Skip to content

Instantly share code, notes, and snippets.

@upadhyan
Last active October 19, 2022 04:02
Show Gist options
  • Save upadhyan/82d028e5b8bda521035415b3af6c9290 to your computer and use it in GitHub Desktop.
Save upadhyan/82d028e5b8bda521035415b3af6c9290 to your computer and use it in GitHub Desktop.
Setting up a Two-Stage Stochastic Program for a server farm problem
import numpy as np
import gurobipy as gp
from gurobipy import GRB
## First Stage Constants
i = np.array([6,14,27])
s = np.array([1,5,3])
B = 1000
S = 100
## Second Stage Constants
K = 50 # Number of scenarios
d_xi = np.array([
np.random.normal(70,10,K),
np.random.normal(8,2,K),
np.random.normal(15,4,K)
])
c = np.array([7,18,30])
p = np.array([1.0/K]*K) # Probability of a scenario happening
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment