Educational algorithms
|
Gradient-descent or steepest-descent algorithm for unconstrained optimization. |
|
Newton's method for unconstrained optimization. |
|
Quasi-Newton method for unconstrained optimization. |
|
Method of Newton-Lagrange for equality-constrained optimization. |
|
Quadratic penalty method for equality-constrained optimization. |
|
A Sequential Quadratic Programming (SQP) algorithm for general constrained optimization. |
|
An Interior Point algorithm for nonlinearly constrained optimization problems. |
|
The Particle Swarm Optimization (PSO) algorithm for unconstrained optimization within a bounded domain. |
|
Nelder-Mead simplex algorithm for unconstrained optimization. |
|
Simulated Annealing algorithm for discrete, unconstrained optimization. |
SteepestDescent
- class modopt.SteepestDescent(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]
Gradient-descent or steepest-descent algorithm for unconstrained 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, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- maxiterint, default=500
Maximum number of iterations.
- opt_tolfloat, default=1e-5
Optimality tolerance. Certifies convergence when the 2-norm of the gradient is less than this value.
- ls_type{None, ‘backtracking-armijo’, ‘derivative-based-strong-wolfe’}, default=’derivative-based-strong-wolfe’
Type of line search to use.
- ls_min_stepfloat, default=1e-14
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_alpha_tolfloat, default=1e-14
Relative tolerance for an acceptable step in the line search.
- ls_gamma_cfloat, default=0.3
Step length contraction factor when backtracking.
- 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.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘itr’, ‘obj’, ‘x’, ‘opt’, ‘time’, ‘nfev’, ‘ngev’, ‘step’.
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.
Newton
- class modopt.Newton(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]
Newton’s method for unconstrained 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, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- maxiterint, default=500
Maximum number of iterations.
- opt_tolfloat, default=1e-6
Optimality tolerance. Certifies convergence when the 2-norm of the gradient is less than this value.
- ls_type{None, ‘backtracking-armijo’, ‘derivative-based-strong-wolfe’}, default=’derivative-based-strong-wolfe’
Type of line search to use.
- ls_min_stepfloat, default=1e-14
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_alpha_tolfloat, default=1e-14
Relative tolerance for an acceptable step in the line search.
- ls_gamma_cfloat, default=0.3
Step length contraction factor when backtracking.
- 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.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘itr’, ‘obj’, ‘x’, ‘opt’, ‘time’, ‘nfev’, ‘ngev’, ‘nhev’, ‘step’.
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.
QuasiNewton
- class modopt.QuasiNewton(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]
Quasi-Newton method for unconstrained 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, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- maxiterint, default=500
Maximum number of iterations.
- opt_tolfloat, default=1e-6
Optimality tolerance. Certifies convergence when the 2-norm of the gradient is less than this value.
- ls_type{None, ‘backtracking-armijo’, ‘derivative-based-strong-wolfe’}, default=’derivative-based-strong-wolfe’
Type of line search to use.
- ls_min_stepfloat, default=1e-14
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_alpha_tolfloat, default=1e-14
Relative tolerance for an acceptable step in the line search.
- ls_gamma_cfloat, default=0.3
Step length contraction factor when backtracking.
- 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.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘itr’, ‘obj’, ‘x’, ‘opt’, ‘time’, ‘nfev’, ‘ngev’, ‘step’.
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.
NewtonLagrange
- class modopt.NewtonLagrange(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]
Method of Newton-Lagrange for equality-constrained 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, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- maxiterint, default=1000
Maximum number of iterations.
- opt_tolfloat, default=1e-8
Optimality tolerance. Certifies convergence when the 2-norm of the Lagrangian gradient is less than this value.
- feas_tolfloat, default=1e-8
Feasibility tolerance. Certifies convergence when the 2-norm of the constraints (constraint violations) is less than this value.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘itr’, ‘obj’, ‘x’, ‘mult’, ‘con’, ‘opt’, ‘feas’, ‘time’, ‘nfev’, ‘ngev’, ‘step’, ‘merit’.
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.
L2PenaltyEq
- class modopt.L2PenaltyEq(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]
Quadratic penalty method for equality-constrained 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, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- maxiterint, default=1000
Maximum number of iterations.
- opt_tolfloat, default=1e-6
Optimality tolerance. Certifies convergence when the 2-norm of the gradient of the Quadratic Penalty function is less than this value.
- feas_tolfloat, default=1e-6
Feasibility tolerance. Certifies convergence when the 2-norm of the constraints (constraint violations) is less than this value.
- rhofloat, default=1000000.
Penalty parameter.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘itr’, ‘obj’, ‘con’, ‘x’, ‘opt’, ‘feas’, ‘time’, ‘nfev’, ‘ngev’, ‘step’, ‘merit’.
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.
SQP
- class modopt.SQP(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 Sequential Quadratic Programming (SQP) algorithm for general constrained 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.- 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.
- qp_tolfloat, default=1e-4
Tolerance for the QP subproblem.
- qp_maxiterint, default=5000
Maximum number of iterations for the QP subproblem.
- ls_min_stepfloat, default=1e-14
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_alpha_tolfloat, default=1e-14
Relative tolerance for an acceptable step in 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.
- 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’, ‘time’, ‘nfev’, ‘ngev’, ‘step’, ‘rho’, ‘merit’.
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.
InteriorPoint
- class modopt.InteriorPoint(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]
An Interior Point algorithm for nonlinearly constrained optimization 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, keeps the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- maxiterint, default=1000
Maximum number of major iterations.
- opt_tolfloat, default=1e-6
Optimality tolerance.
- feas_tolfloat, default=1e-6
Feasibility tolerance.
- fraction_to_boundaryfloat, default=0.99
Fraction to the boundary for step size calculation.
- init_barrier_paramfloat, default=0.50
Initial value of the barrier parameter.
- barrier_reduction_factorfloat, default=0.20
Factor by which the barrier parameter is reduced when convergence tolerances are met for the current barrier problem.
- barrier_reduction_powerfloat, default=1.50
Power to which the barrier parameter is raised when convergence tolerances are met for the current barrier problem.
- barrier_problem_tolerance_factorfloat, default=10.0
Convergence tolerance for each barrier problem set as a factor of the current barrier parameter.
- ls_maxiterint, default=10
Maximum number of line search iterations.
- ls_eta_afloat, default=1e-4
Armijo parameter for the line search.
- ls_gamma_cfloat, default=0.5
Step length contraction factor for backtracking line search.
- ls_max_stepfloat, default=1.0
Maximum step length for line search.
- bfgs_reset_frequencyint, default=100
Iteration frequency to reset the BFGS approximate Hessian.
- 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’, ‘time’, ‘nfev’, ‘ngev’, ‘step’, ‘rho’, ‘merit’.
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.
NelderMeadSimplex
- class modopt.NelderMeadSimplex(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]
Nelder-Mead simplex algorithm for unconstrained 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, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- maxiterint, default=200
Maximum number of iterations.
- initial_lengthfloat, default=1.
Initial length of the simplex edges.
- tolfloat, default=1e-4
Tolerance for the convergence criterion. Certifies convergence when the standard deviation of the objective function values at the simplex vertices is less than this value.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘itr’, ‘obj’, ‘x’, ‘f_sd’, ‘time’, and ‘nfev’.
Methods
print_results([summary_table, all])Print the results of the optimization problem to the terminal.
solve()Run the optimization algorithm to solve the problem.
- 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.
PSO
- class modopt.PSO(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]
The Particle Swarm Optimization (PSO) algorithm for unconstrained optimization within a bounded domain.
Note that the problem needs to define the bounds for each variable. Otherwise, the default bounds of -10 and +10 are used for unbounded variables.
- 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.- populationint, default=25
Number of particles in the swarm.
- maxiterint, default=100
Maximum number of iterations.
- tolfloat, default=1e-4
Tolerance for the convergence criterion. Certifies convergence when the standard deviation of the objective function values of the particles is less than this value.
- inertia_weightfloat, default=0.8
Inertia weight for the velocity update.
- cognitive_coefffloat, default=0.1
Cognitive coefficient (self influence) for the velocity update.
- social_coefffloat, default=0.1
Social coefficient (social influence) for the velocity update.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘itr’, ‘obj’, ‘x’, ‘f_sd’, ‘time’, and ‘nfev’.
Methods
print_results([summary_table, all])Print the results of the optimization problem to the terminal.
solve()Run the optimization algorithm to solve the problem.
- 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.
SimulatedAnnealing
- class modopt.SimulatedAnnealing(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]
Simulated Annealing algorithm for discrete, unconstrained 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, keep the visualization window open after the optimization is complete.- turn_off_outputsbool, default=False
If
True, prevent modOpt from generating any output files.- maxiterint, default=50000
Maximum number of iterations.
- settling_timeint, default=100
Number of iterations after which the temperature is decreased.
- T0float, default=1.
Initial temperature.
- std_dev_tolfloat, default=1.
Tolerance for the convergence criterion. Certifies convergence when the standard deviation of the latest std_dev_sample_size function values is less than this value.
- std_dev_sample_sizeint, default=1000
Number of latest function values to consider for computing the standard deviation for checking the convergence criterion.
- readable_outputslist, default=[]
List of outputs to be written to readable text output files. Available outputs are: ‘itr’, ‘obj’, ‘temp’, ‘x’, ‘f_sd’, and ‘time’.
Methods
print_results([summary_table, all])Print the results of the optimization problem to the terminal.
solve()Run the optimization algorithm to solve the problem.
- 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.