# Use os SOS2 in Linear Optimization I have a linear optimization to minimize value like

MIN = sum(x_i*j_i)
Constrains:
0 < x_i  < C
0 < j_i < J
x_i + y_i <= x_(i-1) + f(x_i)


Where this f(x_i) is a SOS2 function:

Sum(lambda_i) = 1
Sum(lambda_i * X_i) = x_i  # Here X_i is a constant.
Sum(lambda_i * K_i) = result # Here K_i is a constant.
this result will be returned.


When I make individual MixedIntegerLinearProgram(maximization=False, solver = "GLPK") one for f(x), I am able to slove. When introducing the function as another variable into another MixedIntegerLinearProgram(maximization=False, solver = "GLPK") I am unable to get the results.

Need help in actually formulating the sage equations.

edit retag close merge delete

Sort by » oldest newest most voted

When I am looking at documentation? I see there is solution for Piecewise in Sage,

This Piecewise helped me to solve the problem, with accurate results.

when I am passing a MixedIntegerLinearProgram variable I am getting the exception saying the value should be Integer.

There is another thread where the results are wrong when doing minimization of the SOS2. http://ask.sagemath.org/question/3314...

Need help in integrating a SOS2 or Piecewise model with MixedIntegerLinearProgram.

more