Topic
  • 5 replies
  • Latest Post - ‏2012-10-26T08:14:42Z by rdumeur
arguen
arguen
23 Posts

Pinned topic Errors in the constraint -

‏2012-09-27T07:12:27Z |
Hi All,
I am new to OPL and try to code a paper algorithm's. (full paper available on: http://www.springerlink.com/content/tg30x2k21828v835/
I also attached only 2 related pages of the paper )

I coded the 1st constraint (which is on the second page) and OPL didn't gave a problem while coding; but it is giving error while running.

My whole code is the following:
(My current objective is a dummy function just to run the code)


tuple V_tuple 
{ key string id;
// unique vessel id 

int Wc;      
// capacity of a tank of vessel v 

int w;      
// W^mx_v: number of cargo tanks 
} 
{V_tuple
} V_info =...; 
//int W[v in V] =...; //Set of cargo tanks on each ship   
{string
} V = 
{id| <id, Wc, w> in V_info
}; 
// Set of vessels   tuple Arc_vpdt_tuple 
{ string v;   
// v: vessel string p;  
// NP_v: pick-up port, i string d; 
// ND_v: delivery port, j 

int t;   
// T_vpd: sailing time on arc ij 
} 
{Arc_vpdt_tuple
} Arc_vpdt =...;  
// Arc Info: Vessel's available arcs (only P to D) and travel time for each vessel  
{Arc_vpdt_tuple
} Arc_vijt =...;  
// Arc Info: Vessel's available arcs(both way, i to j) and travel time for each     tuple Arc_vpd_tuple 
{ string v;   
// v: vessel string p;  
// NP_v: pick-up port, i string d; 
// ND_v: delivery port, j 
} 
{Arc_vpd_tuple
} Arc_vpd=
{<a.v,a.p,a.d>| a in Arc_vpdt
}; 
{Arc_vpd_tuple
} Arc_vij=
{<a.v,a.p,a.d>| a in Arc_vijt
};   
{string
} NP_v[v in V] = 
{p| <v, p, d, t> in Arc_vpdt
}; 
//, v in V}; Set of pick-up ports for vessel v 
{string
} ND_v[v in V] = 
{d| <v, p, d, t> in Arc_vpdt
};
// Set of delivery ports for vessel v 
{string
} NPD_v[v in V]= NP_v[v] union ND_v[v];       
// Set of all ports for vessel v   
{string
} NP = 
{p| <v, p, d, t> in Arc_vpdt
};  
// Set of pick-up ports 
{string
} ND = 
{d| <v, p, d, t> in Arc_vpdt
}; 
// Set of delivery ports  
//{string} NAll = NP union ND; // Set of ports   

int Tijv[Arc_vij] = [ <a.v, a.p, a.d>:a.t | a in Arc_vijt]; 
//Assigning tr. times to arcs   
/*tuple ArcPD_tuple { string p;  // NP_v: pick-up port, i string d; // ND_v: delivery port, j } {ArcPD_tuple} Arc_pd[v in V] = {<p,d> |<v, p, d, t> in Arc_vpdt}; //, v in V}; Set of Arcs for vessel v */   

int T_mx =...; range T= 1..T_mx; 

int TW =...; 
//Max waiting time at a port   dvar 

boolean x[Arc_vij][T]; 
//  dvar 

boolean z[Arc_vij][T]; 
//    minimize sum( a in Arc_vij, t in T ) x[a][t] * Tijv[a]; subject to 
{ forall( v in V, j in NPD_v[v],  t in T ) sum (i in NPD_v[v] ) x[<v,j,i>][t] - sum (i in NPD_v[v]) x[<v,i,j>][t-Tijv[<v,i,j>]] ==0; 
}


and my .dat file is the following:


