cyqlone develop
Fast, parallel and vectorized solver for linear systems with optimal control structure.
Loading...
Searching...
No Matches
spring-mass.cpp File Reference
#include <benchmark/benchmark.h>
#include <cyqlone/matio.hpp>
#include <cyqlone/qpalm/backends/ocp-backend-cyqlone.hpp>
#include <cyqlone/qpalm/example-problems/spring-mass.hpp>
#include <cyqlone/qpalm/settings.hpp>
#include <cyqlone/qpalm/solver.hpp>
#include <cyqlone/qpalm/status.hpp>
#include <cyqlone/tracing.hpp>
#include <CLI/CLI.hpp>
#include <batmat/dtypes.hpp>
#include <batmat/lut.hpp>
#include <batmat/openmp.h>
#include <guanaqo/demangled-typename.hpp>
#include <guanaqo/pcm/counters.hpp>
#include <guanaqo/perfetto/trace.hpp>
#include <guanaqo/string-util.hpp>
#include <guanaqo/stringify.h>
#include <batmat-version.h>
#include <cyqlone-version.h>
#include <algorithm>
#include <cstdlib>
#include <filesystem>
#include <format>
#include <generator>
#include <map>
#include <optional>
#include <random>
#include <stdexcept>
#include <utility>
#include "hpipm.hpp"

Go to the source code of this file.

Classes

struct  Options
struct  Problem
struct  Solver
struct  SpringMassParams

Typedefs

using seconds = std::chrono::duration<double>

Enumerations

enum class  ProblemType { WangBoyd2008 , WangBoyd2008Width , Domahidi2012 , ActiveStateConstr }
enum class  WarmStartHPIPM { NoWarmStart , WarmZero , WarmCopy , WarmShift }

Functions

auto counter (auto x)
auto counter_avg (auto x)
qp::problems::SpringMassProblem create_problem (const SpringMassParams &params)
void disable_tracing ()
void trace_run (auto &&, const auto &)
void print_traces (std::ostream &)
template<index_t VL, qp::StorageOrder Order>
void run_benchmark (benchmark::State &state, const std::string &param_name, const SpringMassParams &params, qp::CyQPALMBackendSettings backend_settings, qp::Settings settings, bool warm=false, bool trace=false)
std::generator< Problemget_spring_mass_params (const Options &opts)
void export_problem (const Options &opts)
std::string_view order (qp::StorageOrder o)
template<index_t VL, qp::StorageOrder O>
std::generator< Solverget_cyqlone_solvers (const Options &opts)
std::generator< Solverget_hpipm_solvers (const Options &opts)
template<qp::StorageOrder Order>
std::generator< Solverget_cyqlone_solvers_vl (const Options &opts)
std::generator< Solverget_solvers (const Options &opts)
auto register_benchmarks (const Options &opts)
std::unique_ptr< benchmark::BenchmarkReporter > make_custom_reporter (size_t problem_name_width, size_t solver_name_width, bool print_extra, bool with_color)
void register_options (const char *program, CLI::App &app, Options &opts)
int initialize_google_benchmark (char *program, auto bm_args)
void register_context ()
int main (int argc, char **argv)

Variables

constexpr auto v_native = std::is_same_v<batmat::real_t, double> ? 4 : 8
constexpr auto v = batmat::types::vl_at_most<batmat::real_t, v_native>
const std::map< std::string, ProblemTypeproblem_type_map

Class Documentation

◆ Options

struct Options
Class Members
bool cold = true
bool warm_shift = true
bool warm_copy = false
bool no_updates = false
vector< int > parallelism = {8}
vector< int > vector_length = {v}
bool rm = false
bool cm = true
bool pcr = true
bool hpipm = false
vector< int > horizon {32, 64, 96, 128, 192, 256}
vector< int > masses {6, 12, 30}
uint64_t num_instances = 50
uint64_t seed = 0
ProblemType problem_type = ProblemType::WangBoyd2008
double pcr_max_update_fraction = 0.25
double cr_max_update_fraction = 0.9
int parallel_solve_cr_threshold = 10
int parallel_factor_pcr_threshold = 20
double changing_constr_factor = 0.01
bool custom_reporter = true
bool print_extra = false
bool use_color = false
bool trace = false
string export_problem {}

◆ Problem

struct Problem
Class Members
string name
SpringMassParams params

