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!