Topic
• 9 replies
• Latest Post - ‏2014-01-02T20:21:59Z by MarcosQ
MarcosQ
7 Posts

# Pinned topic Error operator forall not available

‏2013-12-11T21:45:32Z |

Hi everyone!

As many new users here, I'm having a hard time with CPLEX, and need help in some aspects of the language. For instance, in the expression:

forall (a in days)
sum (b in dimension, c in dimension) offset[b][c]*z[a][b][c];

I got an error about the operator forall not available for dexpr int. What does It means?

Any help is appreciated!

• AlexFleischer
3204 Posts

#### Re: Error operator forall not available

‏2013-12-12T10:57:41Z

Hi,

can you attach your model ?

regards

• MarcosQ
7 Posts

#### Re: Error operator forall not available

‏2013-12-12T23:59:29Z

Hi,

can you attach your model ?

regards

Hi Alex,

sure I can, see below:

And my question was only about the first part of the expression (the first double sum). So far, my code for the entire expression is:

forall (a in days)
sum (b in dimension c in dimension) (offset[b][c] * z[a][b][c]) +
sum (d in v:d!=0, e in days) (optime[d][a-e] * x[a][e][d]) <= shift;

where:

int horiz=...;

int wells = ...;
int shift = ...;
int total = wells+1;

range days = 1..horiz;
range lines = 1..wells;
range columns = 1..horiz;
range dimension = 1..total;

range v = 0..wells;
dvar boolean x[days][days][v];
dvar boolean z[days][dimension][dimension];

int offset[dimension][dimension]=...;
int optime[lines][columns]=...;

Regards,

Marcos

• AlexFleischer
3204 Posts

#### Re: Error operator forall not available

‏2013-12-13T17:19:17Z
• MarcosQ
• ‏2013-12-12T23:59:29Z

Hi Alex,

sure I can, see below:

And my question was only about the first part of the expression (the first double sum). So far, my code for the entire expression is:

forall (a in days)
sum (b in dimension c in dimension) (offset[b][c] * z[a][b][c]) +
sum (d in v:d!=0, e in days) (optime[d][a-e] * x[a][e][d]) <= shift;

where:

int horiz=...;

int wells = ...;
int shift = ...;
int total = wells+1;

range days = 1..horiz;
range lines = 1..wells;
range columns = 1..horiz;
range dimension = 1..total;

range v = 0..wells;
dvar boolean x[days][days][v];
dvar boolean z[days][dimension][dimension];

int offset[dimension][dimension]=...;
int optime[lines][columns]=...;

Regards,

Marcos

Hi

int horiz= 5;
int wells = 5;
int shift = 5;
int total = wells+1;

range days = 1..horiz;
range lines = 1..wells;
range columns = 1..horiz;
range dimension = 1..total;

range v = 0..wells;
dvar boolean x[days][days][v];
dvar boolean z[days][dimension][dimension];

int offset[dimension][dimension];
int optime[lines][columns];

subject to
{
forall (a in days)
sum (b in dimension, c in dimension) (offset[b][c] * z[a][b][c]) +
sum (d in v:d!=0, e in days: (a-e) in columns) (optime[d][a-e] * x[a][e][d]) <= shift;
}

works fine

• MarcosQ
7 Posts

#### Re: Error operator forall not available

‏2013-12-17T18:53:00Z

Hi

int horiz= 5;
int wells = 5;
int shift = 5;
int total = wells+1;

range days = 1..horiz;
range lines = 1..wells;
range columns = 1..horiz;
range dimension = 1..total;

range v = 0..wells;
dvar boolean x[days][days][v];
dvar boolean z[days][dimension][dimension];

int offset[dimension][dimension];
int optime[lines][columns];

subject to
{
forall (a in days)
sum (b in dimension, c in dimension) (offset[b][c] * z[a][b][c]) +
sum (d in v:d!=0, e in days: (a-e) in columns) (optime[d][a-e] * x[a][e][d]) <= shift;
}

works fine

Hi Alex,

with the inclusion of ": (a-e) in columns" no more errors are showed, however, I got a 'no answer' message. I'll check what's going on and post here. Thanks a lot for your help!

Regards,

Marcos

• MarcosQ
7 Posts

#### Re: Error operator forall not available

‏2013-12-24T17:52:22Z

Thanks to Alex's help, I solve a few problems, but the maximize expression isn't working yet. The problem's objective is:

which I wrote:

maximize

sum (z in P) sum(a in P:a<=z) sum(b in V) x[z][a][b] * vol[b][z-a];

I'm sending the whole code for a better comprehension:

int umps = ...;
int wells = ...;
int horiz = ...;
int turn = ...;
int total = wells+1;

range P = 1..horiz;
range V = 1..wells;

range days = 1..horiz;
range lines = 1..wells;
range columns = 1..horiz;
range dimension = 1..total;

range k = 1..umps;
range v = 1..wells+1;

int distance[dimension][dimension]=...;
int optime[lines][columns]=...;
float vol[lines][columns]=...;

dvar boolean x[days][days][v];
dvar boolean y[days][v][v];
dvar boolean z[days][dimension][dimension];

maximize
sum (z in P) sum(a in P:a<=z) sum(b in V) x[z][a][b] * vol[b][z-a];

subject to {

forall (a in days, b in v)
sum (c in v) y[a][b][c] <= 1;

forall (a in days, b in v)
sum (c in v) y[a][c][b] <= 1;

forall (a in days)
sum (b in v:b!=0) y[a][0][b] == 1;

forall (a in days)
sum (b in v:b!=0) y[a][b][0] == 1;

forall (a in days, b in v)
sum (c in v) y[a][b][c] - sum (c in v) y[a][c][b] == 0;

forall (a in days)
sum (b in v, c in v) y[a][b][c] <= umps - 1;

forall (a in days)
sum (b in dimension, c in dimension) (distance[b][c]*z[a][b][c]) +
sum (d in v:d!=0, e in days:(a-e) in columns) (optime[d][a-e]*x[a][e][d]) <= turn;

forall (a in days, b in v)
sum (c in v) x[a][a][c] - sum (c in v)y[a][b][c] == 0;
}

And one .dat file:

umps=1;
wells=16;
horiz=30;
turn=960;

vol=[[9.65, 2.70, 4.65, 6.05, 7.06, 7.79, 8.31, 8.68, 8.96, 9.15, 9.29, 9.39, 9.47, 9.52, 9.55, 9.58, 9.60, 9.61, 9.62, 9.64, 9.64, 9.64, 9.65, 9.65, 9.65, 9.65, 9.65, 9.65, 9.65, 9.65],
[6.68, 3.12, 4.78, 5.67, 6.14, 6.39, 6.53, 6.60, 6.64, 6.66, 6.67, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68],
[7.87, 2.51, 4.22, 5.37, 6.17, 6.71, 7.08, 7.34, 7.50, 7.62, 7.70, 7.75, 7.79, 7.81, 7.83, 7.84, 7.85, 7.85, 7.85, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87],
[4.40, 1.62, 2.65, 3.30, 3.70, 3.96, 4.12, 4.23, 4.29, 4.34, 4.36, 4.38, 4.39, 4.39, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40],
[10.26, 3.78, 6.17, 7.68, 8.63, 9.23, 9.61, 9.85, 10.00, 10.09, 10.15, 10.19, 10.22, 10.23, 10.24, 10.25, 10.25, 10.25, 10.25, 10.25, 10.25, 10.26, 10.26, 10.26, 10.26, 10.26, 10.26, 10.26, 10.26, 10.26],
[9.91, 2.78, 4.78, 6.21, 7.25, 7.99, 8.53, 8.91, 9.20, 9.39, 9.54, 9.65, 9.72, 9.77, 9.82, 9.84, 9.86, 9.87, 9.88, 9.89, 9.90, 9.90, 9.90, 9.90, 9.91, 9.91, 9.91, 9.91, 9.91, 9.91],
[5.10, 1.27, 2.24, 2.95, 3.49, 3.89, 4.20, 4.42, 4.59, 4.72, 4.81, 4.89, 4.94, 4.98, 5.01, 5.03, 5.05, 5.07, 5.08, 5.08, 5.09, 5.09, 5.09, 5.10, 5.10, 5.10, 5.10, 5.10, 5.10, 5.10],
[9.48, 4.14, 6.49, 7.79, 8.53, 8.95, 9.18, 9.32, 9.38, 9.42, 9.46, 9.47, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48],
[9.71, 2.19, 3.89, 5.20, 6.22, 7.01, 7.62, 8.09, 8.46, 8.74, 8.96, 9.13, 9.26, 9.36, 9.44, 9.50, 9.55, 9.58, 9.61, 9.64, 9.66, 9.67, 9.68, 9.69, 9.69, 9.70, 9.70, 9.70, 9.70, 9.71],
[4.55, 1.03, 1.82, 2.44, 2.91, 3.29, 3.57, 3.79, 3.96, 4.09, 4.20, 4.27, 4.34, 4.39, 4.42, 4.45, 4.47, 4.49, 4.50, 4.52, 4.53, 4.53, 4.54, 4.54, 4.54, 4.54, 4.55, 4.55, 4.55, 4.55],
[10.65, 2.66, 4.66, 6.16, 7.28, 8.13, 8.77, 9.23, 9.59, 9.86, 10.06, 10.21, 10.31, 10.40, 10.46, 10.52, 10.55, 10.58, 10.60, 10.61, 10.62, 10.63, 10.63, 10.64, 10.64, 10.65, 10.65, 10.65, 10.65, 10.65],
[4.73, 1.51, 2.53, 3.23, 3.71, 4.04, 4.26, 4.41, 4.50, 4.58, 4.63, 4.66, 4.69, 4.70, 4.71, 4.72, 4.72, 4.72, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73],
[5.28, 1.69, 2.83, 3.60, 4.14, 4.50, 4.75, 4.92, 5.03, 5.11, 5.16, 5.19, 5.23, 5.24, 5.25, 5.26, 5.27, 5.27, 5.27, 5.27, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28],
[9.52, 3.71, 5.97, 7.36, 8.19, 8.71, 9.03, 9.22, 9.34, 9.40, 9.46, 9.48, 9.50, 9.51, 9.51, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52],
[4.60, 1.04, 1.84, 2.46, 2.95, 3.32, 3.60, 3.83, 4.01, 4.13, 4.24, 4.32, 4.39, 4.43, 4.47, 4.49, 4.52, 4.54, 4.55, 4.56, 4.57, 4.58, 4.58, 4.59, 4.59, 4.59, 4.59, 4.59, 4.59, 4.59],
[4.82, 1.36, 2.32, 3.02, 3.53, 3.89, 4.16, 4.35, 4.47, 4.57, 4.64, 4.70, 4.73, 4.76, 4.78, 4.79, 4.80, 4.80, 4.81, 4.81, 4.81, 4.82, 4.82, 4.82, 4.82, 4.82, 4.82, 4.82, 4.82, 4.82]];

