Python Pulp using with Matrices

后端 未结 2 1205
孤独总比滥情好
孤独总比滥情好 2021-02-07 07:39

I am still very new to Python, after years and years of Matlab. I am trying to use Pulp to set up an integer linear program.

Given an array of numbers:

{         


        
2条回答
  •  灰色年华
    2021-02-07 07:56

    You can set the lowBound and upBound on variables after the initialization. You can create an array of variables with

    LB[i] <= x[i] <= UB[i]
    

    with the following code.

    x = pulp.LpVariable.dicts("x", RANGE,  cat="Integer")
    for i in x.viewkeys():
         x[i].lowBound = LB_ind[i]
         x[i].upBound = UB_ind[i]
    

    The second parameter to LpVariable.dict is the index set of the decision variables, not their lower bounds.

提交回复
热议问题