Ask Your Question

subbu's profile - activity

2021-03-25 13:16:17 +0200 received badge  Popular Question (source)
2013-12-17 13:30:08 +0200 answered a question Use os SOS2 in Linear Optimization

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.

2013-12-16 14:49:05 +0200 answered a question what type of object is a function defined with the piecewise command?

Use lambda functions it worked for me.

2013-12-13 09:58:06 +0200 commented question Output results of sage MixedIntegerLinearProgram solution are not as expected

Yes, I am sure. I checked on paper and even with other LP solver LINDO.

2013-12-12 16:01:29 +0200 asked a question Output results of sage MixedIntegerLinearProgram solution are not as expected

For the problem below

#!/usr/bin/sage -python

from sage.all import *
import sys

problem = MixedIntegerLinearProgram(maximization=False, solver = "GLPK")
y = problem.new_variable(real=True, name='y')

constraints_1 = [(0.0, 6769.0),
                 (8260.0, 6812.0),
                 (12390.0, 7105.0),
                 (16520.0, 7448.0),
                 (20650.0, 7924.0),
                 (24780.0, 8289.0),
                 (28910.0, 8630.0),
                 (33040.0, 9000.0)]
sos_var_1 = problem.new_variable(name='sos2_var')
eq1_1 = 0.0
eq1_2 = 0.0
eq1_3 = 0.0
for i in range(len(constraints_1)):
    eq1_1 += sos_var_1[i]*constraints_1[i][0]
    eq1_2 += sos_var_1[i]*constraints_1[i][1]
    eq1_3 += sos_var_1[i]
problem.add_constraint(eq1_1 == 23450)
problem.add_constraint(eq1_2 == y[0])
problem.add_constraint(eq1_3 == 1)

problem.set_objective(y[0])
print problem.solve()

I am expecting the result to be 8136 but I am getting

8099.05084746

Can anyone help or explain why this is happening?

2013-12-07 01:06:53 +0200 asked a question nameError: name MixedIntegerLinearProgram not defined

Getting error in this file File Content as below in test.py

--------------

#!/usr/bin/sage -python

from sage.all import *

p = MixedIntegerLinearProgram()

--------------------

chmod +x test.py

./test.py

after executing I am receiving the error

Traceback (most recent call last): File "./test2.py", line 3, in <module> from sage.all import * File "/opt/sage/local/lib/python2.7/site-packages/sage/all.py", line 63, in <module> from sage.misc.all import * # takes a while File "/opt/sage/local/lib/python2.7/site-packages/sage/misc/all.py", line 60, in <module> from log import log_html, log_dvi, log_text File "/opt/sage/local/lib/python2.7/site-packages/sage/misc/log.py", line 64, in <module> import interpreter File "/opt/sage/local/lib/python2.7/site-packages/sage/misc/interpreter.py", line 67, in <module> import os, log, re, new, sys File "/home/bob/tank/new.py", line 18, in <module> problem = MixedIntegerLinearProgram(maximization=False, solver = "GLPK") NameError: name 'MixedIntegerLinearProgram' is not defined

Can anyone help me in fixing this problem?

2013-11-01 00:20:01 +0200 asked a question 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.