T_mx = 36;
//range T= 1..T_mx; TW = 3;  
//Max waiting time at a port   
// V_info | V_tuple { id; Wc; w; } V_info = 
{ <VA, 2, 10> <VB, 3, 12> <VC, 1, 25> 
};   
// Arc_vpdt | ArcVPDT_tuple {v,p,d,t} // Arc Info: Available arcs and travel time for each vessel    Arc_vpdt = 
{ <VA, PA, DA, 2> <VA, PA, DB, 3> <VA, PA, DC, 4> <VA, PB, DB, 3> <VA, PB, DC, 4> <VB, PA, DA, 4> <VB, PA, DB, 6> <VB, PA, DC, 8> <VB, PB, DA, 4> <VB, PB, DB, 6> <VB, PB, DC, 8> <VC, PA, DB, 5> <VC, PA, DC, 5> <VC, PB, DB, 6> <VC, PB, DC, 6> 
};     Arc_vijt = 
{ <VA, PA, DA, 2> <VA, PA, DB, 3> <VA, PA, DC, 4> <VA, PB, DB, 3> <VA, PB, DC, 4> <VB, PA, DA, 4> <VB, PA, DB, 6> <VB, PA, DC, 8> <VB, PB, DA, 4> <VB, PB, DB, 6> <VB, PB, DC, 8> <VC, PA, DB, 5> <VC, PA, DC, 5> <VC, PB, DB, 6> <VC, PB, DC, 6> <VA, PA, DA, 2> <VA, DB, PA, 3> <VA, DC, PA, 4> <VA, DB, PB, 3> <VA, DC, PB, 4> <VB, DA, PA, 4> <VB, DB, PA, 6> <VB, DC, PA, 8> <VB, DA, PB, 4> <VB, DB, PB, 6> <VB, DC, PB, 8> <VC, DB, PA, 5> <VC, DC, PA, 5> <VC, DB, PB, 6> <VC, DC, PB, 6> 
};


Any suggestion/correction would be very much appreciated. Thank you for your time in advance.
Updated on 2012-10-26T08:14:42Z at 2012-10-26T08:14:42Z by rdumeur
  • arguen
    arguen
    23 Posts

    Re: Errors in the constraint -

    ‏2012-09-27T07:15:08Z  
    I attached pdf file again since I couldn't see in the first post.
  • AlexFleischer
    AlexFleischer
    77 Posts

    Re: Errors in the constraint -

    ‏2012-10-01T08:44:20Z  
    • arguen
    • ‏2012-09-27T07:15:08Z
    I attached pdf file again since I couldn't see in the first post.
    Hi

    you have many out of bounds.

    I protected your expression to get rid of them in

    
    forall( v in V, j in NPD_v[v],  t in T ) sum (i in NPD_v[v]:<v,j,i> in Arc_vij ) x[<v,j,i>][t] - sum (i in NPD_v[v]:((<v,i,j> in Arc_vij) && ((t-Tijv[<v,i,j>]) in T ) ) ) x[<v,i,j>][t-Tijv[<v,i,j>]] ==0;
    


    but you should work on your model to make sure that the index you use in your arrays are valid.

    Regards
  • arguen
    arguen
    23 Posts

    Re: Errors in the constraint -

    ‏2012-10-07T08:41:20Z  
    Thank you for you reply. It solved my problem
  • SystemAdmin
    SystemAdmin
    623 Posts

    Re: Errors in the constraint -

    ‏2012-10-26T00:28:49Z  
    Hi arguen,
    I am also new to OPL and try to code a cplex's algorithm.,but I do not have some related examples,errors will always exist,can you give me some tutorial about cplex.thang you very much.
  • rdumeur
    rdumeur
    63 Posts

    Re: Errors in the constraint -

    ‏2012-10-26T08:14:42Z  
    Hi arguen,
    I am also new to OPL and try to code a cplex's algorithm.,but I do not have some related examples,errors will always exist,can you give me some tutorial about cplex.thang you very much.
    Dear Arguen,

    Google is your friend:

    https://www.google.com/search?q=Optimization+modeling+with+IBM+ILOG+OPL&rlz=1C1GPEA_enFR314GB384&oq=Optimization+modeling+with+IBM+ILOG+OPL&sugexp=chrome,mod=0&sourceid=chrome&ie=UTF-8

    Otherwise the product documentation itself will provide examples for many language constructs.
    Cheers,

    Renaud