4 #include <scip/scipdefplugins.h>
9 #include "../Solver.hpp"
16 template<
class SystemType,
int N,
int min_steps_on,
int min_steps_off,
int max_steps_on,
int num_steps_solver_delay, INTEGRATION_SCHEME
integration_scheme> requires
17 std::derived_from<SystemType, System<SystemType::NUM_STATES, SystemType::NUM_CONT_INPUTS, SystemType::NUM_BIN_INPUTS>>
19 :
public Solver<SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme> {
24 std::array<std::array<SCIP_VAR *, N + 1>, SystemType::NUM_STATES> scip_state_vars_;
25 std::array<std::array<SCIP_VAR *, N>, SystemType::NUM_INPUTS> scip_input_vars_;
26 std::array<std::array<SCIP_CONS *, SystemType::NUM_STATES>, N> scip_dynamic_const_;
27 std::array<std::array<SCIP_CONS *,
29 max_steps_on>, SystemType::NUM_BIN_INPUTS> scip_pattern_timing_max_const_;
30 std::array<std::array<SCIP_CONS *, 1 + N - 2>, SystemType::NUM_BIN_INPUTS> scip_pattern_timing_min_const_;
32 std::array<std::array<SCIP_VAR *, N + 1>, SystemType::NUM_STATES> scip_T_state_;
33 std::array<std::array<SCIP_VAR *, N>, SystemType::NUM_INPUTS> scip_T_input_;
34 std::array<std::array<SCIP_CONS *, N + 1>, SystemType::NUM_STATES> scip_Tconsp_state_;
35 std::array<std::array<SCIP_CONS *, N + 1>, SystemType::NUM_STATES> scip_Tconsm_state_;
36 std::array<std::array<SCIP_CONS *, N>, SystemType::NUM_INPUTS> scip_Tconsp_input_;
37 std::array<std::array<SCIP_CONS *, N>, SystemType::NUM_INPUTS> scip_Tconsm_input_;
40 std::array<std::array<SCIP_VAR *, N + 1>, SystemType::NUM_STATES> scip_QuadCostErr_states_;
41 std::array<std::array<SCIP_CONS *, N + 1>, SystemType::NUM_STATES> scip_QuadCostErrCons_states_;
43 SCIP_CONS *scip_QuadCostCons_;
44 SCIP_Var *scip_QuadCostSum_;
47 bool compensate_controller_delay_;
49 const SystemType &system_;
51 Eigen::Vector<double, SystemType::NUM_STATES> state_;
52 Eigen::Vector<double, SystemType::NUM_STATES> state_cost_weights_;
53 Eigen::Vector<double, SystemType::NUM_STATES> final_state_cost_weights_;
54 Eigen::Vector<double, SystemType::NUM_INPUTS> input_cost_weights_;
55 Eigen::Vector<double, SystemType::NUM_STATES> set_point_;
57 void setCost(
COST_TYPE cost_type)
override;
71 SCIPSolver(
const typename SystemType::StateVec &state_weights,
72 const typename SystemType::StateVec &final_weights,
73 const typename SystemType::InputVec &input_weights,
const typename SystemType::StateVec &set_point,
75 const SystemType &system,
double system_dt);
83 void addInputConstraintOnStep(
int step,
const typename SystemType::InputVec &lb,
84 const typename SystemType::InputVec &ub)
override;
86 void addStateConstraintOnStep(
int step,
const typename SystemType::StateVec &lb,
87 const typename SystemType::StateVec &ub)
override;
89 void setFinalWeights(
const typename SystemType::StateVec &final_weights)
override;
91 void setStateWeights(
const typename SystemType::StateVec &state_weights)
override;
93 void setInputWeights(
const typename SystemType::InputVec &state_weights)
override;
95 void setSetPoint(
const typename SystemType::StateVec &set_point)
override;
97 void setState(
const typename SystemType::StateVec &state)
override;
100 const typename Eigen::Matrix<double, SystemType::NUM_INPUTS, SolverBase::history_depth> &bin_input_hist)
override;
102 void setNextInputs(
const typename Eigen::Matrix<
double,
103 SystemType::NUM_INPUTS, num_steps_solver_delay> &next_inputs)
override;
108 solve(
const typename Eigen::Matrix<double, SystemType::NUM_INPUTS, N, Eigen::RowMajor> &last_open_loop_input,
109 const typename Eigen::Matrix<
double, SystemType::NUM_STATES,
110 N + 1, Eigen::RowMajor> &last_open_loop_state,
111 typename Eigen::Matrix<double, SystemType::NUM_INPUTS, N, Eigen::RowMajor> &open_loop_input,
112 typename Eigen::Matrix<
double, SystemType::NUM_STATES,
113 N + 1, Eigen::RowMajor> &open_loop_state)
const override;
117 void writeProblemToFile(
const std::string & file_path);
121 #include "SCIPSolver.tpp"
SOLVER_RETURN
Definition: Solver.hpp:18
COST_TYPE
Definition: Solver.hpp:40
Definition: SCIPSolver.hpp:19
void setSolverTimeLimit(double max_seconds) override
void addStateConstraintOnIndex(int index, double lb, double ub) override
unsigned int getStepsToCompensateControllerDelay() override
void addInputConstraintOnIndex(int index, double lb, double ub) override
SCIPSolver(const typename SystemType::StateVec &state_weights, const typename SystemType::StateVec &final_weights, const typename SystemType::InputVec &input_weights, const typename SystemType::StateVec &set_point, COST_TYPE cost_type, const SystemType &system, double system_dt)
Definition: Solver.hpp:83
static constexpr int history_depth
Definition: Solver.hpp:96