problem-凯发k8网页登录
from the series:
express and solve a nonlinear optimization problem with the problem-based approach of optimization toolbox™. interactively define the variables, objective function, and constraints to reflect the mathematical statement of the nonlinear program.
start by creating an optimization problem to hold the problem. next, define optimization variables and their bounds. each optimization variable has its own display name, dimension, type, and bounds. define one or more scalar or array variables to match the variables used in the mathematical statement.
create the objective and constraints with optimization expressions built with the optimization variables. specify them directly for rational expressions. specify other expressions with matlab® functions and convert into optimization expressions with a conversion function. the conversion facility makes it easy to define an optimization problem using existing functions.
use the display functions to review the completed optimization problem. then specify an initial point and solve. the type of solver is automatically selected based on the type of variables, objective, and constraints, relieving you of needing to know the many available solvers.
this video shows how to set up and solve a constrained nonlinear optimization problem in matlab®. in this example, the goal is to minimize this multivariable objective function subject to the following constraints. plot the objective function and constraints. the contour lines show the objective function. the feasible region is inside the blue ellipse and below the red curve.
this is a nonlinear optimization problem. there are two ways to solve nonlinear optimization problems in matlab: using a problem-based approach or a solver-based approach. this example uses a problem-based approach, which uses optimization variables to define the objective and constraints. see the documentation for the solver-based approach.
there are common steps to solving a nonlinear problem with this approach. first, you set up the problem, define optimization variables, define the objective function and constraints, and solve the problem.
now that we have expressed the problem mathematically, we need to express the problem in matlab. create an empty optimization problem container. the optimization problem holds the problem information, including the objective function and constraints.
next, we will define the optimization variables. generally, optimization variables can be scalars, vectors, matrices, or n-d arrays. this example uses variables x and y, which are scalars. create scalar optimization variables for this problem. include the bounds on the variables.
next, we'll create an optimization expression for the objective function. currently, optimization expressions do not support exponentials, so write this as a standard matlab function. to use this objective function in the problem-based approach, you must use a conversion function, which creates an optimization expression. the file name of the objective function is passed with the @ "at" symbol, which creates a "function handle." this tells matlab to identify or "point to" the function, but not to execute the function as matlab typically would do without the symbol. now, add the objective function to the optimization problem. the problem now shows a non-empty objective and associated variables.
this problem has the following nonlinear constraints. the first is a constraint that the solution lies in the ellipse. you can define this constraint as it is written and add it to the problem. the previous constraint was a polynomial inequality and could be expressed as an optimization expression. the second constraint has an exponential term and cannot be written as an optimization expression. this also has extra parameters beyond x and y and includes the variable a. create a function with inputs x, y, and a. convert the function to an optimization expression. include the optimization variables and the parameter a, defined in the matlab workspace. express the inequality and add the constraint to the problem.
now we'll check that the problem formulation is complete. the optimization variables, objective function, constraints, and bounds all look correct.
before solving, we need to define an initial point. the initial values for x and y must be defined as a structure. create a structure representing the initial point as x = -3, y = 3. solve the problem from the initial point. in general, the exit message indicates the stopping conditions and any problems encountered during the optimization. here, the exit message and exit flag indicate that the optimization completed successfully.
try solving the problem from a different initial point. request additional outputs about the solution. the optimization again completed successfully but converged to a different solution. this has a higher objective function value than the first, which indicates this solution is not as good.
add the solution points to the visualization. the plot shows that one solution lies on the boundary of the ellipse and the other lies on the boundary of the exponential constraint and the ellipse.
this video illustrated solving a constrained nonlinear optimization problem. see the documentation for additional examples.
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 mathworks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- (español)
- (english)
- (english)
欧洲
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
亚太
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)