I'm trying to force a variable to be an integer (integer constraint) using cvxpy in Python, but result keeps being a float:
from cvxpy import *
Fi = Int()
Or = Int()
constr = [Fi <= 3000,
Or <= 3000,
Or >= 1000,
1.25*Or - Fi >= 0,
Fi >= 0,
Or >= 0]
obj= Maximize(50000*Fi + 25000*Or)
prob = Problem(obj, constr)
prob.solve()
print ("Status: ", prob.status)
print ("Fi: ", Fi.value)
print ("Or: ", Or.value)
print ("Obj: ", obj.value)
Result:
Status: optimal
Fi: 2999.9999999
Or: 2999.99999989
Obj: 224999999.992
What can I do to force it?
I have tried too:
Fi = Variable()
Or = Variable()
constr = [Fi <= 3000,
Or <= 3000,
Or >= 1000,
1.25*Or - Fi >= 0,
Fi >= 0,
Or >= 0,
Fi == Int(),
Or == Int()]
Fi and Or are variables. Not just numbers.