I have the following issue with linear programming specific to biological data.
The specific method requires the maximization and minimization of all values subject to one specific value.
for example I have 5 variables v,w,x,y,z, I need to maximize v, and when this is performed what are the values of w,x,y,z. This is then repeated where w is maximized and the optimal values of v,x,y and z are required.
I have been using the linprog function to determine the value, the following constraints and equalities are set:
v + w + x + y = 100
v + y <= 60
w + x <= 40
x + z <= 30
v + x <= 70
w + y <= 30
y + z <= 20
v,w,x,y,z >= 0
v,w,x,y,z <=100
I'm assuming my problem is the setup of the objective function, currently what I have been trying with moderate success is to set the objective function specific to the value that needs to be optimized eg. 1v + 0w + 0x + 0y + 0z
my code is as follows:
f = [1;0;0;0;0]A = [1 0 0 1 0; 0 1 1 0 0; 0 0 1 0 1; 1 0 1 0 0; 0 1 0 1 0; 0 0 0 1 1]b = [60;40;30;70;30;20] Aeq = [1 1 1 1 0]beq = 100lb =[0;0;0;0;0]ub = [100;100;100;100;100]
When I perform the linprog I get the following values for when v is minimized:
>> x = linprog(f,A,b,Aeq,beq,lb,ub)Optimal solution found.x = 40 10 30 20 0
which according to my notes is correct, however when I maximize v:
>> x = linprog(-f,A,b,Aeq,beq,lb,ub)Optimal solution found.x = 60 30 10 0 0
where the expected solution should have been:
x = 60 30 10 0 20
This pattern repeats with every variable where either all the values are correct or the last value is incorect (usually displaying zero when it is not). Is this an issue as to how I approaced the objective function? Is there a better way to solve these types of issues? Any assistance would be greatly appreciated.
Best Answer