optime=[[211, 63, 105, 134, 156, 171, 182, 190, 196, 200, 203, 205, 207, 208, 209, 209, 210, 210, 210, 210, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211],
[148, 72, 107, 126, 136, 142, 145, 146, 147, 147, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148],
[173, 59, 95, 120, 137, 148, 156, 162, 165, 168, 169, 171, 171, 172, 172, 172, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173],
[99, 40, 62, 76, 85, 90, 94, 96, 97, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99],
[224, 86, 137, 169, 189, 202, 210, 215, 218, 220, 222, 222, 223, 223, 223, 223, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224],
[216, 65, 107, 138, 160, 176, 187, 195, 201, 205, 209, 211, 212, 213, 214, 215, 215, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216],
[114, 33, 53, 69, 80, 89, 95, 100, 103, 106, 108, 110, 111, 112, 112, 113, 113, 113, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114],
[207, 94, 144, 171, 187, 196, 201, 204, 205, 206, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207],
[212, 53, 89, 116, 138, 155, 168, 178, 186, 192, 196, 200, 203, 205, 206, 208, 209, 209, 210, 211, 211, 211, 211, 212, 212, 212, 212, 212, 212, 212],
[103, 28, 45, 58, 68, 76, 82, 86, 90, 93, 95, 97, 98, 99, 100, 100, 101, 101, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102],
[232, 63, 105, 137, 161, 179, 192, 202, 210, 215, 219, 223, 225, 227, 228, 229, 230, 230, 231, 231, 231, 232, 232, 232, 232, 232, 232, 232, 232, 232],
[106, 38, 60, 75, 85, 92, 96, 100, 102, 103, 104, 105, 105, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106],
[118, 42, 66, 83, 94, 102, 107, 110, 113, 114, 116, 116, 117, 117, 117, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118],
[208, 85, 133, 162, 180, 191, 198, 202, 204, 206, 207, 207, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208],
[104, 28, 45, 58, 69, 76, 83, 87, 91, 94, 96, 98, 99, 100, 101, 101, 102, 102, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 104, 104],
[108, 35, 55, 70, 81, 89, 94, 98, 101, 103, 105, 106, 106, 107, 107, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108]];

