|
virtual void | addInputConstraintOnIndex (int index, double lb, double ub)=0 |
|
virtual void | addStateConstraintOnIndex (int index, double lb, double ub)=0 |
|
virtual void | addInputConstraintOnStep (int step, const SystemType::InputVec &lb, const SystemType::InputVec &ub)=0 |
|
virtual void | addStateConstraintOnStep (int step, const SystemType::StateVec &lb, const SystemType::StateVec &ub)=0 |
|
virtual void | setFinalWeights (const SystemType::StateVec &final_weights)=0 |
|
virtual void | setStateWeights (const SystemType::StateVec &state_weights)=0 |
|
virtual void | setInputWeights (const SystemType::InputVec &state_weights)=0 |
|
virtual void | setCost (COST_TYPE cost_type)=0 |
|
virtual void | setSetPoint (const SystemType::StateVec &set_point)=0 |
|
virtual void | setState (const SystemType::StateVec &state)=0 |
|
virtual void | setInputHistory (const Eigen::Matrix< double, SystemType::NUM_INPUTS, history_depth > &bin_input_hist)=0 |
|
virtual void | setNextInputs (const Eigen::Matrix< double, SystemType::NUM_INPUTS, num_steps_solver_delay > &next_inputs)=0 |
|
virtual void | setSolverTimeLimit (double max_seconds)=0 |
|
virtual unsigned int | getStepsToCompensateControllerDelay ()=0 |
|
virtual SOLVER_RETURN | solve (const Eigen::Matrix< double, SystemType::NUM_INPUTS, N, Eigen::RowMajor > &last_open_loop_input, const Eigen::Matrix< double, SystemType::NUM_STATES, N+1, Eigen::RowMajor > &last_open_loop_state, Eigen::Matrix< double, SystemType::NUM_INPUTS, N, Eigen::RowMajor > &open_loop_input, Eigen::Matrix< double, SystemType::NUM_STATES, N+1, Eigen::RowMajor > &open_loop_state) const =0 |
|
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>
class mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >
This defines abstract base class defines a wrapper around any mixed integer solver and defines a low level solver interface to be used within an mpc. For a highlevel interface refer to MPC, which takes any Solver implementation as a template argument.
The solver discretizes the time into time steps of same length.
- Template Parameters
-
SystemType | refers to the system dynamics and must be a class implementing System |
N | prediction horizon |
min_steps_on | number of discrete time steps that the binary inputs have to stay on |
min_steps_off | number of discrete time steps that the binary inputs have to stay off |
max_steps_on | maximum number of discrete time steps that the binary inputs can stay on |
num_steps_solver_delay | number of discrete time steps that are solver delay, referring to the time delay from the time point system is at a current state (which will be set by setState()) and the time point at which the optimal input returned by solve() is applied to the system. This delay is compensated by predicting the systems state based on the inputs that will be applied during this delay time. This inputs are set via setNextInputs() and can be for example taken from the previous open loop prediction. Obviously, the optimal input predicted by the solver and returned by solve() is the one at num_steps_solver_delay in the next open loop prediction, as the first refer to the predicted states during the delay. The correct index for the next input can be aquired using getStepsToCompensateControllerDelay(). |
integration_scheme | discretization method |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::addInputConstraintOnIndex |
( |
int |
index, |
|
|
double |
lb, |
|
|
double |
ub |
|
) |
| |
|
pure virtual |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::addInputConstraintOnStep |
( |
int |
step, |
|
|
const SystemType::InputVec & |
lb, |
|
|
const SystemType::InputVec & |
ub |
|
) |
| |
|
pure virtual |
Adds or replaces the bounding box constraint to the input vector at given time step
- Parameters
-
step | time step 0<=step<=N |
lb | lower bound |
ub | upper bound |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::addStateConstraintOnIndex |
( |
int |
index, |
|
|
double |
lb, |
|
|
double |
ub |
|
) |
| |
|
pure virtual |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::addStateConstraintOnStep |
( |
int |
step, |
|
|
const SystemType::StateVec & |
lb, |
|
|
const SystemType::StateVec & |
ub |
|
) |
| |
|
pure virtual |
Adds or replaces the bounding box constraint to the state vector at given time step
- Parameters
-
step | time step 0<=step<=N |
lb | lower bound |
ub | upper bound |
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>
virtual unsigned int mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::getStepsToCompensateControllerDelay |
( |
| ) |
|
|
pure virtual |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setCost |
( |
COST_TYPE |
cost_type | ) |
|
|
pure virtual |
Sets the error function type
- Parameters
-
cost_type | error function type |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setFinalWeights |
( |
const SystemType::StateVec & |
final_weights | ) |
|
|
pure virtual |
Sets the state error weights of the final predicted state
- Parameters
-
final_weights | weight vector where each vector element refers to the respective state vector element |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setInputHistory |
( |
const Eigen::Matrix< double, SystemType::NUM_INPUTS, history_depth > & |
bin_input_hist | ) |
|
|
pure virtual |
Sets the input history of past inputs. This is necessary in order to respect the timing constraints.
- Parameters
-
bin_input_hist | input history matrix, where the first index refers to the input vector element and the second index to the history time step. Thereby index 0 refers to the most past element, and index history_depth refers to the current time step. |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setInputWeights |
( |
const SystemType::InputVec & |
state_weights | ) |
|
|
pure virtual |
Sets the input weights of all intermediate predicted inputs
- Parameters
-
state_weights | weight vector where each vector element refers to the respective input vector element |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setNextInputs |
( |
const Eigen::Matrix< double, SystemType::NUM_INPUTS, num_steps_solver_delay > & |
next_inputs | ) |
|
|
pure virtual |
Sets the inputs that the will be applied to the system during the solver delay, in order to predicts the systems behaviour while the solver optimizes the next input
- Parameters
-
next_inputs | input sequence |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setSetPoint |
( |
const SystemType::StateVec & |
set_point | ) |
|
|
pure virtual |
Sets the state set point. The state error is then calculated by applying the error function (as defined by setCost) to the difference between the current or predicted state and the set point. Each state error vector element is weighted by the state and final weights as specified by setStateWeights and setFinalWeights
- Parameters
-
set_point | the state set point |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setSolverTimeLimit |
( |
double |
max_seconds | ) |
|
|
pure virtual |
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setState |
( |
const SystemType::StateVec & |
state | ) |
|
|
pure virtual |
Sets the current system state which is then used to do the optimization and prediction process.
- Parameters
-
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>
virtual void mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::setStateWeights |
( |
const SystemType::StateVec & |
state_weights | ) |
|
|
pure virtual |
Sets the state error weights of all intermediate predicted states
- Parameters
-
state_weights | weight vector where each vector element refers to the respective state vector element |
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>
virtual SOLVER_RETURN mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::solve |
( |
const Eigen::Matrix< double, SystemType::NUM_INPUTS, N, Eigen::RowMajor > & |
last_open_loop_input, |
|
|
const Eigen::Matrix< double, SystemType::NUM_STATES, N+1, Eigen::RowMajor > & |
last_open_loop_state, |
|
|
Eigen::Matrix< double, SystemType::NUM_INPUTS, N, Eigen::RowMajor > & |
open_loop_input, |
|
|
Eigen::Matrix< double, SystemType::NUM_STATES, N+1, Eigen::RowMajor > & |
open_loop_state |
|
) |
| const |
|
pure virtual |
Starts the solving process in order to find the optimal input and state sequence. Given the cost function and constraints. If a time limit as been set with setSolverTimeLimit, the method will return after that time with no or the best solution found so far.
- Parameters
-
last_open_loop_input | an optimal open loop input sequence (i.e. from last iteration) that is used to warm start the solver |
last_open_loop_state | an optimal open loop state sequence (i.e. from last iteration) that is used to warm start the solver |
open_loop_input | the optimal/suboptimal input sequence found by the solver, depending on the delay compensation the next input is at discrete time step getStepsToCompensateControllerDelay() |
open_loop_state | the optimal/suboptimal state sequence found by the solver |
- Returns
- The return state indicates if the solution is optimal, suboptimal or no solution was found
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>
constexpr int mimpc::Solver< SystemType, N, min_steps_on, min_steps_off, max_steps_on, num_steps_solver_delay, integration_scheme >::history_depth |
|
staticconstexpr |
Initial value:= std::max(
{0, max_steps_on - num_steps_solver_delay, min_steps_off - num_steps_solver_delay,
min_steps_on - num_steps_solver_delay})
Gives, based on the timing constraints the number of past discrete time steps that the optimization problem needs to know