def setUp(self): # Primal problem. self.P = P = picos.Problem() self.x = x = P.add_variable("x") self.y = y = P.add_variable("y") P.set_objective("min", picos.lse((x - y) & (-x + y + math.log(2)))) P.add_constraint(picos.lse(x + 2 * y) <= 0) P.add_constraint(picos.lse(-x - 2 * y) <= 0)
#--------------------------------------# # min x/y+2y/x # x*y*y=1 # (x,y>0) #X=ln x, Y=ln y # <=> # exp max lse[X-Y,Y-X+ln(2)] # X+2Y=0 from math import log gp=pic.Problem() X=gp.add_variable('X',1) Y=gp.add_variable('Y',1) #gp.add_constraint(X+2*Y==0) #marche moins bien que les 2 LSE equivalentes ci-dessous (?) gp.add_constraint(pic.lse(X+2*Y)<0) gp.add_constraint(pic.lse(-X-2*Y)<0) gp.set_objective('min',pic.lse((X-Y) & (Y-X+log(2)))) #----------------------------------------# # non-convex QP (bimatrix game) #----------------------------------------# import picos as pic bim=pic.Problem() AA=pic.new_param('A',[[ 1.21e+00, 5.90e-01, -1.45e+00],[-5.64e-01, 1.01e+00, 4.22e-01]]) BB=pic.new_param('B',[[ 1.30e-01, -1.59e+00, 2.06e+00],[ 1.06e+00, -5.56e-01, -1.76e-01]]) x=bim.add_variable('x',2) y=bim.add_variable('y',3) x.T*(AA+BB)*y alpha=bim.add_variable('alpha',1)