XiongPengNUS / rsome

Robust Stochastic Optimization Made Easy
GNU General Public License v3.0
282 stars 54 forks source link

multiple uncertainty sets #29

Closed AmalNammouchi closed 1 year ago

AmalNammouchi commented 1 year ago

Hi, thank you for this awesome toolbox. My question is if there is a way where if one constraint have for example two random variables, where each belong to a different uncertainty set, whether there is a way to deal with that in RSOME. z_1 € u_1 z_2 € u_2 and z_1, z_2 occur in the same constraint.

Thank you

GalPerelman commented 1 year ago

Hi @AmalNammouchi You can combine more than one uncertainty set in a single constraint See for example the following formulation:

x = model.dvar(4)
c = np.array([-5500, -6100, 199.9, 100])
A = np.array([[0, 0, 1, 1], [90, 100, 0, 0], [40, 50, 0, 0], [700, 800, 199.9, 100]])
b = np.array([1000, 2000, 800, 100000])
model.st(x >= 0)
model.st(A @ x <= b)

z1 = model.rvar(4)
z1_set = (rsome.norm(z1, np.inf) <= gamma1)

z2 = model.rvar(4)
z2_set = (rsome.norm(z2, np.inf) <= gamma2)

A1 = np.array([[0.5, 0.6, -0.02, -0.01]])
A2 = np.array([[0, 0, -0.02 * 0.02, 0]])
A3 = np.array([[0, 0, 0, -0.005 * 0.01]])
model.st((A1 @ x + A2 @ z1 + A3 @ z2 <= b).forall([z1_set, z2_set]))

model.min((c @ x).sum())