Results 1 to 1 of 1

Thread: [Lingo] Error Code 188

  1. #1
    New Member
    Join Date
    Oct 12
    Posts
    1

    [Lingo] Error Code 188

    I've just gotten an assignment to improve a Lingo model. The model is about dynamic optimization when producing. My assignment is to improve the model so it's still solvable when demand is greater then producing ability. However, I encounter some problem.
    The first is when I try to increase period, the model report out of range error which is some problem with the excel file. I'm working on this right now.
    The second is when I try to add some branching to the model to solve the assignment, Lingo reports error code 188 which is saying I'm try to redefine defined set. Please help me fix it.

    Here is the old model:
    Code:
    SETS:
    ky: cpcd,cpbd1,cplk,mucsx1,kysx,dt,lkdk,lkck,mucsx2,cpbd2,nlsx2,nlk,nlsx1;
    luukho:chay;
    ENDSETS 
    Min=@Sum(ky(I): cpcd(I)*kysx(I)+cpbd1(I)*mucsx1(I)+cplk(I)*lkck(I)+mucsx2(I)*cpbd2(I));
    tongcp=@Sum(ky(I): cpcd(I)*kysx(I)+cpbd1(I)*mucsx1(I)+cplk(I)*lkck(I)+mucsx2(I)*cpbd2(I));
    @For(ky:@Bin(kysx));
    lkdk(1)=dau;lkck(soky)=cuoi;
    @for(ky(I):lkck(I)=lkdk(I)+mucsx1(I)+mucsx2(I)-dt(I));
    @for(luukho(J):lkdk(chay(J))=lkck(chay(J)-1));
    @for(ky(I):@gin(mucsx1(I)));
    @for(ky(I):mucsx1(I)<=nlsx1(I)*kysx);
    @for(ky(I):lkck(I)<=nlk(I));
    @for(ky(I):lkck(I)>=0);
    @for(ky(I):mucsx2(I)<=nlsx2(I)*kysx);
    
    DATA:
    ky,dt,cpbd1,cpcd,cplk,dau,cuoi,soky,chay,nlsx2,cpbd2,nlk,nlsx1 = @OLE ('IO.xlsx');
    @OLE ('IO.xlsx','mucsx1','lkck','lkdk','tongcp','mucsx2')= mucsx1,lkck,lkdk,tongcp,mucsx2;
    ENDDATA
    and here is my improved model
    Code:
    SETS:
    ky: cpcd,cpbd1,cplk,mucsx1,kysx,dt,lkdk,lkck,mucsx2,cpbd2,nlsx2,nlk,nlsx1;
    luukho:chay;
    ENDSETS 
    Min=@Sum(ky(I): cpcd(I)*kysx(I)+cpbd1(I)*mucsx1(I)+cplk(I)*lkck(I)+mucsx2(I)*cpbd2(I));
    tongcp=@Sum(ky(I): cpcd(I)*kysx(I)+cpbd1(I)*mucsx1(I)+cplk(I)*lkck(I)+mucsx2(I)*cpbd2(I));
    @For(ky:@Bin(kysx));
    lkdk(1)=dau;lkck(soky)=cuoi;
    @for(ky(I):lkck(I)=lkdk(I)+mucsx1(I)+mucsx2(I)-dt(I));
    @for(luukho(J):lkdk(chay(J))=lkck(chay(J)-1));
    @for(ky(I):@gin(mucsx1(I)));
    @for(ky(I):mucsx1(I)<=nlsx1(I)*kysx);
    @for(ky(I):lkck(I)<=nlk(I));
    !@sum(ky(I):sx(I))+lkdk(1)=@sum(ky(I):dt(I))+lkck(cuoi);
    @for(ky(I):lkck(I)>=0);
    @for(ky(I):mucsx2(I)<=nlsx2(I)*kysx);
    calc:
    @ifc(@sum(ky(I):nlsx1(I)+nlsx2(I))#LT#@sum(ky(I):dt(I)):
    	@for(ky(I):
    		@ifc((lkdk(I)+nlsx1(I)+nlsx2(I))#LE#(dt(I)+nlk(I)):
    			mucsx1(I)=nlsx1(I);
    			mucsx2(I)=nlsx2(I);
    		@else
    			@ifc(cpbd1(I)#GE#cpbd2(I):
    			mucsx2(I)=@if((nlsx2(I)+lkdk(I))#LE#(dt(I)+nlk(I)),nlsx2(I),nlk(I)+dt(I)-lkdk(I));
    			mucsx1(I)=@if((nlsx2(I)+lkdk(I))#LE#(dt(I)+nlk(I)),nlk(I)+dt(I)-lkdk(I)-nlsx2(I),0);
    			@else
    			mucsx1(I)=@if((nlsx1(I)+lkdk(I))#LE#(dt(I)+nlk(I)),nlsx1(I),nlk(I)+dt(I)-lkdk(I));
    			mucsx2(I)=@if((nlsx1(I)+lkdk(I))#LE#(dt(I)+nlk(I)),nlk(I)+dt(I)-lkdk(I)-nlsx1(I),0););
    		);
    	);
    );
    endcalc
    
    DATA:
    ky,dt,cpbd1,cpcd,cplk,dau, cuoi,soky,ch,nlsx2,cpbd2,nlk,nlsx1 = @OLE ('IO.xlsx');
    @OLE ('IO.xlsx','mucsx1','lkck','lkdk','tongcp','mucsx2')= mucsx1,lkck,lkdk,tongcp,mucsx2;
    ENDDATA
    It's basically the same, just adding calc section.
    And here is the Excel file
    http://www.mediafire.com/view/?yq48l4h9b12yh51
    Last edited by Hack; Oct 3rd, 2012 at 10:51 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •