# # First (minor) difference: we must import the XpressProblem class # from xpress_problem.py in the problems/ directory. # # Problem data. n = 2 numpy.random.seed(1) x0 = numpy.arange(n) y0 = numpy.arange(n) # Construct the problem. x = Variable(n) # x_0_0, x_0_1 y = Variable(n) # x_1_0, x_1_1 x.var_id = 'Xvar' y.var_id = 'Y' objective = Minimize(sum(y) + sum_squares(x)) qcon1 = sum_squares(y - y0) <= 1.01 lowx = x >= x0 upx = x <= 10 + 10 * x0 qcon2 = sum_squares(y + y0) <= 1.01 qcon1.constr_id = 'dist_pos' lowx.constr_id = 'first_orthant' upx.constr_id = 'upper_lim' qcon2.constr_id = 'dist_neg' constraints = [qcon1, lowx, qcon2, upx]
from cvxpy.problems.xpress_problem import XpressProblem import numpy # Problem data. n = 2 numpy.random.seed(1) x0 = numpy.arange (n) y0 = numpy.arange (n) # Construct the problem. x = Variable (n) # x_0_0, x_0_1 y = Variable (n) # x_1_0, x_1_1 x.var_id = 'Xvar' y.var_id = 'Y' objective = Minimize (sum (y) + sum_squares (x)) qcon1 = sum_squares (y - y0) <= 1.01 lowx = x >= x0 upx = x <= 10 + 10 * x0 qcon2 = sum_squares (y + y0) <= 1.01 qcon1.constr_id = 'dist_pos' lowx.constr_id = 'first_orthant' upx.constr_id = 'upper_lim' qcon2.constr_id = 'dist_neg' constraints = [qcon1, lowx, qcon2, upx]