intlinprog summation MILP optimization problem: ALREADY SOLVED IN GAMS [PROVIDED CODE] BUT CONFUSED IN MATLAB
1 次查看(过去 30 天)
显示 更早的评论
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:
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
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 个评论
采纳的回答
Alan Weiss
2020-11-4
编辑:Alan Weiss
2020-11-4
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Optimization Toolbox 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!