distance=[[0, 11, 19, 54, 54, 31, 31, 19, 19, 11, 11, 1, 11, 19, 31, 31, 19],
[11, 0, 11, 54, 54, 31, 31, 19, 19, 1, 1, 11, 1, 11, 31, 31, 19],
[19, 11, 0, 66, 66, 42, 42, 31, 31, 11, 11, 19, 11, 1, 42, 42, 31],
[54, 54, 66, 0, 1, 23, 23, 46, 46, 54, 54, 54, 54, 66, 23, 23, 46],
[54, 54, 66, 1, 0, 23, 23, 46, 46, 54, 54, 54, 54, 66, 23, 23, 46],
[31, 31, 42, 23, 23, 0, 1, 31, 31, 31, 31, 31, 31, 42, 1, 1, 31],
[31, 31, 42, 23, 23, 1, 0, 31, 31, 31, 31, 31, 31, 42, 1, 1, 31],
[19, 19, 31, 46, 46, 31, 31, 0, 1, 19, 19, 19, 19, 31, 31, 31, 1],
[19, 19, 31, 46, 46, 31, 31, 1, 0, 19, 19, 19, 19, 31, 31, 31, 1],
[11, 1, 11, 54, 54, 31, 31, 19, 19, 0, 1, 11, 1, 11, 31, 31, 19],
[11, 1, 11, 54, 54, 31, 31, 19, 19, 1, 0, 11, 1, 11, 31, 31, 19],
[1, 11, 19, 54, 54, 31, 31, 19, 19, 11, 11, 0, 11, 19, 31, 31, 19],
[11, 1, 11, 54, 54, 31, 31, 19, 19, 1, 1, 11, 0, 11, 31, 31, 19],
[19, 11, 1, 66, 66, 42, 42, 31, 31, 11, 11, 19, 11, 0, 42, 42, 31],
[31, 31, 42, 23, 23, 1, 1, 31, 31, 31, 31, 31, 31, 42, 0, 1, 31],
[31, 31, 42, 23, 23, 1, 1, 31, 31, 31, 31, 31, 31, 42, 1, 0, 31],
[19, 19, 31, 46, 46, 31, 31, 1, 1, 19, 19, 19, 19, 31, 31, 31, 0]];
• AlexFleischer
3204 Posts

#### Re: Error operator forall not available

‏2013-12-25T19:21:57Z
• MarcosQ
• ‏2013-12-24T17:52:22Z

Thanks to Alex's help, I solve a few problems, but the maximize expression isn't working yet. The problem's objective is:

which I wrote:

maximize

sum (z in P) sum(a in P:a<=z) sum(b in V) x[z][a][b] * vol[b][z-a];

I'm sending the whole code for a better comprehension:

int umps = ...;
int wells = ...;
int horiz = ...;
int turn = ...;
int total = wells+1;

range P = 1..horiz;
range V = 1..wells;

range days = 1..horiz;
range lines = 1..wells;
range columns = 1..horiz;
range dimension = 1..total;

range k = 1..umps;
range v = 1..wells+1;

int distance[dimension][dimension]=...;
int optime[lines][columns]=...;
float vol[lines][columns]=...;

dvar boolean x[days][days][v];
dvar boolean y[days][v][v];
dvar boolean z[days][dimension][dimension];

maximize
sum (z in P) sum(a in P:a<=z) sum(b in V) x[z][a][b] * vol[b][z-a];

subject to {

forall (a in days, b in v)
sum (c in v) y[a][b][c] <= 1;

forall (a in days, b in v)
sum (c in v) y[a][c][b] <= 1;

forall (a in days)
sum (b in v:b!=0) y[a][0][b] == 1;

forall (a in days)
sum (b in v:b!=0) y[a][b][0] == 1;

forall (a in days, b in v)
sum (c in v) y[a][b][c] - sum (c in v) y[a][c][b] == 0;

forall (a in days)
sum (b in v, c in v) y[a][b][c] <= umps - 1;

forall (a in days)
sum (b in dimension, c in dimension) (distance[b][c]*z[a][b][c]) +
sum (d in v:d!=0, e in days:(a-e) in columns) (optime[d][a-e]*x[a][e][d]) <= turn;

forall (a in days, b in v)
sum (c in v) x[a][a][c] - sum (c in v)y[a][b][c] == 0;
}

And one .dat file:

umps=1;
wells=16;
horiz=30;
turn=960;

