• 1 reply
  • Latest Post - ‏2012-11-14T16:49:12Z by SystemAdmin
754 Posts

Pinned topic Error: Label constraint

‏2012-11-14T16:01:41Z |
Hello together,

I don´t understand why I get the error for my constraint: " Name ``Name of constraint´´ already defined".

The modell looks like:

//Sets used as indexes
int lastClient=...;
range C= 1..lastClient;

int L[C] =...; //lot size
int P[C] = ...; //price per lot
int T[C]=...; //transportation cost
int B=...; //maximal capacity

//Decision Variable
dvar float+ X[C];

dexpr float income = sum (c in C) X[c]*(P[c]-T[c]*L[c]);
//Objective Function

maximize income;

constraint ctCapacity;

subject to {

ctCapacity: sum(c in C) X[c]*L[c]<= B; --> here I get the error like I explained above.


I hope you can help me, thank you.

Updated on 2012-11-14T16:49:12Z at 2012-11-14T16:49:12Z by SystemAdmin
  • SystemAdmin
    754 Posts

    Re: Error: Label constraint

    According to the reference documentation you can use the 'constraint' keyword only with indexed labels. The following is an extended version of the code snippet in the reference documentation that works without trouble:
    range Products = 1..2; range Cities = 1..3;   dvar float+ x[Products][Cities];   constraint ct[Products][Cities];   minimize sum(p in Products,c in Cities) x[p][c];   subject to 
    { forall(p in Products,c in Cities) 
    { ct[p][c]: x[p][c] >= 0;