My First Robust ProblemΒΆ
We consider a simple linear optimization problem with an ellipsoidal uncertainty set. (TODO complete)
[3]:
import cvxpy as cp
import numpy as np
import lropt as lr
[5]:
n = 2
P = np.array([[1.,2],[1.,0.]])
A = np.eye(2)
b = np.zeros(2)
c = np.array([2,1])
a = np.array([.4,0.5])
u = lr.UncertainParameter(n,
uncertainty_set=lr.Ellipsoidal(A=A, b=b))
x = cp.Variable(n)
objective = cp.Minimize(c @ x)
constraints = [(P @ u + a) @ x <= 10]
prob = lr.RobustProblem(objective, constraints)
[6]:
prob.solve()
print("optimal value = ", objective.value)
print("optimal solution = ", x.value)
optimal value = -20.76298271930384
optimal solution = [ -1.83921308 -17.08455655]