Answered question
This question has been answered.

Unanswered question
This question has not been answered yet.

Hello,
I need help with min function.
I want to find min value of Tijv[i][j][v] over j for all i and v and assign these minima to a new matrix: MinTj[i][v]
My following code gives "Scripting parser error".

Thanks for your help.

int Tijv[N][N][V] =...;
//Assigning travel times
int MinTj[N][V]; execute MINJ
{
for (var v in V)
{
for (var i in N)
{ MinTj[i][v] = ( min(j in N) Tijv[i][j][v] );
// gives error - Scripting parser error: missing ')' - on this line
}
}
}

Hello,
I need help with min function.
I want to find min value of Tijv[i][j][v] over j for all i and v and assign these minima to a new matrix: MinTj[i][v]
My following code gives "Scripting parser error".

Thanks for your help.

<pre class="jive-pre">
int Tijv[N][N][V] =...;
//Assigning travel times
int MinTj[N][V]; execute MINJ
{
for (var v in V)
{
for (var i in N)
{ MinTj[i][v] = ( min(j in N) Tijv[i][j][v] );
// gives error - Scripting parser error: missing ')' - on this line
}
}
}
</pre>

This is the accepted answer.
This is the accepted answer.

Hi

You cannot use the construct "min (j in 1..N)" in the script. For initializing the array MinTj, you can directly use the modeling language.

int N = 10;
int V = 5;
int Tijv[i in 1..N][j in 1..N][v in 1..V] = v*(1 + 10*((i < j) ? j - i : i - j));
//Assigning travel times
int MinTj[i in 1..N][v in 1..V] = min (j in 1..N) Tijv[i][j][v];

cheers

Hi

You cannot use the construct "min (j in 1..N)" in the script. For initializing the array MinTj, you can directly use the modeling language.

<pre class="jive-pre">
int N = 10;
int V = 5;
int Tijv[i in 1..N][j in 1..N][v in 1..V] = v*(1 + 10*((i < j) ? j - i : i - j));
//Assigning travel times
int MinTj[i in 1..N][v in 1..V] = min (j in 1..N) Tijv[i][j][v];
</pre>

You cannot use the construct "min (j in 1..N)" in the script. For initializing the array MinTj, you can directly use the modeling language.

<pre class="jive-pre">
int N = 10;
int V = 5;
int Tijv[i in 1..N][j in 1..N][v in 1..V] = v*(1 + 10*((i < j) ? j - i : i - j));
//Assigning travel times
int MinTj[i in 1..N][v in 1..V] = min (j in 1..N) Tijv[i][j][v];
</pre>

Thank you for your reply.
It helped.
But I have one more question, if you don't mind:
How can I understand which functions/keywords can be used in script and which can be used in modeling language or both and syntax difference.
It is not clear to me from the manual.
Thank you again.

This is the accepted answer.
This is the accepted answer.

Hi

When using OPL, you manipulate two different languages:

The modeling language is a language for math and constraint programming modeler. It has some specific features tuple, tupleset, jointures on tupleset in all, min, max, sum and forall instruction. For a concise introduction you have the book <<The OPL Optimization Programming Language>> by Pascal van Hentenrick. It suufices for creating all array you need as soon as they are indexed by tupleset and use already initialized array of constant, expressions, constraints, and variables.

The codes in execute (or main) blocks are JavaScript code. You can easily find JavaScript tutorials on the web. The specific JavaScript extensions for OPL is in the online documentation. Note that there is a Java API for OPL that is a similar API than the one in JavaScript. It should be used only for data cleaning and reorganization from the database, outputs and multiple models applications.

When using OPL, you manipulate two different languages:

The modeling language is a language for math and constraint programming modeler. It has some specific features tuple, tupleset, jointures on tupleset in all, min, max, sum and forall instruction. For a concise introduction you have the book <<The OPL Optimization Programming Language>> by Pascal van Hentenrick. It suufices for creating all array you need as soon as they are indexed by tupleset and use already initialized array of constant, expressions, constraints, and variables.

The codes in execute (or main) blocks are JavaScript code. You can easily find JavaScript tutorials on the web. The specific JavaScript extensions for OPL is in the online documentation. Note that there is a Java API for OPL that is a similar API than the one in JavaScript. It should be used only for data cleaning and reorganization from the database, outputs and multiple models applications.