vol=[[9.65, 2.70, 4.65, 6.05, 7.06, 7.79, 8.31, 8.68, 8.96, 9.15, 9.29, 9.39, 9.47, 9.52, 9.55, 9.58, 9.60, 9.61, 9.62, 9.64, 9.64, 9.64, 9.65, 9.65, 9.65, 9.65, 9.65, 9.65, 9.65, 9.65],
[6.68, 3.12, 4.78, 5.67, 6.14, 6.39, 6.53, 6.60, 6.64, 6.66, 6.67, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68, 6.68],
[7.87, 2.51, 4.22, 5.37, 6.17, 6.71, 7.08, 7.34, 7.50, 7.62, 7.70, 7.75, 7.79, 7.81, 7.83, 7.84, 7.85, 7.85, 7.85, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87, 7.87],
[4.40, 1.62, 2.65, 3.30, 3.70, 3.96, 4.12, 4.23, 4.29, 4.34, 4.36, 4.38, 4.39, 4.39, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40, 4.40],
[10.26, 3.78, 6.17, 7.68, 8.63, 9.23, 9.61, 9.85, 10.00, 10.09, 10.15, 10.19, 10.22, 10.23, 10.24, 10.25, 10.25, 10.25, 10.25, 10.25, 10.25, 10.26, 10.26, 10.26, 10.26, 10.26, 10.26, 10.26, 10.26, 10.26],
[9.91, 2.78, 4.78, 6.21, 7.25, 7.99, 8.53, 8.91, 9.20, 9.39, 9.54, 9.65, 9.72, 9.77, 9.82, 9.84, 9.86, 9.87, 9.88, 9.89, 9.90, 9.90, 9.90, 9.90, 9.91, 9.91, 9.91, 9.91, 9.91, 9.91],
[5.10, 1.27, 2.24, 2.95, 3.49, 3.89, 4.20, 4.42, 4.59, 4.72, 4.81, 4.89, 4.94, 4.98, 5.01, 5.03, 5.05, 5.07, 5.08, 5.08, 5.09, 5.09, 5.09, 5.10, 5.10, 5.10, 5.10, 5.10, 5.10, 5.10],
[9.48, 4.14, 6.49, 7.79, 8.53, 8.95, 9.18, 9.32, 9.38, 9.42, 9.46, 9.47, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48, 9.48],
[9.71, 2.19, 3.89, 5.20, 6.22, 7.01, 7.62, 8.09, 8.46, 8.74, 8.96, 9.13, 9.26, 9.36, 9.44, 9.50, 9.55, 9.58, 9.61, 9.64, 9.66, 9.67, 9.68, 9.69, 9.69, 9.70, 9.70, 9.70, 9.70, 9.71],
[4.55, 1.03, 1.82, 2.44, 2.91, 3.29, 3.57, 3.79, 3.96, 4.09, 4.20, 4.27, 4.34, 4.39, 4.42, 4.45, 4.47, 4.49, 4.50, 4.52, 4.53, 4.53, 4.54, 4.54, 4.54, 4.54, 4.55, 4.55, 4.55, 4.55],
[10.65, 2.66, 4.66, 6.16, 7.28, 8.13, 8.77, 9.23, 9.59, 9.86, 10.06, 10.21, 10.31, 10.40, 10.46, 10.52, 10.55, 10.58, 10.60, 10.61, 10.62, 10.63, 10.63, 10.64, 10.64, 10.65, 10.65, 10.65, 10.65, 10.65],
[4.73, 1.51, 2.53, 3.23, 3.71, 4.04, 4.26, 4.41, 4.50, 4.58, 4.63, 4.66, 4.69, 4.70, 4.71, 4.72, 4.72, 4.72, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73, 4.73],
[5.28, 1.69, 2.83, 3.60, 4.14, 4.50, 4.75, 4.92, 5.03, 5.11, 5.16, 5.19, 5.23, 5.24, 5.25, 5.26, 5.27, 5.27, 5.27, 5.27, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28, 5.28],
[9.52, 3.71, 5.97, 7.36, 8.19, 8.71, 9.03, 9.22, 9.34, 9.40, 9.46, 9.48, 9.50, 9.51, 9.51, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52, 9.52],
[4.60, 1.04, 1.84, 2.46, 2.95, 3.32, 3.60, 3.83, 4.01, 4.13, 4.24, 4.32, 4.39, 4.43, 4.47, 4.49, 4.52, 4.54, 4.55, 4.56, 4.57, 4.58, 4.58, 4.59, 4.59, 4.59, 4.59, 4.59, 4.59, 4.59],
[4.82, 1.36, 2.32, 3.02, 3.53, 3.89, 4.16, 4.35, 4.47, 4.57, 4.64, 4.70, 4.73, 4.76, 4.78, 4.79, 4.80, 4.80, 4.81, 4.81, 4.81, 4.82, 4.82, 4.82, 4.82, 4.82, 4.82, 4.82, 4.82, 4.82]];