Typedef Documentation

◆ seconds

using seconds = std::chrono::duration<double>
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 104 of file spring-mass.cpp.

Enumeration Type Documentation

◆ ProblemType

enum class ProblemType
strong
Enumerator
WangBoyd2008 
WangBoyd2008Width 
Domahidi2012 
ActiveStateConstr 
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 55 of file spring-mass.cpp.

◆ WarmStartHPIPM

enum class WarmStartHPIPM
strong
Enumerator
NoWarmStart 
WarmZero 
WarmCopy 
WarmShift 
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 234 of file spring-mass.cpp.

Function Documentation

◆ counter()

auto counter ( auto x)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 48 of file spring-mass.cpp.

◆ counter_avg()

auto counter_avg ( auto x)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 51 of file spring-mass.cpp.

◆ create_problem()

qp::problems::SpringMassProblem create_problem ( const SpringMassParams & params)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 106 of file spring-mass.cpp.

◆ disable_tracing()

void disable_tracing ( )
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 162 of file spring-mass.cpp.

◆ trace_run()

void trace_run ( auto && ,
const auto &  )
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 163 of file spring-mass.cpp.

◆ print_traces()

void print_traces ( std::ostream & )
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 164 of file spring-mass.cpp.

◆ run_benchmark()

template<index_t VL, qp::StorageOrder Order>
void run_benchmark ( benchmark::State & state,
const std::string & param_name,
const SpringMassParams & params,
qp::CyQPALMBackendSettings backend_settings,
qp::Settings settings,
bool warm = false,
bool trace = false )
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 168 of file spring-mass.cpp.

◆ get_spring_mass_params()

std::generator< Problem > get_spring_mass_params ( const Options & opts)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 286 of file spring-mass.cpp.

◆ export_problem()

void export_problem ( const Options & opts)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 320 of file spring-mass.cpp.

◆ order()

std::string_view order ( qp::StorageOrder o)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 340 of file spring-mass.cpp.

◆ get_cyqlone_solvers()

template<index_t VL, qp::StorageOrder O>
std::generator< Solver > get_cyqlone_solvers ( const Options & opts)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 343 of file spring-mass.cpp.

◆ get_hpipm_solvers()

std::generator< Solver > get_hpipm_solvers ( const Options & opts)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 401 of file spring-mass.cpp.

◆ get_cyqlone_solvers_vl()

template<qp::StorageOrder Order>
std::generator< Solver > get_cyqlone_solvers_vl ( const Options & opts)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 425 of file spring-mass.cpp.

◆ get_solvers()

std::generator< Solver > get_solvers ( const Options & opts)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 440 of file spring-mass.cpp.

◆ register_benchmarks()

auto register_benchmarks ( const Options & opts)
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 448 of file spring-mass.cpp.

◆ make_custom_reporter()

std::unique_ptr< benchmark::BenchmarkReporter > make_custom_reporter ( size_t problem_name_width,
size_t solver_name_width,
bool print_extra,
bool with_color )

◆ register_options()

void register_options ( const char * program,
CLI::App & app,
Options & opts )
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 474 of file spring-mass.cpp.

◆ initialize_google_benchmark()

int initialize_google_benchmark ( char * program,
auto bm_args )
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 531 of file spring-mass.cpp.

◆ register_context()

void register_context ( )
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 544 of file spring-mass.cpp.

◆ main()

int main ( int argc,
char ** argv )

Definition at line 599 of file spring-mass.cpp.

Variable Documentation

◆ v_native

auto v_native = std::is_same_v<batmat::real_t, double> ? 4 : 8
constexpr
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 44 of file spring-mass.cpp.

◆ v

auto v = batmat::types::vl_at_most<batmat::real_t, v_native>
constexpr
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 46 of file spring-mass.cpp.

◆ problem_type_map

const std::map<std::string, ProblemType> problem_type_map
Initial value:
{
{"wang-boyd-2008", ProblemType::WangBoyd2008},
{"wang-boyd-2008-width", ProblemType::WangBoyd2008Width},
{"domahidi-2012", ProblemType::Domahidi2012},
{"active-state-constr", ProblemType::ActiveStateConstr},
}
Examples
benchmarks/cyqpalm/spring-mass.cpp.

Definition at line 61 of file spring-mass.cpp.