intlinprog summation MILP optimization problem: ALREADY SOLVED IN GAMS [PROVIDED CODE] BUT CONFUSED IN MATLAB
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
shubham kumar gupta
le 3 Nov 2020
Modifié(e) : shubham kumar gupta
le 4 Nov 2020
CONFUSION: HOW TO MAKE Aeq,A vector for this also confused how to use values in FUN in solve.m
Please Help, I solved this on CPLEX, GAMS but stuck in MATLAB
GAMS WORKING CODE:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/402234/image.png)
SP,PCL,PCM,PCH,ICL,ICM,ICH,CL,CM,CH,RM1,RM2 = 1x54 double
R=[500,500]
Budget=1000
I want to optimize F(below defined) and find values of X,Y [int] , Z[int] ,L,M,H using intlinprog
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/402239/image.png)
PROD.m
function [F,A,B,Aeq,Beq,intcon,lb,ub]= Prod(SP,PCL,PCM,PCH,ICL,ICM,ICH,CL,CM,CH,RM1,RM2,R,Budget,X,Y,Z,L,M,H)
D=length(X);
F=0;
for d=1:D
F=F-SP(d)*X(d)+PCL(d)*L(d)+PCM(d)*M(d)+PCH(d)*H(d);
end
A(1,:)=[1;0;-10000;0;0;0];
A(2,:)=[ 0 ;-1 ;0 ;1 ;0 ;0];
A(3,:)=[0;1;0;0;0;1];
for d=1:D
A(4,1)=A(4,1)+X(d)*RM1(d);
A(5,1)=A(5,1)+X(d)*RM2(d);
A(6,4)=A(6,4)+ICL(d)*L(d);
A(6,5)=A(6,5)+ICM(d)*M(d);
A(6,6)=A(6,6)+ICH(d)*H(d);
end
B=[0;0;1;R(1);R(2);Budget]';
intcon=[2,3];
Aeq=zeros(55,6);
for d=1:D
Aeq(d,1)=X(d);
Aeq(d,4)=-CL(d)*L(d);
Aeq(d,5)=-CM(d)*M(d);
Aeq(d,6)=-CH(d)*H(d);
end
Aeq(55,:)=[0;0;-1;1;1;1;];
Beq=zeros(55,1);
lb=[0 0 0 0 0 0];
ub=[inf inf inf inf inf inf];
end
SOLVE.M [confused]
clc;clear;
FUN=@Prod;
[F,A,B,Aeq,Beq,intcon,lb,ub]=FUN(SP,PCL,PCM,PCH,ICL,ICM,ICH,CL,CM,CH,RM1,RM2,R,Budget,X,Y,Z,L,M,H);
%X,Y,Z,L,M,H
[x,fval]=intlinprog(F,intcon,A,B,Aeq,Beq,lb,ub);
0 commentaires
Réponse acceptée
Alan Weiss
le 4 Nov 2020
Modifié(e) : Alan Weiss
le 4 Nov 2020
I suspect that you would be best served by the problem-based approach. You would have a bit of overhead to learn this approach, but I believe that it would overall be faster for you to do so.
Alan Weiss
MATLAB mathematical toolbox documentation
2 commentaires
shubham kumar gupta
le 4 Nov 2020
Modifié(e) : shubham kumar gupta
le 4 Nov 2020
shubham kumar gupta
le 4 Nov 2020
Modifié(e) : shubham kumar gupta
le 4 Nov 2020
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Optimization Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!