Performant algorithms
|
Class that interfaces modOpt with the SLSQP optimization algorithm from Scipy. |
|
Class that interfaces modOpt with the PySLSQP package which is a Python wrapper for the SLSQP optimization algorithm. |
|
Class that interfaces modOpt with the COBYLA optimization algorithm from Scipy. |
|
Class that interfaces modOpt with the BFGS optimization algorithm from Scipy. |
|
Class that interfaces modOpt with the L-BFGS-B optimization algorithm from Scipy. |
|
Class that interfaces modOpt with the Nelder-Mead optimization algorithm from Scipy. |
|
Class that interfaces modOpt with the COBYQA optimization algorithm. |
|
Class that interfaces modOpt with the trust-constr optimization algorithm from Scipy. |
|
A reconfigurable open-source Sequential Quadratic Programming (SQP) optimizer developed in modOpt for constrained nonlinear optimization. |
alias of |
|
Class that interfaces modOpt with the SNOPTc optimization algorithm. |
|
|
Class that interfaces modOpt with the IPOPT solver in the CasADi package. |
|
Class that interfaces modOpt with the |
|
Class that interfaces modOpt with the CVXOPT package to solve Nonlinear Convex Optimization problems. |
SLSQP
- class modopt.SLSQP(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the SLSQP optimization algorithm from Scipy.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘maxiter’, ‘ftol’, ‘disp’, ‘callback’. See the SLSQP page in modOpt’s documentation for more information.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘x’.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_gradient=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_gradientbool, default=False
If
True, print the optimal objective gradient.- allbool, default=False
If
True, print all available information.
PySLSQP
- class modopt.PySLSQP(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the PySLSQP package which is a Python wrapper for the SLSQP optimization algorithm. PySLSQP can solve nonlinear programming problems with equality and inequality constraints.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘maxiter’, ‘acc’, ‘iprint’, ‘callback’, ‘summary_filename’, ‘visualize’, ‘visualize_vars’, ‘keep_plot_open’, ‘save_figname’, ‘save_itr’, ‘save_vars’, ‘save_filename’, ‘load_filename’, ‘warm_start’, ‘hot_start’. See the PySLSQP page in modOpt’s documentation for more information.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘x’.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_gradient=False, optimal_constraints=False, optimal_jacobian=False, optimal_multipliers=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_gradientbool, default=False
If
True, print the optimal objective gradient.- optimal_constraintsbool, default=False
If
True, print the optimal constraints.- optimal_jacobianbool, default=False
If
True, print the optimal constraint Jacobian.- optimal_multipliersbool, default=False
If
True, print the optimal multipliers.- allbool, default=False
If
True, print all available information.
COBYLA
- class modopt.COBYLA(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the COBYLA optimization algorithm from Scipy. Constrained Optimization BY Linear Approximations or COBYLA is a gradient-free optimization algorithm. COBYLA only supports inequality constraints and bounds.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘maxiter’, ‘rhobeg’, ‘tol’, ‘catol’, ‘disp’, ‘callback’. See the COBYLA page in modOpt’s documentation for more information.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘x’.
Methods
print_results([optimal_variables, all])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
BFGS
- class modopt.BFGS(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the BFGS optimization algorithm from Scipy. BFGS (Broyden-Fletcher-Goldfarb-Shanno) is a quasi-Newton optimization algorithm for unconstrained problems. Therefore, it does not support bounds or constraints.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘maxiter’, ‘gtol’, ‘xrtol’, ‘norm’, ‘c1’, ‘c2’, ‘hess_inv0’, ‘return_all’, ‘disp’, ‘callback’. See the BFGS page in modOpt’s documentation for more information.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘x’, ‘obj’.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_gradient=False, optimal_hessian_inverse=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_gradientbool, default=False
If
True, print the optimal objective gradient.- optimal_hessian_inversebool, default=False
If
True, print the optimal Hessian inverse.- allbool, default=False
If
True, print all available information.
LBFGSB
- class modopt.LBFGSB(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the L-BFGS-B optimization algorithm from Scipy. L-BFGS-B (Limited-memory BFGS with Bound constraints) is a quasi-Newton optimization algorithm for large-scale bound-constrained problems. Therefore, it does not support other types of constraints.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘maxfun’, ‘maxiter’, ‘maxls’, ‘maxcor’, ‘ftol’, ‘gtol’, ‘iprint’, ‘callback’. See the LBFGSB page in modOpt’s documentation for more information.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘x’, ‘obj’.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_gradient=False, optimal_hessian_inverse=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_gradientbool, default=False
If
True, print the optimal objective gradient.- optimal_hessian_inversebool, default=False
If
True, print the optimal Hessian inverse.- allbool, default=False
If
True, print all available information.
NelderMead
- class modopt.NelderMead(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the Nelder-Mead optimization algorithm from Scipy. Nelder-Mead is a gradient-free optimization algorithm that can solve bound-constrained problems. It does not support other types of constraints.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘maxiter’, ‘maxfev’, ‘xatol’, ‘fatol’, ‘adaptive’, ‘initial_simplex’, ‘return_all’, ‘disp’, ‘callback’. See the NelderMead page in modOpt’s documentation for more information.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘x’, ‘obj’.
Methods
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- print_results(optimal_variables=False, final_simplex=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- final_simplexbool, default=False
If
True, print the final simplex coordinates and their objective values.- allbool, default=False
If
True, print all available information.
COBYQA
- class modopt.COBYQA(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the COBYQA optimization algorithm. Constrained Optimization BY Quadratic Approximations or COBYQA is a gradient-free optimization algorithm. Unlike COBYLA, COBYQA also supports equality constraints.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘maxfev’, ‘maxiter’, ‘target’, ‘feasibility_tol’, ‘radius_init’, ‘radius_final’, ‘nb_points’, ‘scale’, ‘filter_size’, ‘store_history’, ‘history_size’, ‘debug’, ‘disp’, ‘callback’. See the COBYQA page in modOpt’s documentation for more information.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘x’, ‘obj’.
Methods
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- print_results(optimal_variables=False, obj_history=False, max_con_viol_history=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- obj_historybool, default=False
If
True, print the objective history.- max_con_viol_historybool, default=False
If
True, print the maximum constraint violation history.- allbool, default=False
If
True, print all available information.
TrustConstr
- class modopt.TrustConstr(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the trust-constr optimization algorithm from Scipy. The trust-constr algorithm uses a trust-region interior point method or an equality-constrained sequential quadratic programming (SQP) method to solve a problem depending on whether the problem has inequality constraints or not. It can make use of second order information in the form of the Hessian of the objective for unconstrained problems or the Hessian of the Lagrangian for constrained problems. TrustConstr can also use objective HVP (Hessian-vector product) when the objective Hessian is unavailable.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘maxiter’, ‘gtol’, ‘xtol’, ‘barrier_tol’, ‘initial_tr_radius’, ‘initial_constr_penalty’, ‘initial_barrier_parameter’, ‘initial_barrier_tolerance’, ‘factorization_method’, ‘sparse_jacobian’, ‘ignore_exact_hessian’, ‘verbose’, ‘callback’. See the TrustConstr page in modOpt’s documentation for more information.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘x’, ‘obj’, ‘opt’, ‘feas’, ‘grad’, ‘lgrad’, ‘con’, ‘jac’, ‘lmult_x’, ‘lmult_c’, ‘iter’, ‘cg_niter’, ‘nfev’, ‘nfgev’, ‘nfhev’, ‘ncev’, ‘ncgev’, ‘nchev’, ‘tr_radius’, ‘constr_penalty’, ‘barrier_parameter’, ‘barrier_tolerance’, ‘cg_stop_cond’, ‘time’.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_gradient=False, optimal_constraints=False, optimal_constraint_jacobian=False, optimal_lagrange_multipliers=False, optimal_lagrangian_gradient=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_gradientbool, default=False
If
True, print the optimal objective gradient.- optimal_constraintsbool, default=False
If
True, print the optimal constraints.- optimal_constraint_jacobianbool, default=False
If
True, print the optimal constraints Jacobian.- optimal_lagrange_multipliersbool, default=False
If
True, print the optimal Lagrange multipliers.- optimal_lagrangian_gradientbool, default=False
If
True, print the optimal Lagrangian gradient.- allbool, default=False
If
True, print all available information.
OpenSQP
- class modopt.OpenSQP(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
A reconfigurable open-source Sequential Quadratic Programming (SQP) optimizer developed in modOpt for constrained nonlinear optimization.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keeps the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- verbosity{0, 1}, default=0
If
0, suppresses all console outputs. If1, prints various convergence measures to monitor optimization progress and diagnostic messages for debugging purposes.- maxiterint, default=1000
Maximum number of major iterations.
- opt_tolfloat, default=1e-7
Optimality tolerance.
- feas_tolfloat, default=1e-7
Feasibility tolerance. Certifies convergence when the “scaled” maximum constraint violation is less than this value.
- aqp_primal_feas_tolfloat, default=1e-8
Tolerance for the primal feasibility of the augmented QP subproblem.
- aqp_dual_feas_tolfloat, default=1e-8
Tolerance for the dual feasibility of the augmented QP subproblem.
- aqp_time_limitfloat, default=5.0
Time limit for the augmented QP solution in seconds.
- ls_min_stepfloat, default=1e-12
Minimum step size for the line search.
- ls_max_stepfloat, default=1.
Maximum step size for the line search.
- ls_maxiterint, default=10
Maximum number of iterations for the line search.
- ls_eta_afloat, default=1e-4
Armijo (sufficient decrease condition) parameter for the line search.
- ls_eta_wfloat, default=0.9
Wolfe (curvature condition) parameter for the line search.
- ls_alpha_tolfloat, default=1e-14
Relative tolerance for an acceptable step in the line search.
- bfgs_init_lag_hessnp.ndarray, default=None
Initial symmetric and positive definite approximation of the Lagrangian Hessian of shape (nx,nx) for the BFGS update. Available only with SciPy >= 1.14.0.
- init_multipliersdict, default=None
Initial Lagrange multiplier values for the bounds and constraints. Should be a dict with keys ‘cl’, ‘cu’, ‘xl’, ‘xu’ corresponding to the lower and upper bounds of the constraints and variables, and values being arrays of the same length as the number of constraints/variables.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘major’, ‘obj’, ‘x’, ‘lag_mult’, ‘slacks’, ‘constraints’, ‘opt’, ‘feas’, ‘sum_viol’, ‘max_viol’, ‘time’, ‘nfev’, ‘ngev’, ‘step’, ‘rho’, ‘merit’, ‘elastic’, ‘gamma’, ‘low_curvature’.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([summary_table, all])Print the results of the optimization problem to the terminal.
solve()Run the optimization algorithm to solve the problem.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(summary_table=False, all=False)
Print the results of the optimization problem to the terminal.
- Parameters
- summary_tablebool, default=False
If
True, print the summary table for the optimization.- allbool, default=False
If
False, print only the scalar outputs of the optimization problem. Otherwise, print all the outputs of the optimization problem.
SNOPT
- class modopt.external_libraries.snopt.snoptc.SNOPTc(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the SNOPTc optimization algorithm.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. See the SNOPT page in modOpt’s documentation for more information.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_constraints=False, optimal_multipliers=False, all=False)
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_constraintsbool, default=False
If
True, print the optimal constraints.- optimal_multipliersbool, default=False
If
True, print the optimal multipliers.- allbool, default=False
If
True, print all available information.
IPOPT
- class modopt.IPOPT(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the IPOPT solver in the CasADi package. IPOPT is an open-source interior point algorithm that can solve nonlinear programming problems with equality and inequality constraints. It can make use of second order information in the form of the Hessian of the objective for unconstrained problems or the Hessian of the Lagrangian for constrained problems.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. See the IPOPT page in modOpt’s documentation for more information.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Run the optimization algorithm to solve the problem.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_constraints=False, optimal_multipliers=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_constraintsbool, default=False
If
True, print the optimal constraints.- optimal_multipliersbool, default=False
If
True, print the optimal multipliers.- allbool, default=False
If
True, print all available information.
ConvexQPSolvers
- class modopt.ConvexQPSolvers(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the
qpsolverspackage which provides a unified interface to various convex Quadratic Programming (QP) solvers available in Python. By default, the solver used is ‘quadprog’. Make sure to install ‘qpsolvers’ usingpip install qpsolvers[wheels_only] quadprog osqpto install interfaced open-source QP solvers with pre-compiled binaries.- Parameters
- problemProblem or ProblemLite
Object containing the convex QP problem to be solved.
- turn_off_outputsbool, default=False
If
True, prevents modOpt from generating any output files.- solver_optionsdict
Dictionary containing the solver name and its options. Available global options are:
'solver'and'verbose'. Solver-specific options can also be passed. Make sure the ‘solver’ specified is installed on your machine.
- Attributes
- solver_namestr
The name of the solver to be used.
- available_solverslist
The list of available solvers in qpsolvers. A subset of all the suppported solvers that are installed.
- supported_solverslist
The list of supported solvers in qpsolvers.
- Pnp.ndarray
The symmetric cost matrix. Always positive semi-definite for convex QP. Some solvers also require it to be positive definite.
- qnp.ndarray
The cost vector.
- Gnp.ndarray
The linear inequality constraint matrix.
- hnp.ndarray
The linear inequality constraint vector.
- Anp.ndarray
The linear equality constraint matrix.
- bnp.ndarray
The linear equality constraint vector.
- lbnp.ndarray
The lower bounds for the variables.
- ubnp.ndarray
The upper bounds for the variables.
- resultsdict
The results of the optimization.
- qp_problem: qpsolvers.Problem
The QP problem to be solved.
Attributes of qpsolvers.Problem:
- Pnp.ndarray
The symmetric cost matrix. Always positive semi-definite for convex QP. Some solvers also require it to be positive definite.
- qnp.ndarray
The cost vector.
- Gnp.ndarray
The linear inequality constraint matrix.
- hnp.ndarray
The linear inequality constraint vector.
- Anp.ndarray
The linear equality constraint matrix.
- bnp.ndarray
The linear equality constraint vector.
- lbnp.ndarray
The lower bounds for the variables.
- ubnp.ndarray
The upper bounds for the variables.
- has_sparsebool
Check whether the problem has sparse matrices.
- is_unconstrainedbool
Check whether the problem has constraints.
Methods of qpsolvers.Problem:
- check_constraints()
Check if the problem constraints are correctly defined.
- cond(active_set: qpsolvers.ActiveSet)
Compute the condition number of the symmetric problem matrix representing hte problem data.
- save(filename: str)
Save the problem data to a file. The “.npz” extension will be appended to the filename if it is not already there.
- load(filename: str)
Load the problem data from a file.
- unpack()
Unpack the problem data into a tuple of numpy arrays (P, q, G, h, A, b, lb, ub) and return it.
- get_cute_classification(interest: str)
Get the CUTE classification string of the problem. interest can be ‘A’, ‘M’, or ‘R’, depending on whether your problem is academic, part of a modeling exercise, or has real-world applications.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the results of the optimization problem to the console.
solve()Solve the QP problem by calling qpsolvers with the requested solver and its options.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_constraints=False, optimal_dual_variables=False, extras=False, all=False)[source]
Print the results of the optimization problem to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_constraintsbool, default=False
If
True, print the optimal constraints.- optimal_dual_variablesbool, default=False
If
True, print the optimal dual variables.- extrasbool, default=False
If
True, print the solver-specific extra information returned.- allbool, default=False
If
True, print all available information.
CVXOPT
- class modopt.CVXOPT(problem, recording=False, out_dir=None, hot_start_from=None, hot_start_atol=0.0, hot_start_rtol=0.0, visualize=[], keep_viz_open=False, turn_off_outputs=False, **kwargs)[source]
Class that interfaces modOpt with the CVXOPT package to solve Nonlinear Convex Optimization problems. Note that second derivatives (Hessians) must be provided for these problems, EQUALITY constraints must be LINEAR. Lagrangian Hessian must be provided for constrained problems, and objective Hessian must be provided for unconstrained/bounded problems.
- Parameters
- problemProblem or ProblemLite
Object containing the problem to be solved.
- recordingbool, default=False
If
True, record all outputs from the optimization. This needs to be enabled for hot-starting the same problem later, if the optimization is interrupted.- out_dirstr, optional
The directory to store all the output files generated from the optimization.
- hot_start_fromstr, optional
The record file from which to hot-start the optimization.
- hot_start_atolfloat, default=0.
The absolute tolerance check for the inputs when reusing outputs from the hot-start record.
- hot_start_rtolfloat, default=0.
The relative tolerance check for the inputs when reusing outputs from the hot-start record.
- visualizelist, default=[]
The list of scalar variables to visualize during the optimization.
- keep_viz_openbool, default=False
If
True, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- solver_optionsdict, default={}
Dictionary containing the options to be passed to the solver. Available options are: ‘show_progress’, ‘maxiters’, ‘abstol’, ‘reltol’, ‘feastol’, ‘refinement’. See the CVXOPT page in modOpt’s documentation for more information.
Methods
check_first_derivatives([x, step, formulation])Check the first derivatives of the optimization problem using finite differences.
print_results([optimal_variables, ...])Print the optimization results to the console.
solve()Solve the nonlinear convex problem by calling cvxopt.solvers.cp with given options.
- check_first_derivatives(x=None, step=1e-06, formulation='rs')
Check the first derivatives of the optimization problem using finite differences.
- Parameters
- xnp.ndarray, optional
The design variables at which the derivatives are to be checked. If not provided, the initial design variables are used.
- stepfloat, default=1e-6
The step size for the finite differences.
- print_results(optimal_variables=False, optimal_constraints=False, optimal_dual_variables=False, optimal_slack_variables=False, all=False)[source]
Print the optimization results to the console.
- Parameters
- optimal_variablesbool, default=False
If
True, print the optimal variables.- optimal_constraintsbool, default=False
If
True, print the optimal constraints.- optimal_dual_variablesbool, default=False
If
True, print the optimal dual variables.- optimal_slack_variablesbool, default=False
If
True, print the optimal slack variables.- allbool, default=False
If
True, print all available information.