Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cdd7d52
Work on multistart implement 4/23 morning
sscini Apr 23, 2025
eca0ba8
Finished first draft of pseudocode for multistart
sscini Apr 23, 2025
2160aec
Fixed logical errors in pseudocode
sscini Apr 23, 2025
266beea
Started implementing review comments 4/30
sscini Apr 30, 2025
b877ada
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Apr 30, 2025
9f1ffe5
Work on edits, 5/1/25
sscini May 1, 2025
43f1ab3
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini May 1, 2025
ea067c8
Made edits, still debugging
sscini May 2, 2025
3b839ef
Addressed some comments in code. Still working through example to debug
sscini May 14, 2025
3a7aa1d
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini May 14, 2025
c688f2d
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini May 21, 2025
50c36bc
Got dataframe formatted, still working on executing Q_opt
sscini May 21, 2025
8e5f078
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Jun 2, 2025
f4c7018
Working code, adding features 6/2/25
sscini Jun 2, 2025
4444e6d
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Jun 3, 2025
e788000
Added questions for next round of reviews
sscini Jun 3, 2025
4429caf
Merge branch 'multistart-in-parmest' of https://github.com/sscini/pyo…
sscini Jun 3, 2025
f071718
Removed diagnostic tables to simplify output
sscini Jun 3, 2025
9b1545d
Work from Wednesday of Sprint week
sscini Jun 4, 2025
80079cb
Create Simple_Multimodal_Multistart.ipynb
sscini Jun 4, 2025
1695519
New features Thursday morning
sscini Jun 5, 2025
0634014
First successful running multistart feature, before Alex recommended …
sscini Jun 5, 2025
a959346
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Jun 5, 2025
04a9096
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Jun 23, 2025
06e0a72
Ran black, removed temp example
sscini Jun 24, 2025
6b3ee40
Added utility to update model using suffix values
sscini Jun 27, 2025
5cadfac
Work on Friday 6/27 applying PR comments
sscini Jun 27, 2025
922fd57
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Jun 30, 2025
1be2d9e
Addressed some reviewer comments and ran black.
sscini Jun 30, 2025
56800f5
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Jul 1, 2025
05381c5
Updated argument for theta_est_multistart
sscini Jul 6, 2025
5b4f9c1
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Jul 7, 2025
07ae1e8
Addressed majority of review comments. State before 7/8 dev meeting
sscini Jul 8, 2025
33d838f
Fixing conflict
sscini Jul 8, 2025
65a9cff
Merge branch 'main' into multistart-in-parmest
sscini Jul 15, 2025
90093df
Merge branch 'Pyomo:main' into multistart-in-parmest
sscini Jul 17, 2025
e7b2df1
Added in TODO items based on Dan morning meeting
sscini Jul 17, 2025
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
8 changes: 8 additions & 0 deletions pyomo/contrib/parmest/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ def __init__(self, model=None):

def get_labeled_model(self):
return self.model

def reinitialize_unknown_parameters(self):
raise NotImplementedError(
"The reinitialize_unknown_parameters method should implemented in the subclass." \
"Thi method will take new values for the unknown parameters from the Suffix "
"and allow users to reinitialize the model."
)

25 changes: 18 additions & 7 deletions pyomo/contrib/parmest/parmest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def ef_nonants(ef):


def _experiment_instance_creation_callback(
scenario_name, node_names=None, cb_data=None
scenario_name, node_names=None, cb_data=None, fix_vars=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would support having utility methods _fix_unknown_parameters and _fix_experiment_inputs live within the Experiment class. These methods could have fix=True as a default, and fix=False would unfix.

):
"""
This is going to be called by mpi-sppy or the local EF and it will call into
Expand All @@ -107,6 +107,8 @@ def _experiment_instance_creation_callback(
that is the "callback" value.
"BootList" is None or bootstrap experiment number list.
(called cb_data by mpisppy)
fix_vars: `bool` If True, the theta variables are fixed to the values
provided in the cb_data["ThetaVals"] dictionary.


Returns:
Expand Down Expand Up @@ -217,16 +219,22 @@ def _experiment_instance_creation_callback(
# This is the only way I see to pass the theta values to the model
# Can we add an optional argument to fix them or not?
# Curently, thetavals provided are fixed if not None
# Suggested fix in this function and _Q_at_theta
if "ThetaVals" in outer_cb_data:
thetavals = outer_cb_data["ThetaVals"]

# dlw august 2018: see mea code for more general theta
for name, val in thetavals.items():
theta_cuid = ComponentUID(name)
theta_object = theta_cuid.find_component_on(instance)
if val is not None:
if val is not None and fix_vars is True:
# print("Fixing",vstr,"at",str(thetavals[vstr]))
theta_object.fix(val)
# ADDED OPTION: Set initial value, but do not fix
elif val is not None and fix_vars is False:
# print("Setting",vstr,"to",str(thetavals[vstr]))
theta_object.set_value(val)
theta_object.unfix()
else:
# print("Freeing",vstr)
theta_object.unfix()
Expand Down Expand Up @@ -829,7 +837,7 @@ def _Q_at_theta(self, thetavals, initialize_parmest_model=False):

# start block of code to deal with models with no constraints
# (ipopt will crash or complain on such problems without special care)
instance = _experiment_instance_creation_callback("FOO0", None, dummy_cb)
instance = _experiment_instance_creation_callback("FOO0", None, dummy_cb,)
try: # deal with special problems so Ipopt will not crash
first = next(instance.component_objects(pyo.Constraint, active=True))
active_constraints = True
Expand All @@ -846,7 +854,7 @@ def _Q_at_theta(self, thetavals, initialize_parmest_model=False):

for snum in scenario_numbers:
sname = "scenario_NODE" + str(snum)
instance = _experiment_instance_creation_callback(sname, None, dummy_cb)
instance = _experiment_instance_creation_callback(sname, None, dummy_cb, fix_vars=True)
model_theta_names = self._expand_indexed_unknowns(instance)

if initialize_parmest_model:
Expand Down Expand Up @@ -1214,11 +1222,14 @@ def theta_est_multistart(

# # Check if the objective value is better than the best objective value
# # Set a very high initial best objective value
best_objectiveval = np.inf
best_theta = np.inf
if i == 0:
# Initialize best objective value and theta
best_objectiveval = np.inf
best_theta = np.inf
# Check if the final objective value is better than the best found so far
if final_objectiveval < best_objectiveval:
best_objectiveval = objectiveval
best_theta = theta_vals_current
best_theta = converged_theta.values

print(f"Restart {i+1}/{n_restarts}: Objective Value = {final_objectiveval}, Theta = {converged_theta}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other logging comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, using "out of" instead of "/" is probably a better choice.


Expand Down