Ask Your Question

Behzad's profile - activity

2022-06-04 21:46:20 +0200 received badge  Notable Question (source)
2021-03-26 01:42:49 +0200 received badge  Popular Question (source)
2018-06-07 23:28:53 +0200 received badge  Self-Learner (source)
2018-03-10 01:53:02 +0200 received badge  Taxonomist
2017-10-19 18:51:44 +0200 received badge  Teacher (source)
2017-10-19 18:51:44 +0200 received badge  Necromancer (source)
2017-06-07 18:25:19 +0200 received badge  Popular Question (source)
2016-02-23 02:35:18 +0200 received badge  Famous Question (source)
2015-09-07 04:21:56 +0200 received badge  Notable Question (source)
2015-09-07 04:21:56 +0200 received badge  Popular Question (source)
2014-06-29 21:51:31 +0200 received badge  Notable Question (source)
2014-06-29 21:51:31 +0200 received badge  Popular Question (source)
2014-01-19 14:18:55 +0200 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 21:08:00 +0200 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 19:51:12 +0200 received badge  Editor (source)
2014-01-09 19:50:35 +0200 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 14:14:40 +0200 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 23:00:09 +0200 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 22:55:27 +0200 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 23:10:14 +0200 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-04 00:45:46 +0200 received badge  Student (source)
2013-12-03 21:22:48 +0200 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 22:59:04 +0200 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 22:59:04 +0200 received badge  Scholar (source)
2013-11-19 22:58:59 +0200 received badge  Supporter (source)
2013-11-17 20:46:09 +0200 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