Skip to content

Commit 61c8358

Browse files
committed
clarified role of problem/solver config classes
1 parent 73f7d01 commit 61c8358

2 files changed

Lines changed: 47 additions & 39 deletions

File tree

notebooks/demo_san-sscont-ironorecont_experiment.ipynb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@
7878
"metadata": {},
7979
"outputs": [],
8080
"source": [
81-
"# Classes for Problem and Solver info\n",
82-
"# These don't need modified, they're just used to organize the problem and solver info.\n",
83-
"class Problem:\n",
84-
" \"\"\"Problem class to hold problem information.\"\"\"\n",
81+
"# Classes for Problem and Solver config info\n",
82+
"# These don't need modified\n",
83+
"class ProblemConfig:\n",
84+
" \"\"\"Class to hold problem config information.\"\"\"\n",
8585
"\n",
8686
" def __init__(\n",
8787
" self,\n",
@@ -97,8 +97,8 @@
9797
" self.model_fixed_factors = model_fixed_factors if model_fixed_factors else {}\n",
9898
"\n",
9999
"\n",
100-
"class Solver:\n",
101-
" \"\"\"Solver class to hold solver information.\"\"\"\n",
100+
"class SolverConfig:\n",
101+
" \"\"\"Class to hold solver config information.\"\"\"\n",
102102
"\n",
103103
" def __init__(\n",
104104
" self, name: str, rename: str | None = None, fixed_factors: dict | None = None\n",
@@ -119,16 +119,16 @@
119119
"from simopt.experiment_base import ProblemSolver, post_normalize\n",
120120
"\n",
121121
"\n",
122-
"# Function to run an experiment with the given problems and solvers.\n",
122+
"# Function to run an experiment with the given problem and solver configs.\n",
123123
"def run_experiment(\n",
124-
" problems: list[Problem],\n",
125-
" solvers: list[Solver],\n",
124+
" problems: list[ProblemConfig],\n",
125+
" solvers: list[SolverConfig],\n",
126126
") -> list[list[ProblemSolver]]:\n",
127-
" \"\"\"Run the Experiment for the given problems and solvers.\n",
127+
" \"\"\"Run an experiment using the provided configurations.\n",
128128
"\n",
129129
" Args:\n",
130-
" problems: List of Problem instances.\n",
131-
" solvers: List of Solver instances.\n",
130+
" problems: List of ProblemConfig instances.\n",
131+
" solvers: List of SolverConfig instances.\n",
132132
"\n",
133133
" Returns:\n",
134134
" List[list[ProblemSolver]]: A list of lists containing ProblemSolver instances,\n",
@@ -192,11 +192,15 @@
192192
"# Includes two versions of random search with varying sample sizes.\n",
193193
"# The rename will be used in the plots to differentiate them.\n",
194194
"solvers = [\n",
195-
" Solver(name=\"RNDSRCH\", rename=\"RNDSRCH_ss=10\", fixed_factors={\"sample_size\": 10}),\n",
196-
" Solver(name=\"RNDSRCH\", rename=\"RNDSRCH_ss=50\", fixed_factors={\"sample_size\": 50}),\n",
197-
" Solver(name=\"ASTRODF\"),\n",
198-
" Solver(name=\"NELDMD\"),\n",
199-
" Solver(name=\"STRONG\"),\n",
195+
" SolverConfig(\n",
196+
" name=\"RNDSRCH\", rename=\"RNDSRCH_ss=10\", fixed_factors={\"sample_size\": 10}\n",
197+
" ),\n",
198+
" SolverConfig(\n",
199+
" name=\"RNDSRCH\", rename=\"RNDSRCH_ss=50\", fixed_factors={\"sample_size\": 50}\n",
200+
" ),\n",
201+
" SolverConfig(name=\"ASTRODF\"),\n",
202+
" SolverConfig(name=\"NELDMD\"),\n",
203+
" SolverConfig(name=\"STRONG\"),\n",
200204
"]"
201205
]
202206
},
@@ -235,7 +239,7 @@
235239
"\n",
236240
"# Create all the problem variants.\n",
237241
"SAN_problems = [\n",
238-
" Problem(\n",
242+
" ProblemConfig(\n",
239243
" name=\"SAN-1\",\n",
240244
" rename=f\"SAN-1_rc={costs}\",\n",
241245
" fixed_factors={\n",
@@ -267,7 +271,7 @@
267271
"\n",
268272
"# Create all the problem variants.\n",
269273
"SSCONT_problems = [\n",
270-
" Problem(\n",
274+
" ProblemConfig(\n",
271275
" name=\"SSCONT-1\",\n",
272276
" rename=f\"SSCONT-1_dm={dm}_lm={lm}\",\n",
273277
" fixed_factors={\"budget\": 1000},\n",
@@ -302,7 +306,7 @@
302306
"\n",
303307
"# Create all the problem variants.\n",
304308
"IRONORECONT_problems = [\n",
305-
" Problem(\n",
309+
" ProblemConfig(\n",
306310
" name=\"IRONORECONT-1\",\n",
307311
" rename=f\"IRONORECONT-1_sd={sd}_hc={hc}_inv={inv}\",\n",
308312
" fixed_factors={\"budget\": 1000},\n",
@@ -574,7 +578,7 @@
574578
"name": "python",
575579
"nbconvert_exporter": "python",
576580
"pygments_lexer": "ipython3",
577-
"version": "3.13.3"
581+
"version": "3.13.5"
578582
}
579583
},
580584
"nbformat": 4,

