Search code examples
python-3.xnonlinear-optimizationpyomo

How to declare two dimensional and three dimensional vector in Pyomo


I am trying to solve a optimization problem using Pyomo. For that i need to declare a two dimensional vector and a three dimensional vector . Both of the vectors can store only [0,1].

Sri and Xrij

R=3 V=8 1<=i,j<=V 1<=r<=R

I tried to to do using range in pyomo

model.IDXV = range(v+1)
model.IDXR = range(r+1)
model.x=Var(model.IDXR,model.IDXV,model.IDXV,within=Binary,initialize=0)
model.s=Var(model.IDXR,model.IDXV,within=Binary,initialize=0) 

I am using the 'ipopt' solver but after execution the value of X and S is in fraction instead of 0 or 1.

Please help me to do this.


Solution

  • Axel Kemper (in the comments) is correct. ipopt is a nonlinear programming solver and automatically assumes that you intend to relax discrete values.

    For linear-discrete problems, there are the cbc and glpk free solvers. gurobi and cplex are the major commercial solvers.

    For nonlinear-discrete problems, couenneand bonmin are the free solvers. Several other commercial and academic solvers are also available.