Search code examples
pythonpyomo

python pyomo: declaration of discrete variable


I am using pyomo for optimization modeling, including multiple continuous and discrete variables, but I am not clear how to define a discrete variable.The value of discrete variable is either 0 or 100. my question is : how to define a discrete variable which value is either 0 or 100

thans all!


Solution

  • You would have to declare a binary variable, e.g. y, in addition to your discrete variable, e.g. myvar.

    Then, you need a constraint that says: myvar = 100 * y

    If y=0, then myvar will necessarily be 0 too. If y=1, then myvar will be equal to 100.

    I assume you would be able to express these in Pyomo syntax.