The basic content of nonlinear programming problems
Nonlinear programming solution is the independent variable in a certain combination of linear constraints or nonlinear constrained conditions, such nonlinear objective function determined maximum or minimum of the problem.
When the minimum value of the objective function, the above problem can be written as follows:
\ [\ Z = min {F (x)} \]
\[ \text { s.t. } \left\{\begin{array}{l} {\mathbf{A}\mathbf{X} \leqslant \mathbf{B}} \\ {\mathbf{A}_{\mathrm{eq}} \mathbf{X}=\mathbf{B}_{\mathrm{eq}}} \\ G(x) \leqslant 0 \\ H_{\mathrm{eq}}(x) = 0 \\ {\mathbf{LB} \leqslant \mathbf{X} \leqslant \mathbf{UB}} \end{array}\right. \]
among them
\ (F (x) \) nonlinear objective function
\ (G (x) \) non-linear inequality constraints
\ (H_ \ mathrm {eq} (x) \) constraint is a nonlinear equation
\ (\ mathbf {X} \ ) is the decision variable vector
\ (\ mathbf {A} \ ) is the coefficient of linear matrix inequality
\ (\ mathbf {B} \ ) is the constant vector of linear inequalities right
\ (\ mathbf {A} _ \ mathrm {eq} \) is the matrix of coefficients of linear equations
\ (\ mathbf {B} _ \ mathrm {eq} \) is the constant vector of linear equations right
\ (\ mathbf {LB} \ ) is the lower bound of the decision variable vector
\ (\ mathbf {UB} \ ) is bounded on the decision variable vector
Matlab model code
Call form
[X, FVAL, EXITFLAG, OUTPUT , LAMBDA] = fmincon (FUN, X0, A, B, Aeq, Beq, LB, UB, NONLCON)% , unified form [X, FVAL, EXITFLAG, OUTPUT , LAMBDA] = fmincon (F , X0, A, B, Aeq , Beq, LB, UB, NONLCON)% linear objective function, comprising a nonlinear constrained [X, FVAL, eXITFLAG, OUTPUT , LAMBDA] = fmincon (@ (X) mYOBJ (X), X0 , A, B, Aeq, Beq , LB, UB, @ (X) MYCON (X))% define their own non-linear objective function and constraint functions % objective function function F. myobj = (X-) F. = ...... % nonlinear constrained function function [G, Heq] = MYCON (X-) G = .....% linear inequality constraints Heq = .....% linear equality constraints
Input variables
- FUN objective function, you can define your own input variable X, output target
- X0 is the initial solution
- A is a coefficient matrix inequality constraints (Note that the default direction is less inequality, if not less than, inverse number needs to be taken)
- B is a constant vector inequality right (note that the default direction is less inequality, if not less than, inverse number needs to be taken)
- Aeq equality constraints coefficient matrix
- Is a constant vector equation right Beq
- LB lower bound for the decision variable vector
- UB is bounded on the decision variable vector
- NONLCON nonlinear constraints can define its own, including linear inequality constraints, two restrictions linear equality constraints. Input variable X, the output value calculating inequality, Eq calc
When called, an input parameter is not present, it may be input by []
an empty matrix representation.
Output variables
- X is the optimal solution
- FVAL optimal target
- EXITFLAG run end flag, when equal to 1, indicates that the program converges to X-solution; if equal to 0, represents the number reaches the maximum program running; if less than 0, indicating that in many cases
- OUTPUT number of iterations for the program
- LAMBDA is the solution X related Largrange multiplier and shadow price
Case presentation
The objective function and constraints
\[ \min f(x)=x_{1}^{2}+x_{2}^{2}+8 \]
\[ \text { s.t. }\left\{\begin{array}{l}{x_{1}^{2}-x_{2} \geq 0} \\ {-x_{1}-x_{2}^{2}+2=0} \\ {x_{1}, x_{2} \geq 0}\end{array}\right. \]
Matlab program
CLC Clear Close All X0 = RAND (2,1);% randomly generated initial solution A = []; B = []; Aeq = []; Beq = []; an LB = [0,0]; UB = [] ; [X, FVAL, exitflag] = fmincon of (@ (X) myObj (X), X0, A, B, Aeq, Beq, an LB, UB, @ (X) mycon (X)) % objective function function F = myobj (X) F. X = (. 1) X ^ 2 + (2) + ^ 2. 8; End % nonlinear constraint function function [G, Heq] = mycon (X) G = the -X-(. 1) X ^ 2 + ( 2); Heq the -X-= (. 1) the -X-(2) ^ 2 + 2; End
operation result
x = 1.0000 1.0000 fval = 10.0000 exitflag = 1