Skip to content

Commit

Permalink
removed _SecondStageCostExpr class, call objective function directly
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklise committed Apr 30, 2024
1 parent e68c415 commit 63634c9
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions pyomo/contrib/parmest/parmest.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,6 @@ def SSE(model):
return expr


class _SecondStageCostExpr(object):
"""
Class to pass objective expression into the Pyomo model
"""

def __init__(self, ssc_function):
self._ssc_function = ssc_function

def __call__(self, model):
return self._ssc_function(model)


class Estimator(object):
"""
Parameter estimation class
Expand Down Expand Up @@ -419,10 +407,10 @@ def _create_parmest_model(self, experiment_number):

# TODO, this needs to be turned a enum class of options that still support custom functions
if self.obj_function == 'SSE':
second_stage_rule = _SecondStageCostExpr(SSE)
second_stage_rule = SSE
else:
# A custom function uses model.experiment_outputs as data
second_stage_rule = _SecondStageCostExpr(self.obj_function)
second_stage_rule = self.obj_function

model.FirstStageCost = pyo.Expression(expr=0)
model.SecondStageCost = pyo.Expression(rule=second_stage_rule)
Expand Down

0 comments on commit 63634c9

Please sign in to comment.