Topic
  • 1 reply
  • Latest Post - ‏2013-03-12T06:49:14Z by SystemAdmin
SystemAdmin
SystemAdmin
7929 Posts

Pinned topic how to initialize iloint variables?

‏2013-03-12T02:07:50Z |
I defined an IloIntVarArray x and added an instance of IloIntVar with the following code:

x.add(IloIntVar(env, 1, 5, "x1"));


executing the statement would set the upper and lower bounds the IloIntVar 'x1', but how to assign a specific integer value to "x1"?

I used the following code
x[0] = 2;

but comes with a compiling error 'error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)'
any ideas? thanks;)
Updated on 2014-03-24T22:35:46Z at 2014-03-24T22:35:46Z by iron-man
  • SystemAdmin
    SystemAdmin
    7929 Posts

    Re: how to initialize iloint variables?

    ‏2013-03-12T06:49:14Z  
    You cannot assign a value to an instance of IloIntVar.
    If you want to fix a variable to a particular value then you need to set the lower and upper bound of that variable to that value. You can use the setLB and setUB member functions to do that.