Decision Optimization

Expand all | Collapse all

Error using 'member' function with python

  • 1.  Error using 'member' function with python

    Posted Tue September 24, 2019 02:55 AM

    Originally posted by: rakesh85


    I am trying to use the 'member' function in Python inside if_then. However, I am getting the error in the solution stage (and not in the model building stage). Please look at the formulated constraint:

    mdl.add( if_then ( mdl.member ( 1, [1,2,3] ), x==2).

    The error I am getting is the following:

    "Solver error: Error reading model from <stream> (<ipython-input-154-c271cd74d003>:39(stream:19:1): Error: 'member' is not a function.)"

    Appreciate your help.

    Thanks.

     



  • 2.  Re: Error using 'member' function with python

    Posted Tue September 24, 2019 09:04 AM

    Originally posted by: Olivier OUDOT


    Hello Rakesh,

    You have found a bug in our Python interface, thanks a lot for that. In fact, the function 'member' is deprecated since COS 12.7 and has been replaced by 'allowed_assignments'. If you change your code with this function, it will work.

    We will fix the problem in a next release !

    Thanks for using our product.