optime=[[211, 63, 105, 134, 156, 171, 182, 190, 196, 200, 203, 205, 207, 208, 209, 209, 210, 210, 210, 210, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211],
[148, 72, 107, 126, 136, 142, 145, 146, 147, 147, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148],
[173, 59, 95, 120, 137, 148, 156, 162, 165, 168, 169, 171, 171, 172, 172, 172, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173],
[99, 40, 62, 76, 85, 90, 94, 96, 97, 98, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99],
[224, 86, 137, 169, 189, 202, 210, 215, 218, 220, 222, 222, 223, 223, 223, 223, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224],
[216, 65, 107, 138, 160, 176, 187, 195, 201, 205, 209, 211, 212, 213, 214, 215, 215, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216],
[114, 33, 53, 69, 80, 89, 95, 100, 103, 106, 108, 110, 111, 112, 112, 113, 113, 113, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114],
[207, 94, 144, 171, 187, 196, 201, 204, 205, 206, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, 207],
[212, 53, 89, 116, 138, 155, 168, 178, 186, 192, 196, 200, 203, 205, 206, 208, 209, 209, 210, 211, 211, 211, 211, 212, 212, 212, 212, 212, 212, 212],
[103, 28, 45, 58, 68, 76, 82, 86, 90, 93, 95, 97, 98, 99, 100, 100, 101, 101, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102],
[232, 63, 105, 137, 161, 179, 192, 202, 210, 215, 219, 223, 225, 227, 228, 229, 230, 230, 231, 231, 231, 232, 232, 232, 232, 232, 232, 232, 232, 232],
[106, 38, 60, 75, 85, 92, 96, 100, 102, 103, 104, 105, 105, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106],
[118, 42, 66, 83, 94, 102, 107, 110, 113, 114, 116, 116, 117, 117, 117, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118],
[208, 85, 133, 162, 180, 191, 198, 202, 204, 206, 207, 207, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208],
[104, 28, 45, 58, 69, 76, 83, 87, 91, 94, 96, 98, 99, 100, 101, 101, 102, 102, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 104, 104],
[108, 35, 55, 70, 81, 89, 94, 98, 101, 103, 105, 106, 106, 107, 107, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108]];

distance=[[0, 11, 19, 54, 54, 31, 31, 19, 19, 11, 11, 1, 11, 19, 31, 31, 19],
[11, 0, 11, 54, 54, 31, 31, 19, 19, 1, 1, 11, 1, 11, 31, 31, 19],
[19, 11, 0, 66, 66, 42, 42, 31, 31, 11, 11, 19, 11, 1, 42, 42, 31],
[54, 54, 66, 0, 1, 23, 23, 46, 46, 54, 54, 54, 54, 66, 23, 23, 46],
[54, 54, 66, 1, 0, 23, 23, 46, 46, 54, 54, 54, 54, 66, 23, 23, 46],
[31, 31, 42, 23, 23, 0, 1, 31, 31, 31, 31, 31, 31, 42, 1, 1, 31],
[31, 31, 42, 23, 23, 1, 0, 31, 31, 31, 31, 31, 31, 42, 1, 1, 31],
[19, 19, 31, 46, 46, 31, 31, 0, 1, 19, 19, 19, 19, 31, 31, 31, 1],
[19, 19, 31, 46, 46, 31, 31, 1, 0, 19, 19, 19, 19, 31, 31, 31, 1],
[11, 1, 11, 54, 54, 31, 31, 19, 19, 0, 1, 11, 1, 11, 31, 31, 19],
[11, 1, 11, 54, 54, 31, 31, 19, 19, 1, 0, 11, 1, 11, 31, 31, 19],
[1, 11, 19, 54, 54, 31, 31, 19, 19, 11, 11, 0, 11, 19, 31, 31, 19],
[11, 1, 11, 54, 54, 31, 31, 19, 19, 1, 1, 11, 0, 11, 31, 31, 19],
[19, 11, 1, 66, 66, 42, 42, 31, 31, 11, 11, 19, 11, 0, 42, 42, 31],
[31, 31, 42, 23, 23, 1, 1, 31, 31, 31, 31, 31, 31, 42, 0, 1, 31],
[31, 31, 42, 23, 23, 1, 1, 31, 31, 31, 31, 31, 31, 42, 1, 0, 31],
[19, 19, 31, 46, 46, 31, 31, 1, 1, 19, 19, 19, 19, 31, 31, 31, 0]];