notebooks/demo_sscont_experiment.ipynb

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
"metadata": {},
7575
"outputs": [],
7676
"source": [
77-
"# Classes for Problem and Solver info\n",
78-
"# These don't need modified, they're just used to organize the problem and solver info.\n",
79-
"class Problem:\n",
80-
" \"\"\"Problem class to hold problem information.\"\"\"\n",
77+
"# Classes for Problem and Solver config info\n",
78+
"# These don't need modified\n",
79+
"class ProblemConfig:\n",
80+
" \"\"\"Class to hold problem config information.\"\"\"\n",
8181
"\n",
8282
" def __init__(\n",
8383
" self,\n",
@@ -93,8 +93,8 @@
9393
" self.model_fixed_factors = model_fixed_factors if model_fixed_factors else {}\n",
9494
"\n",
9595
"\n",
96-
"class Solver:\n",
97-
" \"\"\"Solver class to hold solver information.\"\"\"\n",
96+
"class SolverConfig:\n",
97+
" \"\"\"Class to hold solver config information.\"\"\"\n",
9898
"\n",
9999
" def __init__(\n",
100100
" self, name: str, rename: str | None = None, fixed_factors: dict | None = None\n",
@@ -115,16 +115,16 @@
115115
"from simopt.experiment_base import ProblemSolver, post_normalize\n",
116116
"\n",
117117
"\n",
118-
"# Function to run an experiment with the given problems and solvers.\n",
118+
"# Function to run an experiment with the given problem and solver configs.\n",
119119
"def run_experiment(\n",
120-
" problems: list[Problem],\n",
121-
" solvers: list[Solver],\n",
120+
" problems: list[ProblemConfig],\n",
121+
" solvers: list[SolverConfig],\n",
122122
") -> list[list[ProblemSolver]]:\n",
123-
" \"\"\"Run the Experiment for the given problems and solvers.\n",
123+
" \"\"\"Run an experiment using the provided configurations.\n",
124124
"\n",
125125
" Args:\n",
126-
" problems: List of Problem instances.\n",
127-
" solvers: List of Solver instances.\n",
126+
" problems: List of ProblemConfig instances.\n",
127+
" solvers: List of SolverConfig instances.\n",
128128
"\n",
129129
" Returns:\n",
130130
" List[list[ProblemSolver]]: A list of lists containing ProblemSolver instances,\n",
@@ -188,11 +188,15 @@
188188
"# Includes two versions of random search with varying sample sizes.\n",
189189
"# The rename will be used in the plots to differentiate them.\n",
190190
"solvers = [\n",
191-
" Solver(name=\"RNDSRCH\", rename=\"RNDSRCH_ss=10\", fixed_factors={\"sample_size\": 10}),\n",
192-
" Solver(name=\"RNDSRCH\", rename=\"RNDSRCH_ss=50\", fixed_factors={\"sample_size\": 50}),\n",
193-
" Solver(name=\"ASTRODF\"),\n",
194-
" Solver(name=\"NELDMD\"),\n",
195-
" Solver(name=\"STRONG\"),\n",
191+
" SolverConfig(\n",
192+
" name=\"RNDSRCH\", rename=\"RNDSRCH_ss=10\", fixed_factors={\"sample_size\": 10}\n",
193+
" ),\n",
194+
" SolverConfig(\n",
195+
" name=\"RNDSRCH\", rename=\"RNDSRCH_ss=50\", fixed_factors={\"sample_size\": 50}\n",
196+
" ),\n",
197+
" SolverConfig(name=\"ASTRODF\"),\n",
198+
" SolverConfig(name=\"NELDMD\"),\n",
199+
" SolverConfig(name=\"STRONG\"),\n",
196200
"]"
197201
]
198202
},
@@ -209,7 +213,7 @@
209213
"\n",
210214
"# Create all the problem variants.\n",
211215
"SSCONT_problems = [\n",
212-
" Problem(\n",
216+
" ProblemConfig(\n",
213217
" name=\"SSCONT-1\",\n",
214218
" rename=f\"SSCONT-1_dm={dm}_lm={lm}\",\n",
215219
" fixed_factors={\"budget\": 1000},\n",

0 commit comments

Comments
 (0)