# Changing decision variables in linprog

5 views (last 30 days)
bus14 on 8 May 2019
Commented: bus14 on 8 May 2019
Hi!
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.
pd=makedist('normal','mu',100,'sigma',10)
demand=[0:1:200];
prob=normpdf(demand,100,10);
pk=zeros(size(prob));
i=1;
j=1;
l = 1;
q = 11;
s = 2;
A1 = 1;
c=10;
Etot=0;
for k=1:1:200;
pk(k)=prob(k);
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 = ;
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);
E(k)=pk(k)*(-s*y(k)+(l-q)*z(k));
Etot=Etot+E(k);
end
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.
Thankyou!
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.