Topic
• 8 replies
• Latest Post - ‏2013-07-18T15:57:41Z by AlexFleischer
prasenjit mandal
5 Posts

# Pinned topic Constraint labeling in multiple summation

‏2013-07-17T08:48:49Z |

I stuck to model a constraint using OPL.

The constraint is like

sum (t = 1 to t_p) x_(pt)  >= (1 - y_(p,t_p) )* D_p, forall (p in Projects, t_p in deadline_p)

where x_(kpt) and y_(p,t_p)  are binary variables and D_p, deadline_p are the parameters.

I cant model this constraint using OPL.

• AlexFleischer
3283 Posts

#### Re: Constraint labeling in multiple summation

‏2013-07-17T11:33:10Z

Hi,

have you tried

forall (p in Projects, t_p in deadline_p) sum (t in  1 .. t_p) x_[pt]  >= (1 - y_[p,t_p] )* D_p ;

regards

• prasenjit mandal
5 Posts

#### Re: Constraint labeling in multiple summation

‏2013-07-17T18:06:12Z

Hi,

have you tried

forall (p in Projects, t_p in deadline_p) sum (t in  1 .. t_p) x_[pt]  >= (1 - y_[p,t_p] )* D_p ;

regards

Yes, i have tried that. But OPL is showing some error, like, "Constraint labeling not supported for dimensions with variable sizeuse named constraints instead". I tried other ways, even every way is showing some errors.

It's like

****************************************

code blocks: Sample code in C\C++

******************************************

for (p in Projects)

{

for (t_p= dealinep; t_p <T+1; t_p++)

{

for (t = 1; t< t_p, t++)

{

sum =sum + xp,t ;

}

sum >= (1 - yp,t_p)*D(p);

}

}

***************************************************

How can I write these constraints in OPL? I searched even OLP documentation, but dint get any clue.

• AlexFleischer
3283 Posts

#### Re: Constraint labeling in multiple summation

‏2013-07-18T07:35:05Z

Hi,

"Constraint labeling not supported for dimensions with variable sizeuse named constraints instead"

means you labeled your constraint, ie you wrote something like

forall (p in Projects, t_p in deadline_p) ctName: sum (t in  1 .. t_p) x_[pt]  >= (1 - y_[p,t_p] )* D_p ;

can you try to remove that label ?

Do not hesitate to attach your model.

regards

Alex Fleischer

• prasenjit mandal
5 Posts

#### Re: Constraint labeling in multiple summation

‏2013-07-18T10:14:56Z

Hi,

"Constraint labeling not supported for dimensions with variable sizeuse named constraints instead"

means you labeled your constraint, ie you wrote something like

forall (p in Projects, t_p in deadline_p) ctName: sum (t in  1 .. t_p) x_[pt]  >= (1 - y_[p,t_p] )* D_p ;

can you try to remove that label ?

Do not hesitate to attach your model.

regards

Alex Fleischer

**********************************

code block used by me

**********************************

//Escalation constrints

constName1:
sum(k in Resources, t in 1..t_p)
Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

**********************************

I had already tried this code, what you have suggested, but it was giving the following error.

"Constraint labeling not supported for dimensions with variable size, use named constraints instead."

But, I follow what you have tried to suggest (perhaps) - without <constraint_name>...

**********************************

//Escalation constrints

sum(k in Resources, t in 1..t_p)
Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

**********************************

In this case it's running fine.

***

Also, do you have any idea how to use named constraint!!!! Also i tried to use following block of codes after going through the documentation.

**********************************

code block 2

**********************************

//declaration

constraint constName1[Projects][Periods];

//Escalation constrints

constName1[p][t_p]:
sum(k in Resources, t in 1..t_p)
Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

**********************************

Is it OK also?

• prasenjit mandal
5 Posts

#### Re: Constraint labeling in multiple summation

‏2013-07-18T10:15:33Z
**********************************

code block used by me

**********************************

//Escalation constrints

constName1:
sum(k in Resources, t in 1..t_p)
Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

**********************************

I had already tried this code, what you have suggested, but it was giving the following error.

"Constraint labeling not supported for dimensions with variable size, use named constraints instead."

But, I follow what you have tried to suggest (perhaps) - without <constraint_name>...

**********************************

//Escalation constrints

sum(k in Resources, t in 1..t_p)
Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

**********************************

In this case it's running fine.

***

Also, do you have any idea how to use named constraint!!!! Also i tried to use following block of codes after going through the documentation.

**********************************

code block 2

**********************************

//declaration

constraint constName1[Projects][Periods];

//Escalation constrints

constName1[p][t_p]:
sum(k in Resources, t in 1..t_p)
Assign[k][p][t] >= (1 - Escalation[p][t_p])*Demand[p];

**********************************

Is it OK also?

Thanks a lot Alex...

• AlexFleischer
3283 Posts

#### Re: Constraint labeling in multiple summation

‏2013-07-18T13:09:03Z

Thanks a lot Alex...

Hi,

in the doc you should have a look at

## Labels and a variable size indexer

Constraint labels with a variable size indexer are not allowed. For example, this model generates an error message.

``````
tuple RangeTuple
{     int i;     int j;     string k; };
{RangeTuple} RT = {<1, 2, "bla">};
minimize 1;
subject to {
forall(<p1, p2, p3> in RT)
forall(i in p1..p2)
rangeLabel:
1 == 1;
}```
```

``````
tuple RangeTuple{    int i;    int j;    string k;};
{RangeTuple} RT = {<1, 2, "bla">};
{int} s={1,2};
constraint rangeLabel[RT][s];
minimize 1;
subject to{
forall(<p1, p2, p3> in RT)
forall(i in p1..p2)
rangeLabel[<p1, p2, p3>,i]:
1 == 1;
}```
```

`regards`

Updated on 2013-07-18T13:10:47Z at 2013-07-18T13:10:47Z by AlexFleischer
• prasenjit mandal
5 Posts

#### Re: Constraint labeling in multiple summation

‏2013-07-18T15:44:11Z

Hi,

in the doc you should have a look at

## Labels and a variable size indexer

Constraint labels with a variable size indexer are not allowed. For example, this model generates an error message.

<pre class="pre codeblock" dir="ltr">``` tuple RangeTuple { int i; int j; string k; }; {RangeTuple} RT = {<1, 2, "bla">}; minimize 1; subject to { forall(<p1, p2, p3> in RT) forall(i in p1..p2) rangeLabel: 1 == 1; }``` </pre>

<pre class="pre codeblock" dir="ltr">``` tuple RangeTuple{ int i; int j; string k;}; {RangeTuple} RT = {<1, 2, "bla">}; {int} s={1,2}; constraint rangeLabel[RT][s]; minimize 1; subject to{ forall(<p1, p2, p3> in RT) forall(i in p1..p2) rangeLabel[<p1, p2, p3>,i]: 1 == 1; }``` </pre>

`regards`

So, the last one i suggested is fine!!!! is it???

• AlexFleischer
3283 Posts

#### Re: Constraint labeling in multiple summation

‏2013-07-18T15:57:41Z