Changing decision variables in linprog

5 views (last 30 days)
bus14 on 8 May 2019
Commented: bus14 on 8 May 2019
I am fixing an optimization problem and have a new situation in which I have 2 decision variables that are different for every instance from [0-200] and 1 decision variable which should not change. I am using lin prog. but I do not know how to code this, as linprog normally just optimizes regarding Y,X,Z instead of in my case Y(k),Z(k) and X.
My code is:
clear all
% linprog loop to optimize multiple instances of the problem.
l = 1;
q = 11;
s = 2;
A1 = 1;
for k=1:1:200;
f2 = [c',pk(k)*-s.',pk(k)*(l-q).']; % or [c',-s.',(l-q).']
Aeq = [-1,1,A1.']; %[x y z] --> Want it to be [X Y(k) Z(k)]
beq = [0];
lb = [0,0,0];
ub = [inf,inf,k];
sol = linprog(f2,[],[],Aeq,beq,lb,ub);
x= sol(1);
y(k) = sol(2);
z(k) = sol(3);
constraint that I holds for this problem is Y(k)+A1.'*Z(k)=X I changed it around to Y(k)+A1.'*Z(k)-X=0 as beq can only hold a value and not a variable X. When I run this code the output is zero for every instance. This shouldn't be the case. Does anyone know what I am doing.
I would like to get in the constraint that Y and Z change for every instance of K and that X holds the same value for every instance.
I hope this is possible.
bus14 on 8 May 2019
Sorry, I cannot find a way to better upload this photo, but this is the description of my problem I want to code into Matlab. X is independent of the scenario and Z & Y are dependent. for every scenario k Z and Y take differnt values and have a different probability of occurence. I want to put this al into 1 objective function to minize it and find the optimal decision variables. X, Z and Y. For pk a normal distribtion is used. And k=1:1:200. Solving this problem should give me an optimal value for X. Which I later on can use to find the real optimal values for Z and Y for 1 specific instance.
Sorry to bother you a lot with my questions. But it is important for that I have this code running and working properly.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!