Topic
3 replies Latest Post - ‏2013-04-29T12:45:43Z by ChrisBr
Hosssein
Hosssein
26 Posts
ACCEPTED ANSWER

Pinned topic variable ordering

‏2013-04-24T23:24:24Z |

 

Hi,

I am solving a constraint programming model by CP optimizer.  There are two sets of decision variables in the model as follows:

IloIntVarArray W(envvv, 20, 0, 10);

IloIntVarArray S(envvv, 20, 0, 10);

I want to use the following variable ordering in the CP search:

W[0], S[0] , W[1], S[1] , W[2] , S[2] , … , W[i-1],S[i-1],W[i],S[i] , ...

How can I implement this variable ordering?

IloSearchPhase accepts only one set of variables and if I use IloSearchPhaseArray cp optimizer decide about one set of variables first (for example W) and then the other set (for example S) which is not what I am looking for.

 

Thanks in advance for your help

  • ChrisBr
    ChrisBr
    57 Posts
    ACCEPTED ANSWER

    Re: variable ordering

    ‏2013-04-26T13:54:06Z  in response to Hosssein

    Hello Hossein,

    Why don't copy your variables in a dedicated array?

      IloIntVarArray vars(envvv);
      for(i=0; i<20; i++) {
        vars.add(W[i]);
        vars.add(S[i]);
      }


    then use this new array into the search-phase.

    I hope this helps,

    Chris.
     

    Updated on 2013-04-26T13:55:04Z at 2013-04-26T13:55:04Z by ChrisBr
    • Hosssein
      Hosssein
      26 Posts
      ACCEPTED ANSWER

      Re: variable ordering

      ‏2013-04-26T17:45:08Z  in response to ChrisBr

      Hi Chris.

      Great ! Good Idea.

      But adding a new set of variables increases the complexity of CP model. Right?

       

      • ChrisBr
        ChrisBr
        57 Posts
        ACCEPTED ANSWER

        Re: variable ordering

        ‏2013-04-29T12:45:43Z  in response to Hosssein

        Hi Hossein,

        Following my advice you are not creating new variables, instead you are copying existing variables in a new array. So the complexity of the model will not increase.
        You might have a look to the search log and notice that you get the same number of variables in both cases.
        Regards,

        Chris.