Define variables:
Sqdvar () real number type
Intvar () integer
Binvar()0- 1 type
Set the objective function:
F= objective function
Set eligibility criteria:
F = setup (qualification)
Multiple qualifications are connected by a plus sign:
F = set (qualification)+set (qualification 1)+ set (qualification 2) ...
Solution: solvesdp(F, f)
The solution here is the minimum value of the objective function f under the condition of f, and the maximum value f needs a negative sign before it.
View value after solving:
Double(f) double (variable)
Intvar(m, n): generate integer variables;
Sdpvar(m, n): production variable;
Solvesdp(F, f): Solve the optimal solution (minimum value), where f is the constraint condition (connected by a set) and f is the objective function.
Double: shows the solution.
Here's an example:
Known nonlinear integer programming is:
Max z = x12+x2 2+3 * x3 2+4 * x4 2+2 * x5 2-8 * x1-2 * x2-3 * x3-x4-2 * X5.
Science and technology.
0 & lt= Xi & lt; =99(i= 1,2,...,5)
x 1+x2+x3+x4+X5 & lt; =400
x 1+2 * x2+2 * x3+x4+6 * X5 & lt; =800
2 * x 1+x2+6 * x3 & lt; =800
x3+x4+5 * X5 & lt; =200
Input in matlab
& gt& gtx=intvar( 1,5);
f=[ 1 1 3 4 2]*(x '。 ^2)-[8 2 3 1 2]* x '; f = set(0 & lt; = x & lt=99);
F = F+set([ 1 1 1 1 1]* x ' & lt; = 400)+set([ 1 2 2 1 6]* x ' & lt; = 800)+set(2 * x( 1)+x(2)+6 * x(3)& lt; =800);
F = F+set(x(3)+x(4)+5 * x(5)& lt; =200); solvesdp(F,-F);
max=double(f)
sx=double(x)
* start YALMIP integer branch & binding.
* lower solver: fmin con- standard
* Upper solver: circular
* Maximum number of iterations: 300.
Warning: the problem of relaxation may be non-convex. this means
The branching process is not guaranteed to be found.
Global optimal solution, because the lower bound can be
Invalid. Therefore, don't trust boundaries or gaps. ...
The gap (%) on the node opens below.
1:-8.020 e+004 0.03-8.025 e+004 2
2:-8.020 e+004 0.03-8.025 e+004 1
3 : -8.020E+004
+3 finishing. Cost: -80 199
Max =
80 199
sx =
53 99 99 99 0