'error java scripting cplex optimization studio
I´m a beginner in ibm ilog cplex optimization studio.
I´m getting an error when I try to run this code :
{int} job=...; //
{int} mch=...; //
{int} opes=...;
float M=...; //
tuple capableMchs{
int j; // jobs
int o; // operations
int m; //machines
};
{capableMchs} capableMch=...;
{int} Ope[j in job] = { o | <j,o,m> in capableMch};
tuple jointMchs {
int j; //jobs
int o; //operation of j
int h; // jobs
int g; // operation of h
int m; } //machine
{jointMchs} jointMch={};
execute IniciarTupleSet {
for (var j in job) {
for (var op in Ope[j]) {
for (var h in job , (j < h)) {
for (var g in Ope[h]) {
for (var m in mch, <j,op,m> in capableMch) {
if (<h,g,m> in capableMch)
jointMch.add(j,op,h,g,m)
}
}
}
}
}
}
The error I get is: "missing expression"
I think the problem resides in the "for (var m in mch, <j,op,m> in capableMch) " part, but I don´t know how to solve it. Without that preprocessing block I have to do much work by hand.
For context: jointMch is used to index a boolean variable Z that represents that the operation g of a job h precedes the operation o of job j in the machine m.
Here is an example of what I expect the code to generate:
job = { 1 2 3} ;
mch = {1 2 3} ;
opes = {1 2 3} ;
capableMch={ //tuple set of doable operation of jobs in a machine
<1,1,1>,
<1,1,2>,
<1,2,1>,
<1,2,2>
<1,3,3>,
<2,1,2>,
<2,2,2>,
<3,1,3>,
<3,2,3>,
<3,3,3>,
};
jointMch = {
<1,1,2,1,2>,
<1,2,2,1,2>,
<1,2,2,2,2>,
<1,1,1,2,2>,
<1,3,3,1,3>,
<1,3,3,2,3>,
<1,3,3,3,3>,
};
For example because job 1 operation 1 and job 2 operation 1 both are doable in machine 2 I need the element : <1,1,2,1,2> and so on.
Solution 1:[1]
in OPL you have 2 languages : the modeling part and the javascript part. In the javascript part use the javascript language.
{int} job={1,2}; //
{int} mch={1,2};; //
{int} opes={1,2};;
float M=100; //
tuple capableMchs{
int j;
int o;
int m;
};
{capableMchs} capableMch={<1,2,3>};
{int} Ope[j in job] = { o | <j,o,m> in capableMch};
tuple jointMchs {
int j;
int o;
int h;
int g;
int m;}
{jointMchs} jointMch={};
execute IniciarTupleSet {
for (var j in job) {
for (var op in Ope[j]) {
for (var h in job) if (j < h) {
for (var g in Ope[h]) {
for (var m in mch) for(var jopm in capableMch) if (jopm.j==j) {
if (capableMch.find(h,g,m))
jointMch.add(j,op,h,g,m)
}
}
}
}
}
}
works
but with your latest comment I would encourage you to rely on OPL modeling and write
{jointMchs} jointMch={<j,o,h,g,m> | <j,o,h> in capableMch,g in Ope[h],m in mch :<h,g,m> in capableMch && j<h};
which gives
1,1,2,1,2
1,1,2,2,2
1,2,2,1,2
1,2,2,2,2
1,3,3,1,3
1,3,3,2,3
1,3,3,3,3
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
