Ask Your Question

Behzad's profile - activity

2018-06-07 16:28:53 -0500 received badge  Self-Learner (source)
2018-03-09 18:53:02 -0500 received badge  Taxonomist
2017-10-19 11:51:44 -0500 received badge  Necromancer (source)
2017-10-19 11:51:44 -0500 received badge  Teacher (source)
2017-06-07 11:25:19 -0500 received badge  Popular Question (source)
2016-02-22 19:35:18 -0500 received badge  Famous Question (source)
2015-09-06 21:21:56 -0500 received badge  Notable Question (source)
2015-09-06 21:21:56 -0500 received badge  Popular Question (source)
2014-06-29 14:51:31 -0500 received badge  Popular Question (source)
2014-06-29 14:51:31 -0500 received badge  Notable Question (source)
2014-01-19 07:18:55 -0500 commented answer How can I add cvxpy to Sage

I was still wondering if I can cvxpy to Sage Cloud in my session.

2014-01-09 14:08:00 -0500 marked best answer Why do I get the wrong answer from this LP problem?

Helloooooooooooooooooooooo !!

That's because all variables are assumed to be >= 0 by default unless specified otherwise. Sorry for that, it's something that all LP solvers that I know assume too (and that's why we do, too), and it's pretty hard to advertise in the doc and make sure that everybody sees it O_o

So if you want to make this work with negative values, you have to add lines like :

p.set_min(p['x'],None)
p.set_min(p['y'],None)

in your code. And it will work, at least it does on my computer.

Perhaps I should add warnings everywhere in the doc O_o

Nathann

2014-01-09 12:51:12 -0500 received badge  Editor (source)
2014-01-09 12:50:35 -0500 asked a question Exception: type 'sage.rings.real_mpfr.RealLiteral' is not a valid type for a Constant value.

I added cvxpy and ecos to my Sage installation. When I run the following code for the first time, I get the exception in the title. However, the second time the code runs fine.

RealNumber=float

Integer=int

import numpy

from pylab import *

import math

from cvxopt import matrix as m

from cvxpy import *

x = Variable(1)

y = Variable(1)

constraints

constraints = [ x+y >= -1.0, x+y <= 10.0]

objective

objective = Maximize(x+y)

p = Problem(objective, constraints)

result = p.solve()

print result

The optimal value

print x.value

print y.value

2013-12-25 07:14:40 -0500 answered a question How can I add cvxpy to Sage

Till now, I realized to install any Python module, you can write:

sage --python setup.py install

in the module folder.

2013-12-23 16:00:09 -0500 answered a question LMI (Linear Matrix Inequalities)

It might be too late but you here is CVXOPT, the solver for convex optimization: http://www.sagemath.org/doc/numerical...

2013-12-23 15:55:27 -0500 asked a question How can I add cvxpy to Sage

It is not easy to describe convex optimization problems for CVXOPT because CVXOPT is just the solver and there is almost no "modeling" (or user friendly interface). Take Yalmip as an example. With Yalmip, you can add constraints as: x1+2*x2<=0 and much more (including matrices). The closest thing I found for CVXOPT was cvxpy. I was wondering how I can add cvxpy to my Sage installation.

Thanks

2013-12-04 16:10:14 -0500 commented answer Why do I get the wrong answer from this LP problem?

Thanks for the answer. Maybe it's better to leave the constraints to the user.

2013-12-03 17:45:46 -0500 received badge  Student (source)
2013-12-03 14:22:48 -0500 asked a question Why do I get the wrong answer from this LP problem?

In this cell, I have a linear programming problem: http://sagecell.sagemath.org/?q=oatgsd

However, the answer is wrong. The optimal objective has to be 1 whereas it is 0. The optimal values for x and y lie on the line between (-2,1) and (1,-2). I have shown the values of the constraints for the point (-1,0)

2013-11-19 15:59:04 -0500 received badge  Scholar (source)
2013-11-19 15:59:04 -0500 marked best answer Why do I get the "unable to find a common ring for all elements" error message?

The variables in the MILP are not symbolic variables, i.e., not from the Symbolic Ring. The vector() command is failing in that step.

type(x)
<type 'sage.numerical.linear_functions.LinearFunction'>

You can rewrite your constraints like this

p.add_constraint(sum(_a*_x for _a,_x in zip(a1, [x,y])) + r*a1.norm(2) <= b1)
2013-11-19 15:58:59 -0500 received badge  Supporter (source)
2013-11-17 13:46:09 -0500 asked a question Why do I get the "unable to find a common ring for all elements" error message?

I was wondering if you can take a look at this cell:

http://sagecell.sagemath.org/?q=ypqhgw

and let me know why I get the error message.

Thanks