Hey, my name is Maria and I am a complete newby to MATLAB & Yalmip.
I decided to ask my question directly here after spending the last days reading several tutorials about Yalmip - which are too hard for me as a beginner to understand.
In the following code I want to add 3 binary variables (fA, fB, fC)to represent the possibility of "saving" startup costs of a machine when it is not used.
The amount of a product (1/2/3) being produced on machines a/b/c are to be determined by the Yalmip solver. ---> ax1, bx1,....
During the optimisation it should be taken into account, that IF a machine isn't used (ax1+ax2+ax3==0) there will be no startup costs for this machine. --> fA=0
Can I add this if-condition to the constraints ?
I think I found the necessary solver in the documentation (intlinrprog) but I don't know how to use binvar & implies correctly in this case.
I would really appreciate if someone could help me!!
Thank you very much in advance,
Maria
clear;
%quantity per part x1, x2, x3
x1=60; x2=60; x3=60;
%startup costs per machine a,b,c in €
CA=220;
CB=170;
CC=250;
%capacity per machine a,b,c in min
tA=360; tB=420; tC=480;
%operating time t1, t2, t3 per part x1, x2, x3 in min
t1=10;
t2=12;
t3=13;
%operating costs per machine a,b,c, per time in min
cA=2; cB=1.75; cC=1.9;
%purchase prices per part x1, x2, x3 in €
p1= 80;
p2= 45;
p3= 60;
options=sdpsettings ('solver','intlinprog');
%amount of part 1/2/3 produced on machine a/b/c
ax1=sdpvar; ax2=sdpvar; ax3=sdpvar;
bx1=sdpvar; bx2=sdpvar; bx3=sdpvar;
cx1=sdpvar; cx2=sdpvar; cx3=sdpvar;
px1=sdpvar; px2=sdpvar; px3=sdpvar;
fA=binvar(1,1); fB=binvar(1,1); fC=binvar(1,1);
%constraints
constraints=[ax1+bx1+cx1+px1==x1];%meet production target
constraints=[constraints, ax2+bx2+cx2+px2==x2];%meet production target
constraints=[constraints, ax3+bx3+cx3+px3==x3];%meet production target
constraints=[constraints, ax1*t1+ax2*t2+ax3*t3<=tA];%capacity restriction
constraints=[constraints, bx1*t1+bx2*t2+bx3*t3<=tB];%capacity restriction
constraints=[constraints, cx1*t1+cx2*t2+cx3*t3<=tC];%capacity restriction
%if(ax1+ax2+ax3)==0 -> fA=0
constraints=[constraints, ax1>=0; bx1>=0;cx1>=0;ax2>=0;bx2>=0;cx2>=0;ax3>=0;bx3>=0;cx3>=0;px1>=0; px2>=0; px3>=0];
constraints=[constraints, integer(ax1),integer(ax2),integer(ax3),integer(bx1),integer(bx2),integer(bx3),integer(cx1),integer(cx2),integer(cx3),integer(px1),integer(px2),integer(px3)];
objective=((fA*CA+fB*CB+fC*CC)+(px1*p1+px2*p2+px3*p3)+(t1*cA*ax1+t1*cB*bx1+t1*cC*cx1)+(t2*cA*ax2+t2*cB*bx2+t2*cC*cx2)+(t3*cA*ax3+t3*cB*bx3+t3*cC*cx3));
info= optimize(constraints, objective, options);
optim_a=[double(ax1); double(ax2); double(ax3)];
optim_b=[double(bx1); double(bx2); double(bx3)];
optim_c=[double(cx1); double(cx2); double(cx3)];
optim_p=[double(px1); double(px2); double(px3)];
optim_dec=[optim_a; optim_b; optim_c; optim_p];
optim_f=double (objective)
%show solution
optim_show=[optim_a, optim_b, optim_c, optim_p]