Hi,

if you replace the beginning by

int umps = ...;
int wells = ...;
int horiz = ...;
int turn = ...;
int total = wells+1;

range P = 1..horiz;
range V = 1..wells;

range days = 1..horiz;
range lines = 1..wells;
range lines0= 0..wells+1;
range columns = 1..horiz;
range columns0 = 0..horiz+1;
range dimension = 1..total;

range k = 1..umps;
range v = 1..wells+1;
range v0 = 0..wells+1;

int distance[dimension][dimension]=...;
int optime[lines0][columns0]=...;
float vol[lines0][columns0]=...;

dvar boolean x[days][days][v];
dvar boolean y[days][v0][v0];
dvar boolean z[days][dimension][dimension];

As before, you use some indexes that are not in the range.

That is why I used the v0, line0 and columns0 ranges.

Regards

• MarcosQ
7 Posts

#### Re: Error operator forall not available

‏2014-01-01T21:23:47Z

Hi,

if you replace the beginning by

int umps = ...;
int wells = ...;
int horiz = ...;
int turn = ...;
int total = wells+1;

range P = 1..horiz;
range V = 1..wells;

range days = 1..horiz;
range lines = 1..wells;
range lines0= 0..wells+1;
range columns = 1..horiz;
range columns0 = 0..horiz+1;
range dimension = 1..total;

range k = 1..umps;
range v = 1..wells+1;
range v0 = 0..wells+1;

int distance[dimension][dimension]=...;
int optime[lines0][columns0]=...;
float vol[lines0][columns0]=...;

dvar boolean x[days][days][v];
dvar boolean y[days][v0][v0];
dvar boolean z[days][dimension][dimension];

As before, you use some indexes that are not in the range.

That is why I used the v0, line0 and columns0 ranges.

Regards

Hi Alex,

thanks for you answer, but after I posted the whole code, I noticied about the index problem. I just tried your solution, but I got an error at the maximize function.

Anyway, I worked on the index problem and the code looks right and free of erros, but ILOG does not provide an answer (a 'no solution' message), what it can be? Below is the new code:

int umps = ...;
int wells = ...;
int horiz = ...;
int turn = ...;
int total = wells+1;

range P = 1..horiz;
range V = 1..wells;

range days = 1..horiz;
range lines = 1..wells;
range columns = 1..horiz;
range dimension = 1..total;

range k = 1..umps;
range v = 0..wells;

int distance[dimension][dimension]=...;
int optime[lines][columns]=...;
float vol[lines][columns]=...;

dvar boolean x[days][days][v];
dvar boolean y[days][v][v];
dvar boolean z[days][dimension][dimension];

maximize
sum (z in P) sum(a in P:a<z) sum(b in V) x[z][a][b] * vol[b][z-a];

subject to {

forall (a in days, b in v)
sum (c in v) y[a][b][c] <= 1;

forall (a in days, b in v)
sum (c in v) y[a][c][b] <= 1;

forall (a in days)
sum (b in v:b!=0) y[a][0][b] == 1;

forall (a in days)
sum (b in v:b!=0) y[a][b][0] == 1;

forall (a in days, b in v)
sum (c in v) y[a][b][c] - sum (c in v) y[a][c][b] == 0;

forall (a in days)
sum (b in v, c in v) y[a][b][c] <= umps - 1;

forall (a in days)
sum (b in dimension, c in dimension) (distance[b][c]*z[a][b][c]) +
sum (d in v:d!=0, e in days:(a-e) in columns) (optime[d][a-e]*x[a][e][d]) <= turn;

forall (a in days, b in v)
sum (c in v) x[a][a][c] - sum (c in v)y[a][b][c] == 0;
}
• AlexFleischer
3204 Posts

#### Re: Error operator forall not available

‏2014-01-02T08:25:22Z
• MarcosQ
• ‏2014-01-01T21:23:47Z

Hi Alex,

thanks for you answer, but after I posted the whole code, I noticied about the index problem. I just tried your solution, but I got an error at the maximize function.

Anyway, I worked on the index problem and the code looks right and free of erros, but ILOG does not provide an answer (a 'no solution' message), what it can be? Below is the new code:

int umps = ...;
int wells = ...;
int horiz = ...;
int turn = ...;
int total = wells+1;

range P = 1..horiz;
range V = 1..wells;

range days = 1..horiz;
range lines = 1..wells;
range columns = 1..horiz;
range dimension = 1..total;

range k = 1..umps;
range v = 0..wells;

