Hi, I want to define an array a _{i}, the element of the array is set type. So that I can implement a constraint like:
x _{ik} != 1 forall i,k: k in a _{i}
It seems that OPL doesn't support this. Can you help me achieve my purpose?
Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic

Re: array element as set?
20121220T09:58:46ZThis is the accepted answer. This is the accepted answer.Hello,
I think it works in OPL:
int n=10; { int } A[i in 1..n] = { k  k in 1..i }; dvar int x[i in 1..n][j in 1..n] in 0..1; constraints { forall(i in 1..n, k in A[i]) { x[i][k] != 0; } }
Is it something like that you want to do ?
Philippe 
Re: array element as set?
20121220T10:28:22ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20121220T09:58:46Z
Hello,
I think it works in OPL:
<pre class="jivepre">int n=10; { int } A[i in 1..n] = { k  k in 1..i }; dvar int x[i in 1..n][j in 1..n] in 0..1; constraints { forall(i in 1..n, k in A[i]) { x[i][k] != 0; } }
</pre>
Is it something like that you want to do ?
Philippe
I want to initialize A in .dat file, and the values doesn't depend on i, Could you give correct format to initialize A in dat file? thanks.
in mod:
{ int } A[i in 1..2] = ...;
in dat:
A = ?; 
Re: array element as set?
20121220T10:40:52ZThis is the accepted answer. This is the accepted answer. qtbgo
 20121220T10:28:22Z
thank you very much. it works.
I want to initialize A in .dat file, and the values doesn't depend on i, Could you give correct format to initialize A in dat file? thanks.
in mod:
<pre class="jivepre">{ int } A[i in 1..2] = ...;
</pre>
in dat:
A = ?;A = [ { 1 } {1 2 } ];