Topic
2 replies Latest Post - ‏2013-02-07T12:19:42Z by SystemAdmin
arguen
arguen
3 Posts
ACCEPTED ANSWER

Pinned topic variable indexer size for an array?

‏2013-02-05T21:31:41Z |
Hi all,
I want to define an array such that its indexer size varies.
For example: Let x v in V i in N j in N is a binary variable which equals 1 if vehicle v goes from i to j; 0 otherwise.

In my case x[V][N][N] is a very sparse matrix. But i know that, i depends on v and j depends on i and j.
In other words, a vehicle v can visit only the set of N_v(v) and can proceed to only j's element of set N_iv(i,v).

Thus I wrote the following code:
x[v in V][i in N_v[v]][j in N_iv[i,v]]


But, OPL didn't allow this.

Do you know if it is possible to somehow code this in OPL.
If OPL doesn't support "variable indexer size" do you know if C++ or Java support .

Thank you for any help or tip.
Updated on 2014-03-26T05:50:58Z at 2014-03-26T05:50:58Z by iron-man
  • arguen
    arguen
    3 Posts
    ACCEPTED ANSWER

    Re: variable indexer size for an array?

    ‏2013-02-05T21:46:31Z  in response to arguen
    By the way,
    I know one solution is using Tuple sets in OPL.
    But I afraid it may create problem when I want to solve the model with "flow-control" using OPL script.
    Also it would be difficult to write hundreds of lines to dictate each possibility.
    • SystemAdmin
      SystemAdmin
      1883 Posts
      ACCEPTED ANSWER

      Re: variable indexer size for an array?

      ‏2013-02-07T12:19:42Z  in response to arguen
      Go this tuples.

      You don't have to read the data in tuples, you can generate them from arrays on the generation step. I am not familiar with problems with tuples and flow control.

      Regards,
      Zahar