Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions notebooks/demo_fcsa.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "04c470f6",
"metadata": {},
"source": [
"# Demo for an experiment with FCSA on the SAN problem\n",
"This script is intented to demonstrate an experiment with three different versions of the FCSA solver on the SAN problem. "
]
},
{
"cell_type": "markdown",
"id": "8dffeae6",
"metadata": {},
"source": [
"## Append SimOpt Path\n",
"\n",
"Since the notebook is stored in simopt/notebooks, we need to append the\n",
"parent simopt directory to the system path to import the necessary modules\n",
"later on."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -32,6 +53,16 @@
"from simopt.solvers.fcsa import FCSA"
]
},
{
"cell_type": "markdown",
"id": "dc0e1dfe",
"metadata": {},
"source": [
"## Experiment Configuration Parameters\n",
"\n",
"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. "
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -117,6 +148,16 @@
"post_normalize(experiments, n_postreps)"
]
},
{
"cell_type": "markdown",
"id": "6d42598f",
"metadata": {},
"source": [
"## Plotting Settings\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -185,6 +226,16 @@
")"
]
},
{
"cell_type": "markdown",
"id": "418eefec",
"metadata": {},
"source": [
"## Experiment Configuration Parameters\n",
"\n",
"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. "
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -226,6 +277,16 @@
"post_normalize([experiment2, experiment3], 100)"
]
},
{
"cell_type": "markdown",
"id": "5c9de038",
"metadata": {},
"source": [
"## Plotting Settings\n",
"\n",
"Define the plotting settings for the experiments. Plot terminal objective vs feasibility scatter plot for recommended solutions. "
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
33 changes: 32 additions & 1 deletion notebooks/demo_fcsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.17.3
# jupytext_version: 1.18.1
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # Demo for an experiment with FCSA on the SAN problem
# This script is intented to demonstrate an experiment with three different versions of the FCSA solver on the SAN problem.

# %% [markdown]
# ## Append SimOpt Path
#
# Since the notebook is stored in simopt/notebooks, we need to append the
# parent simopt directory to the system path to import the necessary modules
# later on.

# %%
import sys

Expand All @@ -31,6 +42,11 @@
from simopt.models.san import SANLongestPathStochastic
from simopt.solvers.fcsa import FCSA

# %% [markdown]
# ## Experiment Configuration Parameters
#
# 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.

# %%
fixed_factors = {
"constraint_nodes": [6, 8], # nodes with stochastic constraints
Expand Down Expand Up @@ -88,6 +104,11 @@ def run_experiment(solver, problem, n_macroreps, n_postreps):
experiment1, experiment2, experiment3 = experiments
post_normalize(experiments, n_postreps)

# %% [markdown]
# ## Plotting Settings
#
# 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.

# %%
plot_terminal_progress([experiment1], PlotType.VIOLIN, normalize=False)

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

# %% [markdown]
# ## Experiment Configuration Parameters
#
# 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.

# %%
csa_n = FCSA(
fixed_factors={
Expand Down Expand Up @@ -141,5 +167,10 @@ def run_experiment(solver, problem, n_macroreps, n_postreps):
experiment2, experiment3 = experiments
post_normalize([experiment2, experiment3], 100)

# %% [markdown]
# ## Plotting Settings
#
# Define the plotting settings for the experiments. Plot terminal objective vs feasibility scatter plot for recommended solutions.

# %%
plot_terminal_feasibility([[experiment2], [experiment3]], PlotType.FEASIBILITY_SCATTER)