测试环境:
anconda3+python3.8
pyscipopt==8.0.1
代码:
from pyscipopt import Model
model = Model("Example")
x = model.addVar("x")
y = model.addVar("y", vtype="INTEGER")
model.setObjective(x + y)
model.addCons(2*x - y*y >= 0)
model.optimize()
sol = model.getBestSol()
print("x: {}".format(sol[x]))
print("y: {}".format(sol[y]))
结果: