Topic
2 replies Latest Post - ‏2013-09-29T23:16:08Z by guvencdik
guvencdik
guvencdik
2 Posts
ACCEPTED ANSWER

Pinned topic Logical Conditions in Decision Variable Declaration

‏2013-09-27T08:03:35Z |

Hello everybody,

Iam using latest version of opl and i have a question i have never tought about it before.

Lets assume i have a 2 dim binary decision variable X_ij (i and j is from same set/range)

This would be the code piece to define the decision variable...

 int nbJobs=10;
 range i=1..nbJobs;

 range j=1..nbJobs;// I dont really need this, i could have declared dvar int+ x[i][i] in 0..1;

 dvar int+ x[i][j] in 0..1;

But with these piece of code I am also creating these decision variables which i dont want(X11,X22,X33....X1010)

How can i improve this declaration? How can i  put logical constraint during variable declaration such as i!=j

(So actually i dont want to say forall ij : i==j -->Xij== 0 in the constraints)

Thank you very much for your advise.

 

  • AlexFleischer
    AlexFleischer
    1028 Posts
    ACCEPTED ANSWER

    Re: Logical Conditions in Decision Variable Declaration

    ‏2013-09-27T08:34:38Z  in response to guvencdik

    Hi,

    if you do not write any constraint on X11 then it won't consume much memory.

    But what you can also do is to use dvar int+ x[s] in 0..1 instead of dvar int+ x[i][j] in 0..1;

    And s will be a tuple set :

    tuple t

    {

    int I;

    int J,

    }

    {t} s={<I,J> | I in i,J in j: i!=j};

     

    regards

    • guvencdik
      guvencdik
      2 Posts
      ACCEPTED ANSWER

      Re: Logical Conditions in Decision Variable Declaration

      ‏2013-09-29T23:16:08Z  in response to AlexFleischer

      Thank you very much.

      Yep I should use tuples.