Ask Your Question

Linearization of the objective in "MixedIntegerLinearProgram"

asked 2021-12-05 18:05:11 +0200

CyrilleP gravatar image

updated 2023-05-19 21:53:24 +0200

FrédéricC gravatar image

I have a Mixed integer program with non lineazr objective. But as it is the product of power there is no difficulty to linearize. But the program refuses the following modelization.

    c=vector([ln(u) for u in po])
    nc=3 #nombre de contraintes
    nv=8 #nombre de variables
    B0=[40,30,45000] #borne inférieure
    B1=[0,0,0] #borne supérieure
    P=MixedIntegerLinearProgram(maximization=True, solver="GLPK")
    x=P.new_variable(integer=True, nonnegative=False, indices=[0..nv-1])

for i in range(0,nc):
     P.add_constraint(B[i],min=B0[i], max=B1[i])
for i in range(0,nv):
#xi doit avoir pour minimum 0

obviously its P.set_objective(zz) which doesn't work.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-12-05 18:59:29 +0200

Max Alekseyev gravatar image

updated 2021-12-05 19:05:46 +0200

The multiplication c*x is not defined (notice that x is not a vector). Correspondingly, zz=c*x needs to be expressed explicitly - for example, zz=sum( cc*xx for cc,xx in zip(c,x) ).

Also, by the same reason the result of A*x is not what is expected. So, B=A*x also needs to be explicitly expressed - for example, B = [ sum( aa*xx for aa,xx in zip(row,x) ) for row in A.rows() ]

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-12-05 18:05:11 +0200

Seen: 139 times

Last updated: Dec 05 '21