simoptlib 1.2.2__tar.gz → 1.2.2.post0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/PKG-INFO +1 -1
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/pyproject.toml +2 -2
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/GUI.py +1 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/experiment_base.py +16 -6
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/gui/main_menu.py +1 -1
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/gui/new_experiment_window.py +8 -1
- simoptlib-1.2.2.post0/simopt/models/ermexample.py +203 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/fcsa.py +7 -3
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simoptlib.egg-info/PKG-INFO +1 -1
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simoptlib.egg-info/SOURCES.txt +1 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/LICENSE +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/README.md +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/setup.cfg +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/__init__.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/__main__.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/base.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/bootstrap.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/curve.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/curve_utils.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/data_farming/data_farming_core.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/data_farming/nolhs.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/data_farming/nolhs_design_table.npz +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/data_farming_base.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/directory.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/experiment/__init__.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/experiment/multiple.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/experiment/post_normalize.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/experiment/single.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/experimental.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/feasibility.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/gui/data_farming_window.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/gui/df_object.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/gui/plot_window.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/gui/toplevel_custom.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/input_models.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/model.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/__init__.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/_ext.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/amusementpark.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/chessmm.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/cntnv.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/contam.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/dualsourcing.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/dynamnews.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/example.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/facilitysizing.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/fixedsan.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/hotel.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/ironore.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/mm1queue.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/network.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/paramesti.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/rmitd.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/san.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/sscont.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/models/tableallocation.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plot_type.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/__init__.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/area_scatterplot.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/feasibility_progress.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/progress_curve.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/solvability_cdf.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/solvability_profile.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/terminal_feasibility.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/terminal_progress.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/terminal_scatterplot.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/plots/utils.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/problem.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/problem_types.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solver.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/__init__.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/adam.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/aloe.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/astrodf.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/neldmd.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/randomsearch.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/spsa.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/strong.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/solvers/utils.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/utils.py +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simopt/utils.pyi +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simoptlib.egg-info/dependency_links.txt +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simoptlib.egg-info/requires.txt +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/simoptlib.egg-info/top_level.txt +0 -0
- {simoptlib-1.2.2 → simoptlib-1.2.2.post0}/test/test_experiments.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simoptlib
|
|
3
|
-
Version: 1.2.2
|
|
3
|
+
Version: 1.2.2.post0
|
|
4
4
|
Summary: A testbed for simulation-optimization experiments.
|
|
5
5
|
Author-email: David Eckman <eckman@tamu.edu>, Shane Henderson <sgh9@cornell.edu>, Sara Shashaani <sshasha2@ncsu.edu>, William Grochocinski <williamgrochocinski@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -12,11 +12,11 @@ exclude = ["build*"]
|
|
|
12
12
|
"simopt.data_farming" = ["*.npz"]
|
|
13
13
|
|
|
14
14
|
[tool.uv.sources]
|
|
15
|
-
simopt-extensions = { git = "https://github.com/cenwangumass/simopt-extensions", rev = "
|
|
15
|
+
simopt-extensions = { git = "https://github.com/cenwangumass/simopt-extensions", rev = "b40a9c8" }
|
|
16
16
|
|
|
17
17
|
[project]
|
|
18
18
|
name = "simoptlib"
|
|
19
|
-
version = "1.2.2"
|
|
19
|
+
version = "1.2.2.post0"
|
|
20
20
|
authors = [
|
|
21
21
|
{ name = "David Eckman", email = "eckman@tamu.edu" },
|
|
22
22
|
{ name = "Shane Henderson", email = "sgh9@cornell.edu" },
|
|
@@ -202,12 +202,22 @@ def create_design_list_from_table(design_table: DataFrame) -> list[dict[str, Any
|
|
|
202
202
|
# Creates dictonary of table to convert values to proper datatypes.
|
|
203
203
|
dp_dict = design_table.to_dict(orient="list")
|
|
204
204
|
|
|
205
|
-
#
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
for
|
|
210
|
-
|
|
205
|
+
# TODO: this is a hack to get the data type of the factors back.
|
|
206
|
+
design_list = []
|
|
207
|
+
for dp in range(len(design_table)):
|
|
208
|
+
config = {}
|
|
209
|
+
for factor in dp_dict:
|
|
210
|
+
key = str(factor)
|
|
211
|
+
raw_value = str(dp_dict[factor][dp])
|
|
212
|
+
try:
|
|
213
|
+
value = literal_eval(raw_value)
|
|
214
|
+
except ValueError:
|
|
215
|
+
# This exception handles the case where the value is a string.
|
|
216
|
+
value = raw_value
|
|
217
|
+
config[key] = value
|
|
218
|
+
design_list.append(config)
|
|
219
|
+
|
|
220
|
+
return design_list
|
|
211
221
|
|
|
212
222
|
|
|
213
223
|
def create_design(
|
|
@@ -9,7 +9,7 @@ from simopt.gui.data_farming_window import DataFarmingWindow
|
|
|
9
9
|
from simopt.gui.new_experiment_window import NewExperimentWindow
|
|
10
10
|
from simopt.gui.toplevel_custom import Toplevel
|
|
11
11
|
|
|
12
|
-
FONT_SCALE: Final[float] = 1
|
|
12
|
+
FONT_SCALE: Final[float] = 1
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class MainMenuWindow(Toplevel):
|
|
@@ -1647,6 +1647,13 @@ class NewExperimentWindow(Toplevel):
|
|
|
1647
1647
|
for factor in model_specifications:
|
|
1648
1648
|
specifications[factor] = model_specifications[factor]
|
|
1649
1649
|
# Convert the specifications to a dictionary of DFFactor objects
|
|
1650
|
+
|
|
1651
|
+
# TODO: This is a hack to remove the step_type and search_direction factors
|
|
1652
|
+
# because str type is not currently supported in the GUI.
|
|
1653
|
+
if isinstance(base_object, Solver) and base_object.class_name_abbr == "FCSA":
|
|
1654
|
+
del specifications["step_type"]
|
|
1655
|
+
del specifications["search_direction"]
|
|
1656
|
+
|
|
1650
1657
|
self.factor_dict = spec_dict_to_df_dict(specifications)
|
|
1651
1658
|
|
|
1652
1659
|
# Add all the column headers
|
|
@@ -2355,7 +2362,7 @@ class NewExperimentWindow(Toplevel):
|
|
|
2355
2362
|
self.__update_experiment_label(experiment_name, "Logging")
|
|
2356
2363
|
# Try to log the experiment
|
|
2357
2364
|
try:
|
|
2358
|
-
self.
|
|
2365
|
+
self.log_results(experiment_name)
|
|
2359
2366
|
# If successful, update the label and button
|
|
2360
2367
|
self.__update_experiment_label(experiment_name, "Logged")
|
|
2361
2368
|
self.__update_action_button(experiment_name, "All Steps\nComplete")
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"""Example problem of deterministic function with noise.
|
|
2
|
+
|
|
3
|
+
Simulate a synthetic problem with a deterministic objective function
|
|
4
|
+
evaluated with noise.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Annotated, ClassVar
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
from pydantic import BaseModel, Field
|
|
13
|
+
|
|
14
|
+
from mrg32k3a.mrg32k3a import MRG32k3a
|
|
15
|
+
from simopt.base import (
|
|
16
|
+
ConstraintType,
|
|
17
|
+
Model,
|
|
18
|
+
Objective,
|
|
19
|
+
Problem,
|
|
20
|
+
RepResult,
|
|
21
|
+
VariableType,
|
|
22
|
+
)
|
|
23
|
+
from simopt.input_models import InputModel
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ERMExampleModelConfig(BaseModel):
|
|
27
|
+
"""Configuration model for ERMExample simulation.
|
|
28
|
+
|
|
29
|
+
An empirical risk minimization model for linear regression.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
beta: Annotated[
|
|
33
|
+
tuple[float, ...],
|
|
34
|
+
Field(
|
|
35
|
+
default=(0.0, 0.0),
|
|
36
|
+
description="(intercept, slope) coefficients",
|
|
37
|
+
),
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class ERMExampleProblemConfig(BaseModel):
|
|
42
|
+
"""Configuration model for ERMExample Problem.
|
|
43
|
+
|
|
44
|
+
Base class to implement simulation-optimization problems.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
initial_solution: Annotated[
|
|
48
|
+
tuple[float, ...],
|
|
49
|
+
Field(
|
|
50
|
+
default=(0.0, 0.0),
|
|
51
|
+
description="initial solution",
|
|
52
|
+
),
|
|
53
|
+
]
|
|
54
|
+
budget: Annotated[
|
|
55
|
+
int,
|
|
56
|
+
Field(
|
|
57
|
+
default=1000,
|
|
58
|
+
description="max # of replications for a solver to take",
|
|
59
|
+
gt=0,
|
|
60
|
+
json_schema_extra={"isDatafarmable": False},
|
|
61
|
+
),
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class FileInputModel(InputModel):
|
|
66
|
+
def __init__(self, filename):
|
|
67
|
+
self.data = np.load(filename)
|
|
68
|
+
|
|
69
|
+
def set_rng(self, rng: random.Random) -> None:
|
|
70
|
+
self.rng = rng
|
|
71
|
+
|
|
72
|
+
def unset_rng(self) -> None:
|
|
73
|
+
self.rng = None
|
|
74
|
+
|
|
75
|
+
def random(self) -> float:
|
|
76
|
+
n_rows = np.shape(self.data)[0]
|
|
77
|
+
resample_idx = np.random.choice(n_rows, size=1, replace=True)
|
|
78
|
+
resample_x = self.data[resample_idx, 0].item()
|
|
79
|
+
resample_y = self.data[resample_idx, 1].item()
|
|
80
|
+
return resample_x, resample_y
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ERMExampleModel(Model):
|
|
84
|
+
"""A model that for the empirical risk of a linear regression model."""
|
|
85
|
+
|
|
86
|
+
class_name_abbr: ClassVar[str] = "ERMEXAMPLE"
|
|
87
|
+
class_name: ClassVar[str] = "Linear Regression ERM"
|
|
88
|
+
config_class: ClassVar[type[BaseModel]] = ERMExampleModelConfig
|
|
89
|
+
n_rngs: ClassVar[int] = 1
|
|
90
|
+
n_responses: ClassVar[int] = 1
|
|
91
|
+
|
|
92
|
+
def __init__(self, fixed_factors: dict | None = None) -> None:
|
|
93
|
+
"""Initialize the model.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
fixed_factors (dict | None): fixed factors of the model.
|
|
97
|
+
If None, use default values.
|
|
98
|
+
"""
|
|
99
|
+
# Let the base class handle default arguments.
|
|
100
|
+
super().__init__(fixed_factors)
|
|
101
|
+
self.resample_model = FileInputModel("workshop/erm_data.npy")
|
|
102
|
+
|
|
103
|
+
def before_replicate(self, rng_list: list[MRG32k3a]) -> None: # noqa: D102
|
|
104
|
+
self.resample_model.set_rng(rng_list[0])
|
|
105
|
+
|
|
106
|
+
def replicate(self) -> tuple[dict, dict]:
|
|
107
|
+
"""Evaluate the squared error loss of a single observation.
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
tuple[dict, dict]: A tuple containing:
|
|
111
|
+
- responses (dict): Performance measures of interest, including:
|
|
112
|
+
- "sq_error_loss": Squared error loss of a single observation.
|
|
113
|
+
- gradients (dict): A dictionary of gradient estimates for
|
|
114
|
+
each response.
|
|
115
|
+
"""
|
|
116
|
+
beta0, beta1 = self.factors["beta"]
|
|
117
|
+
x, y = self.resample_model.random()
|
|
118
|
+
sq_error_loss = (y - beta0 - beta1 * x) ** 2
|
|
119
|
+
error_loss = y - beta0 - beta1 * x
|
|
120
|
+
# gradients wrt beta0 and beta1
|
|
121
|
+
grad_sq_error_loss = (-2 * error_loss, -2 * x * error_loss)
|
|
122
|
+
|
|
123
|
+
# Compose responses and gradients.
|
|
124
|
+
responses = {"sq_error_loss": sq_error_loss}
|
|
125
|
+
gradients = {"sq_error_loss": {"beta": grad_sq_error_loss}}
|
|
126
|
+
return responses, gradients
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class ERMExampleProblem(Problem):
|
|
130
|
+
"""Base class to implement simulation-optimization problems."""
|
|
131
|
+
|
|
132
|
+
class_name_abbr: ClassVar[str] = "ERM-EXAMPLE-1"
|
|
133
|
+
class_name: ClassVar[str] = "Min Empirical Risk"
|
|
134
|
+
config_class: ClassVar[type[BaseModel]] = ERMExampleProblemConfig
|
|
135
|
+
model_class: ClassVar[type[Model]] = ERMExampleModel
|
|
136
|
+
n_objectives: ClassVar[int] = 1
|
|
137
|
+
n_stochastic_constraints: ClassVar[int] = 0
|
|
138
|
+
minmax: ClassVar[tuple[int, ...]] = (-1,)
|
|
139
|
+
constraint_type: ClassVar[ConstraintType] = ConstraintType.UNCONSTRAINED
|
|
140
|
+
variable_type: ClassVar[VariableType] = VariableType.CONTINUOUS
|
|
141
|
+
gradient_available: ClassVar[bool] = True
|
|
142
|
+
model_default_factors: ClassVar[dict] = {}
|
|
143
|
+
model_decision_factors: ClassVar[set[str]] = {"beta"}
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def optimal_value(self) -> float | None: # noqa: D102
|
|
147
|
+
# Compute optimal beta0 and beta1
|
|
148
|
+
all_data = np.load("workshop/erm_data.npy")
|
|
149
|
+
x = all_data[:, 0]
|
|
150
|
+
y = all_data[:, 1]
|
|
151
|
+
optbeta1, optbeta0 = np.polyfit(x, y, 1)
|
|
152
|
+
opttrainingmse = np.mean(
|
|
153
|
+
[(yy - optbeta0 - optbeta1 * xx) ** 2 for (xx, yy) in zip(x, y)]
|
|
154
|
+
)
|
|
155
|
+
return opttrainingmse
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def optimal_solution(self) -> tuple | None: # noqa: D102
|
|
159
|
+
# Compute optimal beta0 and beta1
|
|
160
|
+
all_data = np.load("workshop/erm_data.npy")
|
|
161
|
+
x = all_data[:, 0]
|
|
162
|
+
y = all_data[:, 1]
|
|
163
|
+
optbeta1, optbeta0 = np.polyfit(x, y, 1)
|
|
164
|
+
return (optbeta0, optbeta1)
|
|
165
|
+
|
|
166
|
+
@property
|
|
167
|
+
def dim(self) -> int: # noqa: D102
|
|
168
|
+
return 2
|
|
169
|
+
|
|
170
|
+
@property
|
|
171
|
+
def lower_bounds(self) -> tuple: # noqa: D102
|
|
172
|
+
return (-np.inf,) * self.dim
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def upper_bounds(self) -> tuple: # noqa: D102
|
|
176
|
+
return (np.inf,) * self.dim
|
|
177
|
+
|
|
178
|
+
def vector_to_factor_dict(self, vector: tuple) -> dict: # noqa: D102
|
|
179
|
+
return {"beta": vector[:]}
|
|
180
|
+
|
|
181
|
+
def factor_dict_to_vector(self, factor_dict: dict) -> tuple: # noqa: D102
|
|
182
|
+
return tuple(factor_dict["beta"])
|
|
183
|
+
|
|
184
|
+
def replicate(self, _x: tuple) -> RepResult: # noqa: D102
|
|
185
|
+
responses, gradients = self.model.replicate()
|
|
186
|
+
objectives = [
|
|
187
|
+
Objective(
|
|
188
|
+
stochastic=responses["sq_error_loss"],
|
|
189
|
+
stochastic_gradients=gradients["sq_error_loss"]["beta"],
|
|
190
|
+
)
|
|
191
|
+
]
|
|
192
|
+
return RepResult(objectives=objectives)
|
|
193
|
+
|
|
194
|
+
def get_random_solution(self, rand_sol_rng: MRG32k3a) -> tuple: # noqa: D102
|
|
195
|
+
# beta = tuple([rand_sol_rng.uniform(-2, 2) for _ in range(self.dim)])
|
|
196
|
+
beta = tuple(
|
|
197
|
+
rand_sol_rng.mvnormalvariate(
|
|
198
|
+
mean_vec=[1.0] * self.dim,
|
|
199
|
+
cov=np.eye(self.dim).tolist(),
|
|
200
|
+
factorized=False,
|
|
201
|
+
)
|
|
202
|
+
)
|
|
203
|
+
return beta
|
|
@@ -5,7 +5,7 @@ Stochastically Constrained Simulation Optimization Problems' by Felice, N.,
|
|
|
5
5
|
D. J. Eckman, S. G. Henderson, and S. Shashaani
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from typing import Annotated, ClassVar
|
|
8
|
+
from typing import Annotated, ClassVar
|
|
9
9
|
|
|
10
10
|
import cvxpy as cp
|
|
11
11
|
import numpy as np
|
|
@@ -44,7 +44,9 @@ class FCSAConfig(SolverConfig):
|
|
|
44
44
|
),
|
|
45
45
|
]
|
|
46
46
|
step_type: Annotated[
|
|
47
|
-
|
|
47
|
+
# TODO: change back when the old GUI is removed
|
|
48
|
+
# Literal["const", "decay"],
|
|
49
|
+
str,
|
|
48
50
|
Field(default="const", description="constant or decaying step size?"),
|
|
49
51
|
]
|
|
50
52
|
step_mult: Annotated[
|
|
@@ -60,7 +62,9 @@ class FCSAConfig(SolverConfig):
|
|
|
60
62
|
Field(default=0.01, ge=0, description="tolerance function"),
|
|
61
63
|
]
|
|
62
64
|
search_direction: Annotated[
|
|
63
|
-
|
|
65
|
+
# TODO: change back when the old GUI is removed
|
|
66
|
+
# Literal["FCSA", "CSA-N", "CSA"],
|
|
67
|
+
str,
|
|
64
68
|
Field(
|
|
65
69
|
default="FCSA",
|
|
66
70
|
description=(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simoptlib
|
|
3
|
-
Version: 1.2.2
|
|
3
|
+
Version: 1.2.2.post0
|
|
4
4
|
Summary: A testbed for simulation-optimization experiments.
|
|
5
5
|
Author-email: David Eckman <eckman@tamu.edu>, Shane Henderson <sgh9@cornell.edu>, Sara Shashaani <sshasha2@ncsu.edu>, William Grochocinski <williamgrochocinski@gmail.com>
|
|
6
6
|
License: MIT License
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|