Changing decision variables in linprog
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 = [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);
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!
3 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!