|
| | Opti () |
| | Construct a new optimization environment.
|
| | Opti (const std::vector< std::string > &categories_to_freeze) |
| | Construct with frozen categories.
|
| | ~Opti ()=default |
| SymbolicScalar | variable (double init_guess=0.0, std::optional< double > scale=std::nullopt, std::optional< double > lower_bound=std::nullopt, std::optional< double > upper_bound=std::nullopt) |
| | Create a scalar decision variable.
|
| SymbolicScalar | variable (double init_guess, const VariableOptions &opts, std::optional< double > scale=std::nullopt, std::optional< double > lower_bound=std::nullopt, std::optional< double > upper_bound=std::nullopt) |
| | Create a scalar decision variable with options.
|
| SymbolicVector | variable (int n_vars, double init_guess=0.0, std::optional< double > scale=std::nullopt, std::optional< double > lower_bound=std::nullopt, std::optional< double > upper_bound=std::nullopt) |
| | Create a vector of decision variables with scalar init guess.
|
| SymbolicVector | variable (const NumericVector &init_guess, std::optional< double > scale=std::nullopt, std::optional< double > lower_bound=std::nullopt, std::optional< double > upper_bound=std::nullopt) |
| | Create a vector of decision variables with per-element init guess.
|
| SymbolicScalar | parameter (double value) |
| | Create a scalar parameter.
|
| SymbolicVector | parameter (const NumericVector &value) |
| | Create a vector parameter.
|
| void | subject_to (const SymbolicScalar &constraint) |
| | Add a scalar constraint.
|
| void | subject_to (const SymbolicScalar &constraint, double linear_scale) |
| | Add a scaled scalar constraint.
|
| void | subject_to (const std::vector< SymbolicScalar > &constraints) |
| | Add multiple constraints.
|
| void | subject_to (const std::vector< SymbolicScalar > &constraints, double linear_scale) |
| | Add multiple constraints with one shared linear scale.
|
| void | subject_to (std::initializer_list< SymbolicScalar > constraints) |
| | Add constraints from initializer list.
|
| void | subject_to (std::initializer_list< SymbolicScalar > constraints, double linear_scale) |
| | Add an initializer-list of constraints with one shared linear scale.
|
| void | subject_to_lower (const SymbolicScalar &scalar, double lower_bound) |
| | Apply lower bound to a scalar variable.
|
| void | subject_to_upper (const SymbolicScalar &scalar, double upper_bound) |
| | Apply upper bound to a scalar variable.
|
| void | subject_to_bounds (const SymbolicScalar &scalar, double lower_bound, double upper_bound) |
| | Apply both lower and upper bounds to a scalar variable.
|
| void | subject_to_lower (const SymbolicVector &vec, double lower_bound) |
| | Apply lower bound to all elements of a vector.
|
| void | subject_to_upper (const SymbolicVector &vec, double upper_bound) |
| | Apply upper bound to all elements of a vector.
|
| void | subject_to_bounds (const SymbolicVector &vec, double lower_bound, double upper_bound) |
| | Apply both lower and upper bounds to all elements.
|
| void | minimize (const SymbolicScalar &objective) |
| | Set objective to minimize.
|
| void | minimize (const SymbolicScalar &objective, double objective_scale) |
| | Set objective to minimize with explicit objective scaling.
|
| void | maximize (const SymbolicScalar &objective) |
| | Set objective to maximize.
|
| void | maximize (const SymbolicScalar &objective, double objective_scale) |
| | Set objective to maximize with explicit objective scaling.
|
| OptiSol | solve (const OptiOptions &options={}) |
| | Solve the optimization problem.
|
| SweepResult | solve_sweep (const SymbolicScalar ¶m, const std::vector< double > &values, const OptiOptions &options={}) |
| | Perform parametric sweep over a parameter.
|
| SymbolicVector | derivative_of (const SymbolicVector &var, const NumericVector &with_respect_to, double derivative_init_guess, const std::string &method="trapezoidal") |
| | Create a derivative variable constrained by integration.
|
| void | constrain_derivative (const SymbolicVector &derivative, const SymbolicVector &var, const NumericVector &with_respect_to, const std::string &method="trapezoidal") |
| | Constrain an existing variable to be a derivative.
|
| void | constrain_derivative (const SymbolicVector &derivative, const SymbolicVector &var, const NumericVector &with_respect_to, IntegrationMethod method) |
| | Constrain an existing variable to be a derivative (enum version).
|
| ScalingReport | analyze_scaling (const ScalingAnalysisOptions &opts={}) const |
| | Diagnose variable, objective, and constraint scaling at the current initial point.
|
| const casadi::Opti & | casadi_opti () const |
| | Access the underlying CasADi Opti object.
|
| void | set_initial (const casadi::MX &x, const casadi::DM &v) |
| | Set initial guess for a symbolic expression.
|
| std::vector< SymbolicScalar > | get_category (const std::string &category) const |
| | Get all variables in a category.
|
| std::vector< std::string > | get_category_names () const |
| | Get all registered category names.
|
| bool | is_category_frozen (const std::string &category) const |
| | Check if a category is marked for freezing.
|
Main optimization environment class.
Wraps CasADi's Opti interface to provide Janus-native types and a clean C++ API for nonlinear programming with IPOPT backend.
Example:
opti.
minimize((1 - x) * (1 - x) + 100 * (y - x * x) * (y - x * x));
double x_opt = sol.
value(x);
double value(const SymbolicScalar &var) const
Extract scalar value at optimum.
Definition OptiSol.hpp:45
Main optimization environment class.
Definition Opti.hpp:167
void minimize(const SymbolicScalar &objective)
Set objective to minimize.
Definition Opti.hpp:555
OptiSol solve(const OptiOptions &options={})
Solve the optimization problem.
Definition Opti.hpp:603
SymbolicScalar variable(double init_guess=0.0, std::optional< double > scale=std::nullopt, std::optional< double > lower_bound=std::nullopt, std::optional< double > upper_bound=std::nullopt)
Create a scalar decision variable.
Definition Opti.hpp:200
Rosenbrock Benchmark:
for (int i = 0; i < 9; ++i) {
obj = obj + 100 *
janus::pow(x(i+1) - x(i)*x(i), 2)
}
void subject_to(const SymbolicScalar &constraint)
Add a scalar constraint.
Definition Opti.hpp:396
T pow(const T &base, const T &exponent)
Computes the power function: base^exponent.
Definition Arithmetic.hpp:72
casadi::MX SymbolicScalar
CasADi MX symbolic scalar.
Definition JanusTypes.hpp:70
- See also
- OptiSol for extracting results
-
OptiOptions for solver configuration
-
SweepResult for parametric sweep results
-
ScalingReport for scaling diagnostics