<jupyter_start><jupyter_text>Generate Problem Parameters<jupyter_code>n_origins = 2
n_destinations = 2
n_intermediates = 4
#------------
param = ndp.generate_random_parameters(n_origins, n_destinations, n_intermediates)
param<jupyter_output><empty_output><jupyter_text>Instantiate Problem<jupyter_code>network_problem = ndp.NetworkDesign(param)
network_problem<jupyter_output><empty_output><jupyter_text>Instantiate Problem Uncertainty  Lognormal Demand<jupyter_code>n_scenarios = 10
distribution = 'lognormal'
mean = 1
std = 1
#------------------
network_uncertainty = ndu.Demands(n_scenarios=n_scenarios, 
                                  n_commodities=n_destinations*n_origins, 
                                  distribution=distribution,
                                  mean=mean, 
                                  std=std)
network_uncertainty<jupyter_output><empty_output><jupyter_text>Uniform Demand<jupyter_code>n_scenarios = 10
distribution = "uniform"
lb = 5
ub = 20
corr = 0.4
#-------------------
network_uncertainty = ndu.Demands(n_scenarios=n_scenarios,
                                  n_commodities=n_origins*n_destinations, 
                                  distribution=distribution,
                                  lb=lb, 
                                  ub=ub, 
                                  corr=corr)
network_uncertainty<jupyter_output><empty_output><jupyter_text>Build scenario tree<jupyter_code># get only scenarios of index [1, 5]
scenario_tree = network_uncertainty.get_scenario_tree([1, 5])
scenario_tree
# get all scenarios
scenario_tree = network_uncertainty.get_scenario_tree()
scenario_tree<jupyter_output><empty_output><jupyter_text>Solve the problem on the scenario tree<jupyter_code>network_solution = network_problem.solve(scenario_tree)
network_solution<jupyter_output>Number of scenario trees: 1 (bushiness: [10.0]) 

Initialize model... Finished. (0.159 sec).
Initialize variables... Finished. (0.030 sec).
Add deterministic constraints at subroot #1... Finished. (0.087 sec).
Define objective function at subtree #1... Finished. (0.067 sec).

Solve scenario tree #1... 
  Precompute variables and parameters... Finished. (0.001 sec).
  Check parameters validity... Finished. (0.000 sec).
  Add random constraints at subtree #1... Finished. (0.091 sec).
  Solve problem at subtree #1... Finished. (0.304 sec).
  Fill scenario tree... Finished. (0.024 sec).
Finished. (0.427 sec).<jupyter_text>Plot optimal solution<jupyter_code>network_solution.plot_network()
network_solution.plot_network(scen_index=0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10986460348162476, 'fraction_numerical': 0.02630560928433269, 'mean_word_length': 3.111287758346582, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '528347', 'license': 'MIT', 'n_tokens_mistral': 878, 'n_tokens_neox': 803, 'n_words': 159, 'path': 'notebooks/Two-Stage Network Design Problem.ipynb', 'repo_name': 'julienkeutchayan/StochOptim', 'size': '2585'}