Appendix A
The Lingo code of the first Model, Z1. This code is applied to the generated data instances of group G_1 (2-5-10). The code of the other groups and all results are provided in the article/Supplementary Materials.
MODEL:
SETS:
PLANT:PLANTCAPACITY;
DISTRIBUTOR:DISTRIBUTORCAPACITY,OPINNINGCOST,U;
RETAILER:DEMAND;
LINK1(PLANT,DISTRIBUTOR):FIJ,YIJ,CIJ,XIJ;
LINK2(DISTRIBUTOR,RETAILER):FJK,YJK,CJK,XJK;
ENDSETS
DATA:
PLANT = P1, P2;
DISTRIBUTOR = D1, D2, D3, D4 D5;
RETAILER = R1, R2, R3, R4, R5, R6 R7 R8 R9 R10;
PLANTCAPACITY = @file('PDR_2-5-10_1.txt');
DEMAND = @file('PDR_2-5-10_1.TXT');
OPINNINGCOST = @file('PDR_2-5-10_1.TXT');
FIJ = @file('PDR_2-5-10_1.TXT');
CIJ = @file('PDR_2-5-10_1.TXT');
FJK = @file('PDR_2-5-10_1.TXT');
CJK = @file('PDR_2-5-10_1.TXT');
@TEXT('OUT1.TXT') = @WRITE( ' PLANT DISTRIBUTOR QUANTITY', @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITE( ' ----------------------------------', @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITEFOR( LINK1( I, J) | XIJ( I, J) #GT# 0:8*' ', PLANT( I), 8*' ',DISTRIBUTOR( J), 8*' ', @FORMAT( XIJ( I, J), '8.0f'), @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITE( ' -----------------------------------', @NEWLINE( 2));
@TEXT('OUT1.TXT') = @WRITE( ' DISTRIBUTOR RETAILER QUANTITY', @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITE( ' ----------------------------------', @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITEFOR( LINK2( J,K) | XJK( J,K) #GT# 0:8*' ', DISTRIBUTOR( J), 8*' ', RETAILER( K), 8*' ', @FORMAT( XJK( J,K), '8.0f'), @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITE( ' ----------------------------------', @NEWLINE( 1));
ENDDATA
[TCOST] MIN = FixedCost + FlowCost + OpeningCost ;
FixedCost = @SUM(LINK1(I,J):FIJ(I,J)*YIJ(I,J)) + @SUM(LINK2(J,K):FJK(J,K)*YJK(J,K)) ;
FlowCost = @SUM(LINK1(I,J):CIJ(I,J)*XIJ(I,J)) + @SUM(LINK2(J,K):CJK(J,K)*XJK(J,K)) ;
OpeningCost = @SUM(DISTRIBUTOR(J):OPINNINGCOST(J)*U(J));
@FOR(PLANT(I): @SUM(DISTRIBUTOR(J):XIJ(I,J))< PLANTCAPACITY(I));
@FOR(DISTRIBUTOR(J):@SUM(RETAILER(K):XJK(J,K))< = DISTRIBUTORCAPACITY(J)*U(J));
@FOR(RETAILER(K):@SUM(DISTRIBUTOR(J):XJK(J,K))= DEMAND(K));
@FOR(DISTRIBUTOR(J):@SUM(RETAILER(K):DEMAND(K))= DISTRIBUTORCAPACITY(J));
! DC balance constraints;
@FOR(DISTRIBUTOR(J):@SUM(PLANT(I):XIJ(I,J)) = @SUM(RETAILER(K):XJK(J,K)));
@FOR(LINK1:XIJ> 0);
@FOR(LINK2:XJK> 0);
@FOR(LINK1:YIJ = @IF(XIJ#GT#0,1,0));
@FOR(LINK2:YJK = @IF(XJK#GT#0,1,0));
@FOR(DISTRIBUTOR:@BIN(U));
!TOTAL COST OUTPUT;
CALC:
@SOLVE();
@TEXT('CostandTime_2-5-10-Z1-Obj.TXT', 'a') = @WRITE( 'PDR_2-5-10_1.TXT',6*' ', OpeningCost,6*' ', FixedCost ,6*' ', FlowCost ,6*' ,TCOST, 6*' ','CPU = ',6*' ', @Time(), @NEWLINE( 1));
ENDCALC
END
ALTER ALL '1.txt'3_%10-%-50.txt'
GO
ALTER ALL '3_%10-%-50.txt'3_%10-%-40.txt'
GO
ALTER ALL '3_%10-%-40.txt'3_%10-%-30.txt'
GO
ALTER ALL '3_%10-%-30.txt'3_%10-%-20.txt'
GO
…
Appendix B
The Lingo code of the second Model, Z2. This code is applied to the generated data instances of group G_1 (2-5-10). The code of the other groups and all results are provided in the article/Supplementary Materials.
MODEL:
SETS:
PLANT:PLANTCAPACITY;
DISTRIBUTOR:DISTRIBUTORCAPACITY,OPINNINGCOST,U;
RETAILER:DEMAND;
LINK1(PLANT,DISTRIBUTOR):FIJ,YIJ,CIJ,XIJ;
LINK2(DISTRIBUTOR,RETAILER):FJK,YJK,CJK,XJK;
ENDSETS
DATA:
PLANT = P1, P2;
DISTRIBUTOR = D1, D2, D3, D4 D5;
RETAILER = R1, R2, R3, R4, R5, R6 R7 R8 R9 R10;
PLANTCAPACITY = @file('PDR_2-5-10_1.txt');
DEMAND = @file('PDR_2-5-10_1.TXT');
OPINNINGCOST = @file('PDR_2-5-10_1.TXT');
FIJ = @file('PDR_2-5-10_1.TXT');
CIJ = @file('PDR_2-5-10_1.TXT');
FJK = @file('PDR_2-5-10_1.TXT');
CJK = @file('PDR_2-5-10_1.TXT');
@TEXT('OUT1.TXT') = @WRITE( ' PLANT DISTRIBUTOR QUANTITY', @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITE( ' ----------------------------------', @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITEFOR( LINK1( I, J) | XIJ( I, J) #GT# 0:8*' ', PLANT( I), 8*' ',DISTRIBUTOR( J), 8*' ', @FORMAT( XIJ( I, J), '8.0f'), @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITE( ' -----------------------------------', @NEWLINE( 2));
@TEXT('OUT1.TXT') = @WRITE( ' DISTRIBUTOR RETAILER QUANTITY', @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITE( ' ----------------------------------', @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITEFOR( LINK2( J,K) | XJK( J,K) #GT# 0:8*' ', DISTRIBUTOR( J), 8*' ', RETAILER( K), 8*' ', @FORMAT( XJK( J,K), '8.0f'), @NEWLINE( 1));
@TEXT('OUT1.TXT') = @WRITE( ' ----------------------------------', @NEWLINE( 1));
ENDDATA
[TCOST] MIN = FlowCost + OpeningCost ;
FixedCost = @SUM(LINK1(I,J):FIJ(I,J)*YIJ(I,J)) + @SUM(LINK2(J,K):FJK(J,K)*YJK(J,K)) ;
FlowCost = @SUM(LINK1(I,J):CIJ(I,J)*XIJ(I,J)) + @SUM(LINK2(J,K):CJK(J,K)*XJK(J,K)) ;;
OpeningCost = @SUM(DISTRIBUTOR(J):OPINNINGCOST(J)*U(J));
@FOR(PLANT(I): @SUM(DISTRIBUTOR(J):XIJ(I,J))< PLANTCAPACITY(I));
@FOR(DISTRIBUTOR(J):@SUM(RETAILER(K):XJK(J,K))< = DISTRIBUTORCAPACITY(J)*U(J));
@FOR(RETAILER(K):@SUM(DISTRIBUTOR(J):XJK(J,K))= DEMAND(K));
@FOR(DISTRIBUTOR(J):@SUM(RETAILER(K):DEMAND(K))= DISTRIBUTORCAPACITY(J));
! DC balance constraints;
@FOR(DISTRIBUTOR(J):@SUM(PLANT(I):XIJ(I,J)) = @SUM(RETAILER(K):XJK(J,K)));
@FOR(LINK1:XIJ> 0);
@FOR(LINK2:XJK> 0);
@FOR(LINK1:YIJ = @IF(XIJ#GT#0,1,0));
@FOR(LINK2:YJK = @IF(XJK#GT#0,1,0));
@FOR(DISTRIBUTOR:@BIN(U));
!TOTAL COST OUTPUT;
CALC:
@SOLVE();
@TEXT('CostandTime_2-5-10-Z2-Obj.TXT', 'a') = @WRITE('PDR_2-5-10_1.TXT' ,6*' ', OpeningCost,6*' ', FixedCost ,6*' ', FlowCost ,6*' ',FixedCost + TCOST, 6*' ','CPU = ',6*' ',@Time(), @NEWLINE( 1));
ENDCALC
END
ALTER ALL '1.txt'3_%10-%-50.txt'
GO
ALTER ALL '3_%10-%-50.txt'3_%10-%-40.txt'
GO
ALTER ALL '3_%10-%-40.txt'3_%10-%-30.txt'
GO
ALTER ALL '3_%10-%-30.txt'3_%10-%-20.txt'
GO
…