32 template <
typename DERIVED,
38 bool CONTINUOUS =
true>
42 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
44 typedef typename std::conditional<CONTINUOUS,
73 virtual void setProblem(
const OptConProblem_t& optConProblem)
75 optConProblem.verify();
83 if (optConProblem.getInputBoxConstraints())
85 if (optConProblem.getStateBoxConstraints())
87 if (optConProblem.getGeneralConstraints())
94 virtual void configure(
const Settings_t& settings) = 0;
101 const std::string& ns = DERIVED::SolverName)
112 virtual bool solve() = 0;
118 virtual bool runIteration() {
throw std::runtime_error(
"runIteration not supported by solver"); }
179 virtual void changeCostFunction(
const typename OptConProblem_t::CostFunctionPtr_t& cf) = 0;
195 virtual void changeLinearSystem(
const typename OptConProblem_t::LinearPtr_t& lin) = 0;
208 throw std::runtime_error(
"The current solver does not support input box constraints!");
213 throw std::runtime_error(
"The current solver does not support state box constraints!");
227 throw std::runtime_error(
"The current solver does not support general constraints!");
230 virtual SCALAR
getCost()
const {
throw std::runtime_error(
"Get cost not implemented"); }
282 throw std::runtime_error(
"getInputBoxConstraintsInstances not supported.");
287 throw std::runtime_error(
"getInputBoxConstraintsInstances not supported.");
292 throw std::runtime_error(
"getStateBoxConstraintsInstances not supported.");
297 throw std::runtime_error(
"getStateBoxConstraintsInstances not supported.");
313 throw std::runtime_error(
"getGeneralConstraintsInstances not supported.");
318 throw std::runtime_error(
"getGeneralConstraintsInstances not supported.");
331 virtual void generateAndCompileCode(
335 throw std::runtime_error(
"Generate and compile code not implemented for this solver");
348 throw std::runtime_error(
"Generate Code not implemented for this solver");
virtual SCALAR getCost() const
Definition: OptConSolver.h:230
Definition: OptConSolver.h:39
virtual void setProblem(const OptConProblem_t &optConProblem)
Assigns the optimal control problem to the solver.
Definition: OptConSolver.h:73
virtual void configure(const Settings_t &settings)=0
virtual const std::vector< typename OptConProblem_t::ConstraintPtr_t > & getStateBoxConstraintsInstances() const
Definition: OptConSolver.h:295
virtual void setInitialGuess(const Policy_t &initialGuess)=0
virtual const Policy_t & getSolution()=0
virtual bool runIteration()
Definition: OptConSolver.h:118
virtual void changeTimeHorizon(const SCALAR &tf)=0
Change the time horizon the solver operates on.
virtual const core::ControlTrajectory< CONTROL_DIM, SCALAR > getControlTrajectory() const =0
virtual void changeInitialState(const core::StateVector< STATE_DIM, SCALAR > &x0)=0
Change the initial state for the optimal control problem.
virtual std::vector< typename OptConProblem_t::LinearPtr_t > & getLinearSystemsInstances()=0
Direct accessor to the linear system instances.
virtual void changeCostFunction(const typename OptConProblem_t::CostFunctionPtr_t &cf)=0
Change the cost function.
virtual SCALAR getTimeHorizon() const =0
Get the time horizon the solver currently operates on.
virtual const std::vector< typename OptConProblem_t::ConstraintPtr_t > & getGeneralConstraintsInstances() const
Definition: OptConSolver.h:316
POLICY Policy_t
Definition: OptConSolver.h:51
virtual std::vector< typename OptConProblem_t::ConstraintPtr_t > & getGeneralConstraintsInstances()
Direct accessor to the general constraints.
Definition: OptConSolver.h:311
CppAD::AD< CppAD::cg::CG< double > > SCALAR
DERIVED Derived
Definition: OptConSolver.h:53
virtual std::vector< typename OptConProblem_t::ConstraintPtr_t > & getStateBoxConstraintsInstances()
Definition: OptConSolver.h:290
virtual void changeStateBoxConstraints(const typename OptConProblem_t::ConstraintPtr_t con)
Definition: OptConSolver.h:211
SETTINGS Settings_t
Definition: OptConSolver.h:52
virtual ~OptConSolver()
Definition: OptConSolver.h:57
virtual void changeGeneralConstraints(const typename OptConProblem_t::ConstraintPtr_t con)
Change the general constraints.
Definition: OptConSolver.h:225
virtual std::vector< typename OptConProblem_t::ConstraintPtr_t > & getInputBoxConstraintsInstances()
Direct accessor to the box constraint instances.
Definition: OptConSolver.h:280
void configureFromFile(const std::string &filename, bool verbose=true, const std::string &ns=DERIVED::SolverName)
Definition: OptConSolver.h:99
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::conditional< CONTINUOUS, ContinuousOptConProblem< STATE_DIM, CONTROL_DIM, SCALAR >, DiscreteOptConProblem< STATE_DIM, CONTROL_DIM, SCALAR > >::type OptConProblem_t
Definition: OptConSolver.h:46
virtual void generateCode(const ct::core::DerivativesCppadSettings &settings)
Generates source AD source code which can be used in the solver. This method needs to be called ahead...
Definition: OptConSolver.h:346
virtual const core::StateTrajectory< STATE_DIM, SCALAR > getStateTrajectory() const =0
void load(const std::string &filename, bool verbose=true, const std::string &ns="dms")
Definition: DmsSettings.h:124
virtual void changeInputBoxConstraints(const typename OptConProblem_t::ConstraintPtr_t con)
Change the box constraints.
Definition: OptConSolver.h:206
OptConSolver()
Definition: OptConSolver.h:56
StateVector< state_dim > x0
Definition: ConstrainedNLOCTest.cpp:14
virtual void changeNonlinearSystem(const typename OptConProblem_t::DynamicsPtr_t &dyn)=0
Change the nonlinear system.
const bool verbose
Definition: ConstraintComparison.h:18
static const size_t CONTROL_D
Definition: OptConSolver.h:49
virtual std::vector< typename OptConProblem_t::DynamicsPtr_t > & getNonlinearSystemsInstances()=0
Direct accessor to the system instances.
virtual const std::vector< typename OptConProblem_t::ConstraintPtr_t > & getInputBoxConstraintsInstances() const
Definition: OptConSolver.h:285
virtual void changeLinearSystem(const typename OptConProblem_t::LinearPtr_t &lin)=0
Change the linear system.
SCALAR Scalar_t
Definition: OptConSolver.h:54
Definition: OptConProblemBase.h:40
static const size_t STATE_D
Definition: OptConSolver.h:48
virtual const core::tpl::TimeArray< SCALAR > & getTimeArray() const =0
virtual std::vector< typename OptConProblem_t::CostFunctionPtr_t > & getCostFunctionInstances()=0
Direct accessor to the cost function instances.