int distance[dimension][dimension]=...;
int optime[lines][columns]=...;
float vol[lines][columns]=...;

dvar boolean x[days][days][v];
dvar boolean y[days][v][v];
dvar boolean z[days][dimension][dimension];

maximize
sum (z in P) sum(a in P:a<z) sum(b in V) x[z][a][b] * vol[b][z-a];

subject to {

forall (a in days, b in v)
sum (c in v) y[a][b][c] <= 1;

forall (a in days, b in v)
sum (c in v) y[a][c][b] <= 1;

forall (a in days)
sum (b in v:b!=0) y[a][0][b] == 1;

forall (a in days)
sum (b in v:b!=0) y[a][b][0] == 1;

forall (a in days, b in v)
sum (c in v) y[a][b][c] - sum (c in v) y[a][c][b] == 0;

forall (a in days)
sum (b in v, c in v) y[a][b][c] <= umps - 1;

forall (a in days)
sum (b in dimension, c in dimension) (distance[b][c]*z[a][b][c]) +
sum (d in v:d!=0, e in days:(a-e) in columns) (optime[d][a-e]*x[a][e][d]) <= turn;

forall (a in days, b in v)
sum (c in v) x[a][a][c] - sum (c in v)y[a][b][c] == 0;
}

Hi,

If you label your constraints like in

subject to {

forall (a in days, b in v)
ct1:sum (c in v) y[a][b][c] <= 1;

forall (a in days, b in v)
ct2:sum (c in v) y[a][c][b] <= 1;

forall (a in days)
ct3:sum (b in v:b!=0) y[a][0][b] == 1;

forall (a in days)
ct4:sum (b in v:b!=0) y[a][b][0] == 1;

forall (a in days, b in v)
ct5:sum (c in v) y[a][b][c] - sum (c in v) y[a][c][b] == 0;

forall (a in days)
ct6:sum (b in v, c in v) y[a][b][c] <= umps - 1;

forall (a in days)
ct7:sum (b in dimension, c in dimension) (distance[b][c]*z[a][b][c]) +
sum (d in v:d!=0, e in days:(a-e) in columns) (optime[d][a-e]*x[a][e][d]) <= turn;

forall (a in days, b in v)
ct8:sum (c in v) x[a][a][c] - sum (c in v)y[a][b][c] == 0;
}

then you get a conflict

between

ct3[1]
and ct6[1]

plus many relaxations for ct3 and ct4

You see those directly if you use the IDE

If you use oplrun you can see that with oplrun -conflict and oplrun -relax

Regards

• MarcosQ
7 Posts

#### Re: Error operator forall not available

‏2014-01-02T20:21:59Z

Hi,

If you label your constraints like in

subject to {

forall (a in days, b in v)
ct1:sum (c in v) y[a][b][c] <= 1;

forall (a in days, b in v)
ct2:sum (c in v) y[a][c][b] <= 1;

forall (a in days)
ct3:sum (b in v:b!=0) y[a][0][b] == 1;

forall (a in days)
ct4:sum (b in v:b!=0) y[a][b][0] == 1;

forall (a in days, b in v)
ct5:sum (c in v) y[a][b][c] - sum (c in v) y[a][c][b] == 0;

forall (a in days)
ct6:sum (b in v, c in v) y[a][b][c] <= umps - 1;

forall (a in days)
ct7:sum (b in dimension, c in dimension) (distance[b][c]*z[a][b][c]) +
sum (d in v:d!=0, e in days:(a-e) in columns) (optime[d][a-e]*x[a][e][d]) <= turn;

forall (a in days, b in v)
ct8:sum (c in v) x[a][a][c] - sum (c in v)y[a][b][c] == 0;
}

then you get a conflict

between

ct3[1]
and ct6[1]

plus many relaxations for ct3 and ct4

You see those directly if you use the IDE

If you use oplrun you can see that with oplrun -conflict and oplrun -relax

Regards

Hi Alex,

thanks to let me know. I'm using the Cplex Optimization Studio, as I said, I'm a beginner at Cplex, and so far, this is the only way I know how to use it.

But I revised the constraints and found an error in ct6, and change to:

forall (a in dias, m in V)
ct6:sum (b in v, c in v) y[a][b][c] <= m - 1;

Still no solution, but got a different message about it (sorry but my Cplex version is in another language, don't know the best translation to english, but it's like a 'free solution' message)

Thanks for you help!

Updated on 2014-01-02T20:25:39Z at 2014-01-02T20:25:39Z by MarcosQ