Skip to content

Commit c5e1240

Browse files
authored
Add descriptions in demo_fcsa.ipynb
1 parent 4cf378e commit c5e1240

File tree

2 files changed

+93
-1
lines changed

2 files changed

+93
-1
lines changed

notebooks/demo_fcsa.ipynb

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "04c470f6",
6+
"metadata": {},
7+
"source": [
8+
"# Demo for an experiment with FCSA on the SAN problem\n",
9+
"This script is intented to demonstrate an experiment with three different versions of the FCSA solver on the SAN problem. "
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"id": "8dffeae6",
15+
"metadata": {},
16+
"source": [
17+
"## Append SimOpt Path\n",
18+
"\n",
19+
"Since the notebook is stored in simopt/notebooks, we need to append the\n",
20+
"parent simopt directory to the system path to import the necessary modules\n",
21+
"later on."
22+
]
23+
},
324
{
425
"cell_type": "code",
526
"execution_count": null,
@@ -32,6 +53,16 @@
3253
"from simopt.solvers.fcsa import FCSA"
3354
]
3455
},
56+
{
57+
"cell_type": "markdown",
58+
"id": "dc0e1dfe",
59+
"metadata": {},
60+
"source": [
61+
"## Experiment Configuration Parameters\n",
62+
"\n",
63+
"Configure 3 versions of the solver: CSA, CSA-N, and FCSA and set problem configuration. Set report_all_solutions = True meaning all incumbent solutions will be reported. "
64+
]
65+
},
3566
{
3667
"cell_type": "code",
3768
"execution_count": null,
@@ -117,6 +148,16 @@
117148
"post_normalize(experiments, n_postreps)"
118149
]
119150
},
151+
{
152+
"cell_type": "markdown",
153+
"id": "6d42598f",
154+
"metadata": {},
155+
"source": [
156+
"## Plotting Settings\n",
157+
"\n",
158+
"Define the plotting settings for the experiments. Plot terminal objective progress, terminal feasibility progress, objective progress curve, and feasiblity progress curve for all incumbent solutions."
159+
]
160+
},
120161
{
121162
"cell_type": "code",
122163
"execution_count": null,
@@ -185,6 +226,16 @@
185226
")"
186227
]
187228
},
229+
{
230+
"cell_type": "markdown",
231+
"id": "418eefec",
232+
"metadata": {},
233+
"source": [
234+
"## Experiment Configuration Parameters\n",
235+
"\n",
236+
"Configure 2 versions of the solver: CSA-N, and FCSA and set problem configuration. Set report_all_solutions = False meaning only recommended solutions will be reported. "
237+
]
238+
},
188239
{
189240
"cell_type": "code",
190241
"execution_count": null,
@@ -226,6 +277,16 @@
226277
"post_normalize([experiment2, experiment3], 100)"
227278
]
228279
},
280+
{
281+
"cell_type": "markdown",
282+
"id": "5c9de038",
283+
"metadata": {},
284+
"source": [
285+
"## Plotting Settings\n",
286+
"\n",
287+
"Define the plotting settings for the experiments. Plot terminal objective vs feasibility scatter plot for recommended solutions. "
288+
]
289+
},
229290
{
230291
"cell_type": "code",
231292
"execution_count": null,

notebooks/demo_fcsa.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@
66
# extension: .py
77
# format_name: percent
88
# format_version: '1.3'
9-
# jupytext_version: 1.17.3
9+
# jupytext_version: 1.18.1
1010
# kernelspec:
1111
# display_name: Python 3 (ipykernel)
1212
# language: python
1313
# name: python3
1414
# ---
1515

16+
# %% [markdown]
17+
# # Demo for an experiment with FCSA on the SAN problem
18+
# This script is intented to demonstrate an experiment with three different versions of the FCSA solver on the SAN problem.
19+
20+
# %% [markdown]
21+
# ## Append SimOpt Path
22+
#
23+
# Since the notebook is stored in simopt/notebooks, we need to append the
24+
# parent simopt directory to the system path to import the necessary modules
25+
# later on.
26+
1627
# %%
1728
import sys
1829

@@ -31,6 +42,11 @@
3142
from simopt.models.san import SANLongestPathStochastic
3243
from simopt.solvers.fcsa import FCSA
3344

45+
# %% [markdown]
46+
# ## Experiment Configuration Parameters
47+
#
48+
# Configure 3 versions of the solver: CSA, CSA-N, and FCSA and set problem configuration. Set report_all_solutions = True meaning all incumbent solutions will be reported.
49+
3450
# %%
3551
fixed_factors = {
3652
"constraint_nodes": [6, 8], # nodes with stochastic constraints
@@ -88,6 +104,11 @@ def run_experiment(solver, problem, n_macroreps, n_postreps):
88104
experiment1, experiment2, experiment3 = experiments
89105
post_normalize(experiments, n_postreps)
90106

107+
# %% [markdown]
108+
# ## Plotting Settings
109+
#
110+
# Define the plotting settings for the experiments. Plot terminal objective progress, terminal feasibility progress, objective progress curve, and feasiblity progress curve for all incumbent solutions.
111+
91112
# %%
92113
plot_terminal_progress([experiment1], PlotType.VIOLIN, normalize=False)
93114

@@ -114,6 +135,11 @@ def run_experiment(solver, problem, n_macroreps, n_postreps):
114135
print_max_hw=False,
115136
)
116137

138+
# %% [markdown]
139+
# ## Experiment Configuration Parameters
140+
#
141+
# Configure 2 versions of the solver: CSA-N, and FCSA and set problem configuration. Set report_all_solutions = False meaning only recommended solutions will be reported.
142+
117143
# %%
118144
csa_n = FCSA(
119145
fixed_factors={
@@ -141,5 +167,10 @@ def run_experiment(solver, problem, n_macroreps, n_postreps):
141167
experiment2, experiment3 = experiments
142168
post_normalize([experiment2, experiment3], 100)
143169

170+
# %% [markdown]
171+
# ## Plotting Settings
172+
#
173+
# Define the plotting settings for the experiments. Plot terminal objective vs feasibility scatter plot for recommended solutions.
174+
144175
# %%
145176
plot_terminal_feasibility([[experiment2], [experiment3]], PlotType.FEASIBILITY_SCATTER)

0 commit comments

Comments
 (0)