simoptlib 1.1.0__tar.gz → 1.1.1__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.
Files changed (51) hide show
  1. {simoptlib-1.1.0/simoptlib.egg-info → simoptlib-1.1.1}/PKG-INFO +2 -2
  2. {simoptlib-1.1.0 → simoptlib-1.1.1}/README.md +1 -1
  3. {simoptlib-1.1.0 → simoptlib-1.1.1}/pyproject.toml +1 -1
  4. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/experiment_base.py +14 -14
  5. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/gui/data_farming_window.py +20 -6
  6. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/gui/df_object.py +57 -2
  7. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/gui/new_experiment_window.py +189 -67
  8. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/amusementpark.py +2 -0
  9. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/chessmm.py +1 -0
  10. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/cntnv.py +1 -0
  11. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/contam.py +1 -0
  12. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/dualsourcing.py +2 -0
  13. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/dynamnews.py +1 -0
  14. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/example.py +1 -0
  15. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/facilitysizing.py +2 -0
  16. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/fixedsan.py +1 -0
  17. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/hotel.py +1 -0
  18. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/ironore.py +2 -0
  19. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/mm1queue.py +1 -0
  20. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/network.py +1 -0
  21. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/paramesti.py +1 -0
  22. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/rmitd.py +1 -0
  23. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/san.py +2 -0
  24. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/sscont.py +3 -0
  25. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/tableallocation.py +1 -0
  26. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/solvers/astrodf.py +52 -43
  27. {simoptlib-1.1.0 → simoptlib-1.1.1/simoptlib.egg-info}/PKG-INFO +2 -2
  28. {simoptlib-1.1.0 → simoptlib-1.1.1}/LICENSE +0 -0
  29. {simoptlib-1.1.0 → simoptlib-1.1.1}/setup.cfg +0 -0
  30. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/GUI.py +0 -0
  31. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/__init__.py +0 -0
  32. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/__main__.py +0 -0
  33. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/base.py +0 -0
  34. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/data_farming_base.py +0 -0
  35. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/directory.py +0 -0
  36. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/gui/experiment_window.py +0 -0
  37. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/gui/main_menu.py +0 -0
  38. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/gui/plot_window.py +0 -0
  39. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/gui/toplevel_custom.py +0 -0
  40. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/models/__init__.py +0 -0
  41. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/solvers/__init__.py +0 -0
  42. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/solvers/adam.py +0 -0
  43. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/solvers/aloe.py +0 -0
  44. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/solvers/neldmd.py +0 -0
  45. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/solvers/randomsearch.py +0 -0
  46. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/solvers/spsa.py +0 -0
  47. {simoptlib-1.1.0 → simoptlib-1.1.1}/simopt/solvers/strong.py +0 -0
  48. {simoptlib-1.1.0 → simoptlib-1.1.1}/simoptlib.egg-info/SOURCES.txt +0 -0
  49. {simoptlib-1.1.0 → simoptlib-1.1.1}/simoptlib.egg-info/dependency_links.txt +0 -0
  50. {simoptlib-1.1.0 → simoptlib-1.1.1}/simoptlib.egg-info/requires.txt +0 -0
  51. {simoptlib-1.1.0 → simoptlib-1.1.1}/simoptlib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simoptlib
3
- Version: 1.1.0
3
+ Version: 1.1.1
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 <wagrocho@ncsu.edu>
6
6
  License: MIT License
@@ -76,7 +76,7 @@ Full documentation for the source code can be found on our **[readthedocs page](
76
76
  - Python >= 3.8
77
77
  - To check your Python version, open a terminal and run `python --version`. If you see a message along the lines of `Command not found`, then you likely don't have Python installed. If you know you have it installed but are getting a `Command not found` error, then you may need to [add Python to your PATH](https://realpython.com/add-python-to-path/).
78
78
  - For new installs, [Miniconda or Anaconda](https://www.anaconda.com/download) is recommended ([read about the differences between Miniconda and Anaconda](https://docs.anaconda.com/distro-or-miniconda/)). If you already have a compatible IDE (such as VS Code), we've found that Miniconda will work fine at 1/10 of the size of Anaconda. It is ***highly recommended*** to check the box during installation to add Python/Miniconda/Anaconda to your system PATH.
79
- - Ruby >= 3.0 (required for datafarming)
79
+ - Ruby >= 2.5 (required for datafarming)
80
80
  - Included on MacOS, but Windows users will need to grab it from [here](https://rubyinstaller.org/).
81
81
  - `datafarming` gem < 2.0 (required for datafarming)
82
82
  - This can be installed via `gem install datafarming -v 1.4` once Ruby is installed/configured.
@@ -34,7 +34,7 @@ Full documentation for the source code can be found on our **[readthedocs page](
34
34
  - Python >= 3.8
35
35
  - To check your Python version, open a terminal and run `python --version`. If you see a message along the lines of `Command not found`, then you likely don't have Python installed. If you know you have it installed but are getting a `Command not found` error, then you may need to [add Python to your PATH](https://realpython.com/add-python-to-path/).
36
36
  - For new installs, [Miniconda or Anaconda](https://www.anaconda.com/download) is recommended ([read about the differences between Miniconda and Anaconda](https://docs.anaconda.com/distro-or-miniconda/)). If you already have a compatible IDE (such as VS Code), we've found that Miniconda will work fine at 1/10 of the size of Anaconda. It is ***highly recommended*** to check the box during installation to add Python/Miniconda/Anaconda to your system PATH.
37
- - Ruby >= 3.0 (required for datafarming)
37
+ - Ruby >= 2.5 (required for datafarming)
38
38
  - Included on MacOS, but Windows users will need to grab it from [here](https://rubyinstaller.org/).
39
39
  - `datafarming` gem < 2.0 (required for datafarming)
40
40
  - This can be installed via `gem install datafarming -v 1.4` once Ruby is installed/configured.
@@ -7,7 +7,7 @@ packages = ["simopt", "simopt.gui", "simopt.models", "simopt.solvers"]
7
7
 
8
8
  [project]
9
9
  name = "simoptlib"
10
- version = "1.1.0"
10
+ version = "1.1.1"
11
11
  authors = [
12
12
  { name="David Eckman", email="eckman@tamu.edu" },
13
13
  { name="Shane Henderson", email="sgh9@cornell.edu" },
@@ -318,7 +318,7 @@ def mean_of_curves(curves: list[Curve]) -> Curve:
318
318
  float(np.mean([curve.lookup(float(x_val)) for curve in curves]))
319
319
  for x_val in unique_x_vals
320
320
  ]
321
- mean_curve = Curve(x_vals=unique_x_vals.tolist(), y_vals=mean_y_vals)
321
+ mean_curve = Curve(x_vals=unique_x_vals.tolist(), y_vals=mean_y_vals) # type: ignore
322
322
  return mean_curve
323
323
 
324
324
 
@@ -362,7 +362,8 @@ def quantile_of_curves(curves: list[Curve], beta: float) -> Curve:
362
362
  for x_val in unique_x_vals
363
363
  ]
364
364
  quantile_curve = Curve(
365
- x_vals=unique_x_vals.tolist(), y_vals=quantile_y_vals
365
+ x_vals=unique_x_vals.tolist(), # type: ignore
366
+ y_vals=quantile_y_vals,
366
367
  )
367
368
  return quantile_curve
368
369
 
@@ -1105,7 +1106,7 @@ class ProblemSolver:
1105
1106
  self.solver.attach_rngs(rng_list)
1106
1107
 
1107
1108
  # Start a timer
1108
- self.function_start = time.time()
1109
+ function_start = time.time()
1109
1110
 
1110
1111
  print("Starting macroreplications in parallel")
1111
1112
  with Pool() as process_pool:
@@ -1118,6 +1119,10 @@ class ProblemSolver:
1118
1119
  # Update status bar here
1119
1120
  result.wait(1)
1120
1121
 
1122
+ print(
1123
+ f"Finished running {n_macroreps} macroreplications in {round(time.time() - function_start, 3)} seconds."
1124
+ )
1125
+
1121
1126
  # Grab all the data out of the result
1122
1127
  for mrep in range(n_macroreps):
1123
1128
  (
@@ -1125,12 +1130,6 @@ class ProblemSolver:
1125
1130
  self.all_intermediate_budgets[mrep],
1126
1131
  self.timings[mrep],
1127
1132
  ) = result.get()[mrep]
1128
- print(
1129
- f"Finished running {n_macroreps} macroreplications in {round(time.time() - self.function_start, 3)} seconds."
1130
- )
1131
-
1132
- # Delete stuff we don't need to save
1133
- del self.function_start
1134
1133
 
1135
1134
  self.has_run = True
1136
1135
  self.has_postreplicated = False
@@ -6519,7 +6518,7 @@ def validate_ruby_install() -> bool:
6519
6518
 
6520
6519
  # If we're here, Ruby is not installed on the system or on WSL
6521
6520
  # Raise an exception
6522
- error_msg = "Ruby is not installed on the system or is not on the system path. Please install Ruby or add it to the system path."
6521
+ error_msg = "Ruby is not installed on the system or is not on the system path. Please install Ruby or add it to the system path. If you just installed Ruby, you may need to restart your terminal/IDE."
6523
6522
  raise Exception(error_msg)
6524
6523
 
6525
6524
 
@@ -6595,10 +6594,11 @@ def validate_gem_install(design_type: str, installed_via_wsl: bool) -> str:
6595
6594
  )
6596
6595
  error_msg += f" This can be done by running: `{command_prefix}gem install datafarming -v 1.4{command_suffix}`"
6597
6596
  raise Exception(error_msg)
6598
- # Not totally sure what error to catch here, in theory it should only
6599
- # ever error due to the datafarming gem not being installed or having
6600
- # an incompatible version
6601
- error_msg = "An error occurred while checking if the datafarming gem is installed."
6597
+ # We get here if the gem is installed and the version is correct, but
6598
+ # we still can't run the stack script. This is likely due to the gem
6599
+ # not being in the system path. We'll let the user know that they need
6600
+ # to restart their terminal/IDE.
6601
+ error_msg = "Ruby was able to detect the datafarming gem, but was unable to run the stack script. If you just installed the datafarming gem, it may be necessary to restart your terminal/IDE."
6602
6602
  raise Exception(error_msg)
6603
6603
  else:
6604
6604
  error_msg = "Invalid design type."
@@ -684,7 +684,10 @@ class DataFarmingWindow(Toplevel):
684
684
  ].get("description")
685
685
  self.factor_default = self.model_object.specifications[factor].get(
686
686
  "default"
687
+
687
688
  )
689
+ self.factor_isDatafarmable = self.model_object.specifications[factor].get(
690
+ "isDatafarmable")
688
691
 
689
692
  # Values to help with formatting
690
693
  entry_width = 10
@@ -707,7 +710,7 @@ class DataFarmingWindow(Toplevel):
707
710
  padx=10,
708
711
  )
709
712
 
710
- if self.factor_datatype is float:
713
+ if self.factor_datatype is float and self.factor_isDatafarmable is not False:
711
714
  self.factors_frame.grid_rowconfigure(
712
715
  self.factor_que_length, weight=1
713
716
  )
@@ -842,7 +845,7 @@ class DataFarmingWindow(Toplevel):
842
845
 
843
846
  self.factor_que_length += 1
844
847
 
845
- elif self.factor_datatype is int:
848
+ elif self.factor_datatype is int and self.factor_isDatafarmable is not False:
846
849
  self.factors_frame.grid_rowconfigure(
847
850
  self.factor_que_length, weight=1
848
851
  )
@@ -947,12 +950,17 @@ class DataFarmingWindow(Toplevel):
947
950
 
948
951
  self.factor_que_length += 1
949
952
 
950
- elif self.factor_datatype is list:
953
+ elif self.factor_datatype is list or self.factor_isDatafarmable is False:
951
954
  self.factors_frame.grid_rowconfigure(
952
955
  self.factor_que_length, weight=1
953
956
  )
954
957
 
955
- self.str_type = "list"
958
+ if self.factor_datatype is list:
959
+ self.str_type = "list"
960
+ elif self.factor_datatype is int:
961
+ self.str_type = "int"
962
+ elif self.factor_datatype is float:
963
+ self.str_type = "float"
956
964
 
957
965
  # Add label for factor type
958
966
  self.factortype_label = tk.Label(
@@ -1211,6 +1219,9 @@ class DataFarmingWindow(Toplevel):
1211
1219
  factor_datatype = self.model_object.specifications[factor].get(
1212
1220
  "datatype"
1213
1221
  )
1222
+ factor_isDatafarmable = self.model_object.specifications[factor].get(
1223
+ "isDatafarmable"
1224
+ )
1214
1225
  factor_include = check_values[factor_index]
1215
1226
 
1216
1227
  # get user inputs for design factors
@@ -1218,7 +1229,7 @@ class DataFarmingWindow(Toplevel):
1218
1229
  if factor_include:
1219
1230
  self.factor_names.append(factor)
1220
1231
 
1221
- if factor_datatype in (float, int):
1232
+ if factor_datatype in (float, int) and factor_isDatafarmable is not False:
1222
1233
  factor_min = str(min_values[maxmin_index])
1223
1234
  factor_max = str(max_values[maxmin_index])
1224
1235
  maxmin_index += 1
@@ -1352,9 +1363,12 @@ class DataFarmingWindow(Toplevel):
1352
1363
  self.factor_default = self.model_object.specifications[factor].get(
1353
1364
  "default"
1354
1365
  )
1366
+ self.factor_isDatafarmable = self.model_object.specifications[factor].get(
1367
+ "isDatafarmable"
1368
+ )
1355
1369
 
1356
1370
  # Disable / enable experiment option widgets depending on factor type
1357
- if self.factor_datatype in (int, float):
1371
+ if self.factor_datatype in (int, float) and self.factor_isDatafarmable is not False:
1358
1372
  self.current_min_entry = self.min_widgets[factor]
1359
1373
  self.current_max_entry = self.max_widgets[factor]
1360
1374
 
@@ -491,6 +491,54 @@ class DFInteger(DFFactor):
491
491
  self.__maximum = tk.IntVar(value=default)
492
492
 
493
493
 
494
+ class DFIntegerNonDatafarmable(DFFactor):
495
+ """Class to store non-datafarmable integer factors for problems and solvers."""
496
+
497
+ @property
498
+ def type(self) -> tk.StringVar:
499
+ """The type of the factor."""
500
+ return tk.StringVar(value="int")
501
+
502
+ @property
503
+ def default(self) -> tk.IntVar:
504
+ """The default value of the factor."""
505
+ return self.__default
506
+
507
+ @default.setter
508
+ def default(self, default: tk.Variable) -> None:
509
+ if not isinstance(default, tk.IntVar):
510
+ error_msg = "Default value must be an IntVar."
511
+ raise ValueError(error_msg)
512
+ self.__default = default
513
+
514
+ @property
515
+ def default_eval(self) -> int:
516
+ """Evaluated default value of the factor."""
517
+ try:
518
+ return int(self.default.get())
519
+ except ValueError:
520
+ raise ValueError(
521
+ f"Default value for {self.name.get()} must be an integer."
522
+ ) from None
523
+
524
+ def __init__(self, name: str, description: str, default: int) -> None:
525
+ """Initialize the
526
+
527
+ Parameters
528
+ ----------
529
+ name : str
530
+ The name of the factor
531
+ description : str
532
+ The description of the factor
533
+ default : list
534
+ The default value of the factor
535
+
536
+ """
537
+ appended_description = "[Non-Datafarmable] " + description
538
+ super().__init__(name, appended_description)
539
+ self.__default = tk.IntVar(value=default)
540
+
541
+
494
542
  class DFFloat(DFFactor):
495
543
  """Class to store float factors for problems and solvers."""
496
544
 
@@ -748,8 +796,15 @@ def spec_to_df(spec_name: str, spec: dict) -> DFFactor:
748
796
  list: DFList,
749
797
  }
750
798
 
751
- # Create the factor object
752
- if f_type in df_factor_map:
799
+ # Check to see if we have a non-datafarmable integer
800
+ if (
801
+ f_type is int
802
+ and "isDatafarmable" in spec
803
+ and not spec["isDatafarmable"]
804
+ ):
805
+ return DFIntegerNonDatafarmable(spec_name, f_description, f_default)
806
+ # Otherwise, just use the default mapping
807
+ elif f_type in df_factor_map:
753
808
  return df_factor_map[f_type](spec_name, f_description, f_default)
754
809
  else:
755
810
  raise NotImplementedError(
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import pickle
3
3
  import re
4
+ import threading
4
5
  import tkinter as tk
5
6
  from abc import ABCMeta
6
7
  from tkinter import filedialog, messagebox, ttk
@@ -1461,11 +1462,13 @@ class NewExperimentWindow(Toplevel):
1461
1462
  # Open file dialog to select design file
1462
1463
  # Pickle files only, but all files can be selected (in case someone
1463
1464
  # forgets to change file type)
1464
- # NOTE: For some reason we use both .pickle and .pkl extensions so we
1465
- # need to make sure we accept both
1465
+ # NOTE: Trying to accept both .pickle and .pkl files using
1466
+ # "*.pickle;*.pkl" causes Python to crash on MacOS but works fine on
1467
+ # Windows. As long as we only have one pickle file extension, we
1468
+ # should be fine.
1466
1469
  # TODO: standardize Pickle file extension (see GitHub issue #71)
1467
1470
  experiment_file = filedialog.askopenfilename(
1468
- filetypes=[("Pickle files", "*.pickle;*.pkl"), ("All files", "*.*")]
1471
+ filetypes=[("Pickle files", "*.pickle"), ("All files", "*.*")]
1469
1472
  )
1470
1473
  # Exit w/o message if no file selected
1471
1474
  if experiment_file == "" or not experiment_file:
@@ -2280,6 +2283,183 @@ class NewExperimentWindow(Toplevel):
2280
2283
  self.__update_problem_dropdown()
2281
2284
  self.__update_solver_dropdown()
2282
2285
 
2286
+ def __spawn_new_thread(self, function: Callable) -> threading.Thread:
2287
+ thread = threading.Thread(target=function)
2288
+ thread.start()
2289
+ return thread
2290
+
2291
+ def __disable_exp_buttons(self, experiment_name: str) -> None:
2292
+ name_base: Final[str] = "exp." + experiment_name
2293
+ # Get all the buttons
2294
+ buttons = [bttn for bttn in self.tk_buttons if name_base in bttn]
2295
+ # Disable all buttons (except view)
2296
+ for button in buttons:
2297
+ if not button.endswith(".view"):
2298
+ self.tk_buttons[button].configure(state="disabled")
2299
+
2300
+ def __enable_exp_buttons(self, experiment_name: str) -> None:
2301
+ name_base: Final[str] = "exp." + experiment_name
2302
+ # Get all the buttons
2303
+ buttons = [bttn for bttn in self.tk_buttons if name_base in bttn]
2304
+ # Enable all buttons
2305
+ for button in buttons:
2306
+ self.tk_buttons[button].configure(state="normal")
2307
+
2308
+ def __update_action_button(
2309
+ self,
2310
+ experiment_name: str,
2311
+ text: str,
2312
+ command: Union[Callable, None] = None,
2313
+ ) -> None:
2314
+ name_base: Final[str] = "exp." + experiment_name
2315
+ action_bttn_name: Final[str] = name_base + ".action"
2316
+ if command is None:
2317
+ self.tk_buttons[action_bttn_name].configure(text=text)
2318
+ else:
2319
+ self.tk_buttons[action_bttn_name].configure(
2320
+ text=text, command=command
2321
+ )
2322
+
2323
+ def __update_experiment_label(
2324
+ self, experiment_name: str, status: str
2325
+ ) -> None:
2326
+ name_base: Final[str] = "exp." + experiment_name
2327
+ lbl_name: Final[str] = name_base + ".name"
2328
+ text = f"{experiment_name}\n({status})"
2329
+ self.tk_labels[lbl_name].configure(text=text)
2330
+
2331
+ def __run_experiment_gui(self, experiment_name: str) -> None:
2332
+ # Setup
2333
+ self.__disable_exp_buttons(experiment_name)
2334
+ self.__update_experiment_label(experiment_name, "Running")
2335
+ # Try to run the experiment
2336
+ try:
2337
+ self.run_experiment(experiment_name)
2338
+ # If successful, update the label and button
2339
+ self.__update_experiment_label(experiment_name, "Ran")
2340
+ self.__update_action_button(
2341
+ experiment_name,
2342
+ "Post-Replicate",
2343
+ lambda exp_name=experiment_name: self.__post_process_gui_thread(
2344
+ exp_name
2345
+ ),
2346
+ )
2347
+ except Exception as e:
2348
+ messagebox.showerror("Error", str(e))
2349
+ self.__update_experiment_label(experiment_name, "Initialized")
2350
+ # Enable the buttons
2351
+ self.__enable_exp_buttons(experiment_name)
2352
+
2353
+ def __run_experiment_gui_thread(
2354
+ self, experiment_name: str
2355
+ ) -> threading.Thread:
2356
+ return self.__spawn_new_thread(
2357
+ lambda: self.__run_experiment_gui(experiment_name)
2358
+ )
2359
+
2360
+ def __post_process_gui(self, experiment_name: str) -> None:
2361
+ # Setup
2362
+ self.__disable_exp_buttons(experiment_name)
2363
+ self.__update_experiment_label(experiment_name, "Post-Processing")
2364
+ # Try to run the post-processing
2365
+ try:
2366
+ self.post_process(experiment_name)
2367
+ # If successful, update the label and button
2368
+ self.__update_experiment_label(experiment_name, "Post-Processed")
2369
+ self.__update_action_button(
2370
+ experiment_name,
2371
+ "Post-Replicated",
2372
+ lambda exp_name=experiment_name: self.__post_normalize_gui_thread(
2373
+ exp_name
2374
+ ),
2375
+ )
2376
+ except Exception as e:
2377
+ messagebox.showerror("Error", str(e))
2378
+ self.__update_experiment_label(experiment_name, "Ran")
2379
+ # Enable the buttons
2380
+ self.__enable_exp_buttons(experiment_name)
2381
+
2382
+ def __post_process_gui_thread(
2383
+ self, experiment_name: str
2384
+ ) -> threading.Thread:
2385
+ return self.__spawn_new_thread(
2386
+ lambda: self.__post_process_gui(experiment_name)
2387
+ )
2388
+
2389
+ def __post_normalize_gui(self, experiment_name: str) -> None:
2390
+ # Setup
2391
+ self.__disable_exp_buttons(experiment_name)
2392
+ self.__update_experiment_label(experiment_name, "Post-Normalizing")
2393
+ # Try to run the post-normalization
2394
+ try:
2395
+ self.post_normalize(experiment_name)
2396
+ # If successful, update the label and button
2397
+ self.__update_experiment_label(experiment_name, "Post-Normalized")
2398
+ self.__update_action_button(
2399
+ experiment_name,
2400
+ "Log Results",
2401
+ lambda exp_name=experiment_name: self.__log_results_gui_thread(
2402
+ exp_name
2403
+ ),
2404
+ )
2405
+ except Exception as e:
2406
+ messagebox.showerror("Error", str(e))
2407
+ # If the post-normalization fails, revert to the post-process button
2408
+ self.__update_experiment_label(experiment_name, "Post-Processed")
2409
+ # Enable the buttons
2410
+ self.__enable_exp_buttons(experiment_name)
2411
+
2412
+ def __post_normalize_gui_thread(
2413
+ self, experiment_name: str
2414
+ ) -> threading.Thread:
2415
+ return self.__spawn_new_thread(
2416
+ lambda: self.__post_normalize_gui(experiment_name)
2417
+ )
2418
+
2419
+ def __log_results_gui(self, experiment_name: str) -> None:
2420
+ # Setup
2421
+ self.__disable_exp_buttons(experiment_name)
2422
+ self.__update_experiment_label(experiment_name, "Logging")
2423
+ # Try to log the experiment
2424
+ try:
2425
+ self.post_normalize(experiment_name)
2426
+ # If successful, update the label and button
2427
+ self.__update_experiment_label(experiment_name, "Logged")
2428
+ self.__update_action_button(experiment_name, "All Steps\nComplete")
2429
+ # Update the all button to reflect that all steps are done
2430
+ all_bttn_name: Final[str] = "exp." + experiment_name + ".all"
2431
+ self.tk_buttons[all_bttn_name].configure(text="All Steps\nComplete")
2432
+ except Exception as e:
2433
+ messagebox.showerror("Error", str(e))
2434
+ self.__update_experiment_label(experiment_name, "Post-Normalized")
2435
+ # Enable the buttons that don't relate to running the experiment
2436
+ name_base: Final[str] = "exp." + experiment_name
2437
+ buttons = [bttn for bttn in self.tk_buttons if name_base in bttn]
2438
+ for button in buttons:
2439
+ if not button.endswith(".action") and not button.endswith(".all"):
2440
+ self.tk_buttons[button].configure(state="normal")
2441
+
2442
+ def __log_results_gui_thread(
2443
+ self, experiment_name: str
2444
+ ) -> threading.Thread:
2445
+ return self.__spawn_new_thread(
2446
+ lambda: self.__log_results_gui(experiment_name)
2447
+ )
2448
+
2449
+ def __all_action_gui(self, experiment_name: str) -> None:
2450
+ # None of these steps do anything if they've already been done
2451
+ self.__run_experiment_gui(experiment_name)
2452
+ self.__post_process_gui(experiment_name)
2453
+ self.__post_normalize_gui(experiment_name)
2454
+ self.__log_results_gui(experiment_name)
2455
+
2456
+ def __all_actions_gui_thread(
2457
+ self, experiment_name: str
2458
+ ) -> threading.Thread:
2459
+ return self.__spawn_new_thread(
2460
+ lambda: self.__all_action_gui(experiment_name)
2461
+ )
2462
+
2283
2463
  def add_exp_row(
2284
2464
  self, experiment_name: str, is_imported: bool = False
2285
2465
  ) -> None:
@@ -2289,25 +2469,6 @@ class NewExperimentWindow(Toplevel):
2289
2469
 
2290
2470
  # Format:
2291
2471
  # (past_tense, present_tense, future_tense, function)
2292
- bttn_text_steps: Final[
2293
- list[tuple[str, str, str, Callable[[str], None]]]
2294
- ] = [
2295
- ("Run", "Running", "Ran", self.run_experiment),
2296
- (
2297
- "Post-Replicate",
2298
- "Post-Replicating",
2299
- "Post-Replicated",
2300
- self.post_process,
2301
- ),
2302
- (
2303
- "Post-Normalize",
2304
- "Post-Normalizing",
2305
- "Post-Normalized",
2306
- self.post_normalize,
2307
- ),
2308
- ("Log Results", "Logging", "Logged", self.log_results),
2309
- ]
2310
-
2311
2472
  name_base: Final[str] = "exp." + experiment_name
2312
2473
  lbl_name: Final[str] = name_base + ".name"
2313
2474
  action_bttn_name: Final[str] = name_base + ".action"
@@ -2338,49 +2499,6 @@ class NewExperimentWindow(Toplevel):
2338
2499
  bttn_text_run_all = "Run All\nRemaining Steps"
2339
2500
  bttn_text_run = "Run\nExperiment"
2340
2501
 
2341
- def action(name: str, step: int = 0) -> bool:
2342
- # Lookup all the verbage for the current step
2343
- past_tense, present_tense, future_tense, function = bttn_text_steps[
2344
- step
2345
- ]
2346
- # Get the buttons and update them for the current step
2347
- action_button = self.tk_buttons[action_bttn_name]
2348
- all_button = self.tk_buttons[all_bttn_name]
2349
- action_button.configure(text=present_tense, state="disabled")
2350
- all_button.configure(state="disabled")
2351
- self.update()
2352
- # Run the function
2353
- try:
2354
- function(name) # type: ignore
2355
- # Set the name to include the updated status
2356
- name_label = self.tk_labels[lbl_name]
2357
- name_label.configure(text=name + "\n(" + future_tense + ")")
2358
- # If there are more steps, setup the next step
2359
- if step < len(bttn_text_steps) - 1:
2360
- # Figure out what the next step is
2361
- next_past_tense, _, _, _ = bttn_text_steps[step + 1]
2362
- action_button.configure(
2363
- text=next_past_tense,
2364
- state="normal",
2365
- command=lambda: action(name, step + 1),
2366
- )
2367
- all_button.configure(state="normal")
2368
- else:
2369
- action_button.configure(text="Done")
2370
- return True
2371
-
2372
- except Exception as e:
2373
- messagebox.showerror("Error", str(e))
2374
- # Set the button text back to past tense and reactivate buttons
2375
- action_button.configure(text=past_tense, state="normal")
2376
- all_button.configure(state="normal")
2377
- return False
2378
-
2379
- def all_actions(name: str) -> None:
2380
- for step in range(len(bttn_text_steps)):
2381
- if not action(name, step):
2382
- break
2383
-
2384
2502
  def view(experiment_name: str) -> None:
2385
2503
  # Check if there's an experiment in progress
2386
2504
  if (
@@ -2472,7 +2590,9 @@ class NewExperimentWindow(Toplevel):
2472
2590
  self.tk_buttons[action_bttn_name] = ttk.Button(
2473
2591
  master=list_frame,
2474
2592
  text=bttn_text_run,
2475
- command=lambda name=experiment_name: action(name),
2593
+ command=lambda name=experiment_name: self.__run_experiment_gui_thread(
2594
+ name
2595
+ ),
2476
2596
  )
2477
2597
  self.tk_buttons[action_bttn_name].grid(
2478
2598
  row=row_idx, column=1, padx=5, pady=5, sticky="nsew"
@@ -2481,7 +2601,9 @@ class NewExperimentWindow(Toplevel):
2481
2601
  self.tk_buttons[all_bttn_name] = ttk.Button(
2482
2602
  master=list_frame,
2483
2603
  text=bttn_text_run_all,
2484
- command=lambda name=experiment_name: all_actions(name),
2604
+ command=lambda name=experiment_name: self.__all_actions_gui_thread(
2605
+ name
2606
+ ),
2485
2607
  )
2486
2608
  self.tk_buttons[all_bttn_name].grid(
2487
2609
  row=row_idx, column=2, padx=5, pady=5, sticky="nsew"
@@ -79,6 +79,7 @@ class AmusementPark(Model):
79
79
  "description": "The number of attractions in the park.",
80
80
  "datatype": int,
81
81
  "default": NUM_ATTRACTIONS,
82
+ "isDatafarmable": False
82
83
  },
83
84
  "time_open": {
84
85
  "description": "The number of minutes per day the park is open.",
@@ -556,6 +557,7 @@ class AmusementParkMinDepart(Problem):
556
557
  "description": "Max # of replications for a solver to take.",
557
558
  "datatype": int,
558
559
  "default": 100,
560
+ "isDatafarmable": False
559
561
  },
560
562
  }
561
563
 
@@ -343,6 +343,7 @@ class ChessAvgDifference(Problem):
343
343
  "description": "max # of replications for a solver to take",
344
344
  "datatype": int,
345
345
  "default": 1000,
346
+ "isDatafarmable": False
346
347
  },
347
348
  "upper_time": {
348
349
  "description": "upper bound on wait time",
@@ -348,6 +348,7 @@ class CntNVMaxProfit(Problem):
348
348
  "description": "max # of replications for a solver to take",
349
349
  "datatype": int,
350
350
  "default": 1000,
351
+ "isDatafarmable": False
351
352
  },
352
353
  }
353
354
 
@@ -737,6 +737,7 @@ class ContaminationTotalCostCont(Problem):
737
737
  "description": "max # of replications for a solver to take",
738
738
  "datatype": int,
739
739
  "default": 10000,
740
+ "isDatafarmable": False
740
741
  },
741
742
  "prev_cost": {
742
743
  "description": "cost of prevention",
@@ -92,6 +92,7 @@ class DualSourcing(Model):
92
92
  "description": "number of days to simulate",
93
93
  "datatype": int,
94
94
  "default": 1000,
95
+ "isDatafarmable": False
95
96
  },
96
97
  "initial_inv": {
97
98
  "description": "initial inventory",
@@ -467,6 +468,7 @@ class DualSourcingMinCost(Problem):
467
468
  "description": "max # of replications for a solver to take",
468
469
  "datatype": int,
469
470
  "default": 1000,
471
+ "isDatafarmable": False
470
472
  },
471
473
  }
472
474
 
@@ -374,6 +374,7 @@ class DynamNewsMaxProfit(Problem):
374
374
  "description": "max # of replications for a solver to take",
375
375
  "datatype": int,
376
376
  "default": 1000,
377
+ "isDatafarmable": False
377
378
  },
378
379
  }
379
380
 
@@ -242,6 +242,7 @@ class ExampleProblem(Problem):
242
242
  "description": "max # of replications for a solver to take",
243
243
  "datatype": int,
244
244
  "default": 1000,
245
+ "isDatafarmable": False
245
246
  },
246
247
  }
247
248
 
@@ -87,6 +87,7 @@ class FacilitySize(Model):
87
87
  "description": "number of facilities",
88
88
  "datatype": int,
89
89
  "default": NUM_FACILITIES,
90
+ "isDatafarmable": False
90
91
  },
91
92
  }
92
93
 
@@ -317,6 +318,7 @@ class FacilitySizingTotalCost(Problem):
317
318
  "description": "Max # of replications for a solver to take.",
318
319
  "datatype": int,
319
320
  "default": 10000,
321
+ "isDatafarmable": False
320
322
  },
321
323
  "installation_costs": {
322
324
  "description": "Cost to install a unit of capacity at each facility.",
@@ -340,6 +340,7 @@ class FixedSANLongestPath(Problem):
340
340
  "description": "max # of replications for a solver to take",
341
341
  "datatype": int,
342
342
  "default": 10000,
343
+ "isDatafarmable": False
343
344
  },
344
345
  "arc_costs": {
345
346
  "description": "cost associated to each arc",
@@ -898,6 +898,7 @@ class HotelRevenue(Problem):
898
898
  "description": "max # of replications for a solver to take",
899
899
  "datatype": int,
900
900
  "default": 100,
901
+ "isDatafarmable": False
901
902
  },
902
903
  }
903
904
 
@@ -132,6 +132,7 @@ class IronOre(Model):
132
132
  "description": "number of days to simulate",
133
133
  "datatype": int,
134
134
  "default": 365,
135
+ "isDatafarmable": False
135
136
  },
136
137
  }
137
138
 
@@ -449,6 +450,7 @@ class IronOreMaxRev(Problem):
449
450
  "description": "max # of replications for a solver to take",
450
451
  "datatype": int,
451
452
  "default": 1000,
453
+ "isDatafarmable": False
452
454
  },
453
455
  }
454
456
 
@@ -366,6 +366,7 @@ class MM1MinMeanSojournTime(Problem):
366
366
  "description": "max # of replications for a solver to take",
367
367
  "datatype": int,
368
368
  "default": 1000,
369
+ "isDatafarmable": False
369
370
  },
370
371
  "cost": {
371
372
  "description": "cost for increasing service rate",
@@ -472,6 +472,7 @@ class NetworkMinTotalCost(Problem):
472
472
  "description": "max # of replications for a solver to take",
473
473
  "datatype": int,
474
474
  "default": 1000,
475
+ "isDatafarmable": False
475
476
  },
476
477
  }
477
478
 
@@ -274,6 +274,7 @@ class ParamEstiMaxLogLik(Problem):
274
274
  "description": "max # of replications for a solver to take",
275
275
  "datatype": int,
276
276
  "default": 1000,
277
+ "isDatafarmable": False
277
278
  },
278
279
  }
279
280
 
@@ -399,6 +399,7 @@ class RMITDMaxRevenue(Problem):
399
399
  "description": "max # of replications for a solver to take",
400
400
  "datatype": int,
401
401
  "default": 10000,
402
+ "isDatafarmable": False
402
403
  },
403
404
  }
404
405
 
@@ -68,6 +68,7 @@ class SAN(Model):
68
68
  "description": "number of nodes",
69
69
  "datatype": int,
70
70
  "default": 9,
71
+ "isDatafarmable": False
71
72
  },
72
73
  "arcs": {
73
74
  "description": "list of arcs",
@@ -373,6 +374,7 @@ class SANLongestPath(Problem):
373
374
  "description": "max # of replications for a solver to take",
374
375
  "datatype": int,
375
376
  "default": 10000,
377
+ "isDatafarmable": False
376
378
  },
377
379
  "arc_costs": {
378
380
  "description": "Cost associated to each arc.",
@@ -131,11 +131,13 @@ class SSCont(Model):
131
131
  "description": "number of periods to simulate",
132
132
  "datatype": int,
133
133
  "default": 100,
134
+ "isDatafarmable": False
134
135
  },
135
136
  "warmup": {
136
137
  "description": "number of periods as warmup before collecting statistics",
137
138
  "datatype": int,
138
139
  "default": 20,
140
+ "isDatafarmable": False
139
141
  },
140
142
  }
141
143
 
@@ -498,6 +500,7 @@ class SSContMinCost(Problem):
498
500
  "description": "max # of replications for a solver to take",
499
501
  "datatype": int,
500
502
  "default": 1000,
503
+ "isDatafarmable": False
501
504
  },
502
505
  }
503
506
 
@@ -399,6 +399,7 @@ class TableAllocationMaxRev(Problem):
399
399
  "description": "max # of replications for a solver to take",
400
400
  "datatype": int,
401
401
  "default": 1000,
402
+ "isDatafarmable": False
402
403
  },
403
404
  }
404
405
 
@@ -132,6 +132,11 @@ class ASTRODF(Solver):
132
132
  "datatype": float,
133
133
  "default": 0.1,
134
134
  },
135
+ "use_gradients": {
136
+ "description": "if direct gradient observations are available, use them",
137
+ "datatype": bool,
138
+ "default": True,
139
+ },
135
140
  }
136
141
 
137
142
  @property
@@ -469,8 +474,9 @@ class ASTRODF(Solver):
469
474
  interpolation_solns.append(visited_pts_list[f_index])
470
475
  # for new points, run the simulation with pilot run
471
476
  else:
477
+ decision_vars = tuple(var_y[i][0])
472
478
  new_solution = self.create_new_solution(
473
- tuple(var_y[i][0]), problem
479
+ decision_vars, problem
474
480
  )
475
481
  visited_pts_list.append(new_solution)
476
482
  problem.simulate(new_solution, pilot_run)
@@ -479,9 +485,6 @@ class ASTRODF(Solver):
479
485
 
480
486
  # adaptive sampling
481
487
  while True:
482
- problem.simulate(new_solution, 1)
483
- expended_budget += 1
484
- sample_size += 1
485
488
  sig2 = new_solution.objectives_var[0]
486
489
  stopping = self.get_stopping_time(
487
490
  pilot_run,
@@ -496,6 +499,10 @@ class ASTRODF(Solver):
496
499
  or expended_budget >= budget
497
500
  ):
498
501
  break
502
+ problem.simulate(new_solution, 1)
503
+ expended_budget += 1
504
+ sample_size += 1
505
+
499
506
  fval.append(
500
507
  -1 * problem.minmax[0] * new_solution.objectives_mean
501
508
  )
@@ -659,12 +666,14 @@ class ASTRODF(Solver):
659
666
  lambda_min: int = self.factors["lambda_min"]
660
667
  lambda_max = budget_limit - expended_budget
661
668
  # lambda_max = budget_limit / (15 * sqrt(problem.dim))
662
- gradient_availability = problem.gradient_available
669
+ enable_gradient = (
670
+ problem.gradient_available and self.factors["use_gradients"]
671
+ )
663
672
  # uncomment the next line to avoid Hessian updating
664
673
  # h_k = np.identity(problem.dim)
665
674
  # determine power of delta in adaptive sampling rule
666
675
  if self.factors["crn_across_solns"]:
667
- if gradient_availability:
676
+ if enable_gradient:
668
677
  delta_power = 0
669
678
  else:
670
679
  delta_power = 2
@@ -679,9 +688,7 @@ class ASTRODF(Solver):
679
688
  - 1
680
689
  )
681
690
  if k == 1:
682
- incumbent_solution = self.create_new_solution(
683
- tuple(incumbent_x), problem
684
- )
691
+ incumbent_solution = self.create_new_solution(incumbent_x, problem)
685
692
  if len(visited_pts_list) == 0:
686
693
  visited_pts_list.append(incumbent_solution)
687
694
 
@@ -692,7 +699,7 @@ class ASTRODF(Solver):
692
699
 
693
700
  # adaptive sampling
694
701
  while True:
695
- if gradient_availability:
702
+ if enable_gradient:
696
703
  rhs_for_kappa = norm(
697
704
  incumbent_solution.objectives_gradients_mean[0]
698
705
  )
@@ -726,14 +733,15 @@ class ASTRODF(Solver):
726
733
  )
727
734
  # print("kappa "+str(kappa))
728
735
  break
729
- else:
730
- problem.simulate(incumbent_solution, 1)
731
- expended_budget += 1
732
- sample_size += 1
736
+ problem.simulate(incumbent_solution, 1)
737
+ expended_budget += 1
738
+ sample_size += 1
733
739
 
734
740
  recommended_solns.append(incumbent_solution)
735
741
  intermediate_budgets.append(expended_budget)
736
- elif self.factors["crn_across_solns"]: # since incument was only evaluated with the sample size of previous incumbent, here we compute its adaptive sample size
742
+ elif self.factors[
743
+ "crn_across_solns"
744
+ ]: # since incument was only evaluated with the sample size of previous incumbent, here we compute its adaptive sample size
737
745
  sample_size = incumbent_solution.n_reps
738
746
  # adaptive sampling
739
747
  while True:
@@ -755,10 +763,9 @@ class ASTRODF(Solver):
755
763
  problem.simulate(incumbent_solution, 1)
756
764
  expended_budget += 1
757
765
  sample_size += 1
758
-
759
766
 
760
767
  # use Taylor expansion if gradient available
761
- if gradient_availability:
768
+ if enable_gradient:
762
769
  fval = (
763
770
  np.ones(2 * problem.dim + 1)
764
771
  * -1
@@ -801,7 +808,7 @@ class ASTRODF(Solver):
801
808
  # TODO: why do we need this? Check model reduction calculation too.
802
809
  # print("np.dot(np.multiply(grad, Hessian), grad) "+str(np.dot(np.multiply(grad, hessian), grad)))
803
810
  # print("np.dot(np.dot(grad, hessian), grad) "+str(np.dot(np.dot(grad, hessian), grad)))
804
- if gradient_availability:
811
+ if enable_gradient:
805
812
  # print("hessian " + str(hessian))
806
813
  check_positive_definite = np.dot(np.dot(grad, hessian), grad)
807
814
  else:
@@ -817,12 +824,8 @@ class ASTRODF(Solver):
817
824
  # print("tau "+str(tau))
818
825
  grad = np.reshape(grad, (1, problem.dim))[0]
819
826
  grad_norm = norm(grad)
827
+ # Make sure we don't divide by 0
820
828
  if grad_norm == 0:
821
- # warning_msg = "Warning: Division by 0 in ASTRO-DF solver (norm(grad) == 0)."
822
- # print(warning_msg, file=sys.stderr)
823
- # # TODO: figure out how to handle this
824
- # # Normally, DB0 errors would result in +-inf, but we have to
825
- # # add the result to incumbent_x, so we can't have inf values
826
829
  candidate_x = incumbent_x
827
830
  else:
828
831
  product = tau * delta_k * grad
@@ -854,16 +857,18 @@ class ASTRODF(Solver):
854
857
 
855
858
  # print("problem.lower_bounds "+str(problem.lower_bounds))
856
859
  # handle the box constraints
860
+ new_candidate_list = []
857
861
  for i in range(problem.dim):
858
862
  if candidate_x[i] <= problem.lower_bounds[i]:
859
- candidate_x[i] = problem.lower_bounds[i] + 0.01
863
+ new_candidate_list.append(problem.lower_bounds[i] + 0.01)
860
864
  elif candidate_x[i] >= problem.upper_bounds[i]:
861
- candidate_x[i] = problem.upper_bounds[i] - 0.01
865
+ new_candidate_list.append(problem.upper_bounds[i] - 0.01)
866
+ else:
867
+ new_candidate_list.append(candidate_x[i])
868
+ candidate_x = tuple(new_candidate_list)
862
869
 
863
870
  # store the solution (and function estimate at it) to the subproblem as a candidate for the next iterate
864
- candidate_solution = self.create_new_solution(
865
- tuple(candidate_x), problem
866
- )
871
+ candidate_solution = self.create_new_solution(candidate_x, problem)
867
872
  visited_pts_list.append(candidate_solution)
868
873
 
869
874
  # if we use crn, then the candidate solution has the same sample size as the incumbent solution
@@ -876,7 +881,7 @@ class ASTRODF(Solver):
876
881
  expended_budget += pilot_run
877
882
  sample_size = pilot_run
878
883
  while True:
879
- # if gradient_availability:
884
+ # if enable_gradient:
880
885
  # # print("incumbent_solution.objectives_gradients_var[0] "+str(candidate_solution.objectives_gradients_var[0]))
881
886
  # while norm(candidate_solution.objectives_gradients_var[0]) == 0 and candidate_solution.n_reps < max(pilot_run, lambda_max/100):
882
887
  # problem.simulate(candidate_solution, 1)
@@ -900,7 +905,7 @@ class ASTRODF(Solver):
900
905
  problem.simulate(candidate_solution, 1)
901
906
  expended_budget += 1
902
907
  sample_size += 1
903
-
908
+
904
909
  # TODO: make sure the solution whose estimated objevtive is abrupted bc of budget is not added to the list of recommended solutions, unless the error is negligible ...
905
910
  # if (expended_budget >= budget_limit) and (sample_size < stopping):
906
911
  # final_ob = fval[0]
@@ -911,7 +916,7 @@ class ASTRODF(Solver):
911
916
  # also if the candidate solution's variance is high that could be caused by stopping early due to exhausting budget
912
917
  # print("cv "+str(candidate_solution.objectives_var/(candidate_solution.n_reps * candidate_solution.objectives_mean ** 2)))
913
918
  # print("fval[0] - min(fval) "+str(fval[0] - min(fval)))
914
- if not gradient_availability and (
919
+ if not enable_gradient and (
915
920
  (
916
921
  (min(fval) < fval_tilde)
917
922
  and (
@@ -931,19 +936,22 @@ class ASTRODF(Solver):
931
936
  )
932
937
  ):
933
938
  fval_tilde = min(fval)
934
- candidate_x = y_var[fval.index(min(fval))][0]
935
- candidate_solution = interpolation_solns[fval.index(min(fval))]
939
+ candidate_x = y_var[fval.index(min(fval))][0] # type: ignore
940
+ candidate_solution = interpolation_solns[fval.index(min(fval))] # type: ignore
936
941
 
937
942
  # compute the success ratio rho
938
- s = np.array(candidate_x - incumbent_x)
939
- if gradient_availability:
943
+ candidate_x_arr = np.array(candidate_x)
944
+ incumbent_x_arr = np.array(incumbent_x)
945
+ s = np.subtract(candidate_x_arr, incumbent_x_arr)
946
+ if enable_gradient:
940
947
  model_reduction = -np.dot(s, grad) - 0.5 * np.dot(
941
948
  np.dot(s, hessian), s
942
949
  )
943
950
  else:
944
951
  model_reduction = self.evaluate_model(
945
- np.zeros(problem.dim), q
946
- ) - self.evaluate_model(s, q)
952
+ np.zeros(problem.dim),
953
+ q, # type: ignore
954
+ ) - self.evaluate_model(s, q) # type: ignore
947
955
  if model_reduction <= 0:
948
956
  rho = 0
949
957
  else:
@@ -959,7 +967,7 @@ class ASTRODF(Solver):
959
967
  # very successful: expand
960
968
  if rho >= eta_2:
961
969
  delta_k = min(gamma_1 * delta_k, delta_max)
962
- if gradient_availability:
970
+ if enable_gradient:
963
971
  candidate_grad = (
964
972
  -1
965
973
  * problem.minmax[0]
@@ -979,10 +987,11 @@ class ASTRODF(Solver):
979
987
  else:
980
988
  r_k = 1.0 / (y_k @ s)
981
989
  h_s_k = h_k @ s
982
- h_k = h_k + (
983
- np.outer(y_k, y_k) * r_k
990
+ h_k = (
991
+ h_k
992
+ + np.outer(y_k, y_k) * r_k
984
993
  - np.outer(h_s_k, h_s_k) / (s @ h_s_k)
985
- )
994
+ ) # type: ignore
986
995
  # unsuccessful: shrink and reject
987
996
  else:
988
997
  delta_k = min(gamma_2 * delta_k, delta_max)
@@ -1059,7 +1068,7 @@ class ASTRODF(Solver):
1059
1068
  incumbent_solution = self.create_new_solution(
1060
1069
  tuple(incumbent_x), problem
1061
1070
  )
1062
- h_k = np.identity(problem.dim)
1071
+ h_k = np.identity(problem.dim).tolist()
1063
1072
 
1064
1073
  while expended_budget < budget:
1065
1074
  k += 1
@@ -1087,7 +1096,7 @@ class ASTRODF(Solver):
1087
1096
  intermediate_budgets,
1088
1097
  kappa,
1089
1098
  incumbent_solution,
1090
- h_k,
1099
+ h_k, # type: ignore
1091
1100
  )
1092
1101
 
1093
1102
  return recommended_solns, intermediate_budgets
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: simoptlib
3
- Version: 1.1.0
3
+ Version: 1.1.1
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 <wagrocho@ncsu.edu>
6
6
  License: MIT License
@@ -76,7 +76,7 @@ Full documentation for the source code can be found on our **[readthedocs page](
76
76
  - Python >= 3.8
77
77
  - To check your Python version, open a terminal and run `python --version`. If you see a message along the lines of `Command not found`, then you likely don't have Python installed. If you know you have it installed but are getting a `Command not found` error, then you may need to [add Python to your PATH](https://realpython.com/add-python-to-path/).
78
78
  - For new installs, [Miniconda or Anaconda](https://www.anaconda.com/download) is recommended ([read about the differences between Miniconda and Anaconda](https://docs.anaconda.com/distro-or-miniconda/)). If you already have a compatible IDE (such as VS Code), we've found that Miniconda will work fine at 1/10 of the size of Anaconda. It is ***highly recommended*** to check the box during installation to add Python/Miniconda/Anaconda to your system PATH.
79
- - Ruby >= 3.0 (required for datafarming)
79
+ - Ruby >= 2.5 (required for datafarming)
80
80
  - Included on MacOS, but Windows users will need to grab it from [here](https://rubyinstaller.org/).
81
81
  - `datafarming` gem < 2.0 (required for datafarming)
82
82
  - This can be installed via `gem install datafarming -v 1.4` once Ruby is installed/configured.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes