简体   繁体   中英

solving linear optimisation in matlab

i have a simple linear problem defined as:

min f(x) such that :A.x <=b
                Aeq.x = beq
                lb<= x <=ub

the vector of my variables is :

x =[x(1)i;x(2)i;x(3)i;x(4)i;x(5);x(6)] i=1...n

i have a difficulty in writing the upper bound constraints defined as follow :

 x(1).i <= x(5)
 x(2).i <= x(5)
 x(3).i <= x(6)

How can i create the uper bound vector ? should i put all the variables on the left side and write it as inequality constraints?

thanks for helping .

The upper bound constraint ub is for when the upper bound are numbers (more precisely a vector of doubles). ub is not for generalized, linear inequality constraints!

I'm going to ignore your .i notation because I have no idea what that is supposed to mean.

Your constraints: x1 <= x5 , x2 <= x5 , x3 <= x6 can be written in matrix form:

[1  0  0  0 -1  0      [x1        [0
 0  1  0  0 -1  0   *   x2   <=    0
 0  0  1  0  0 -1]      x3         0];
                        x4
                        x5
                        x6

Hence to use several of the Matlab solvers you would do:

A = [1, 0, 0, 0, -1,  0;         
     0, 1, 0, 0, -1,  0;
     0, 0, 1, 0,  0, -1];
b = zeros(3, 1);

Now your constraints are written in the form of A*x <= b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM