Skip to content

Commit

Permalink
Deprecate old convergence tester tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Lee committed Nov 7, 2023
1 parent 98a2503 commit bffa953
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion idaes/core/util/convergence/convergence_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- a Pyomo solver with appropriate options
The module executes convergence evaluation in two steps. In the first step, a
json file is created that containsa set of points sampled from the provided
json file is created that contains a set of points sampled from the provided
inputs. This step only needs to be done once - up front. The second step, which
should be executed any time there is a major code change that could impact the
model, takes that set of sampled points and solves the model at each of the
Expand Down Expand Up @@ -79,6 +79,7 @@ class from ConvergenceEvaluation, and implement three methods:
from pyomo.core import Param, Var
from pyomo.common.log import LoggingIntercept
from pyomo.environ import check_optimal_termination
from pyomo.common.deprecation import deprecated

# idaes
import idaes.core.util.convergence.mpi_utils as mpiu
Expand All @@ -92,6 +93,11 @@ class from ConvergenceEvaluation, and implement three methods:
convergence_classes = {}


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def register_convergence_class(name):
def _register_convergence_class(cls):
if name in convergence_classes:
Expand All @@ -102,6 +108,11 @@ def _register_convergence_class(cls):
return _register_convergence_class


@deprecated(
msg="This class has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
class ConvergenceEvaluationSpecification(object):
"""
Object for defining sample points for convergence evaluations.
Expand Down Expand Up @@ -161,6 +172,11 @@ def inputs(self):
return self._inputs


@deprecated(
msg="This class has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
class ConvergenceEvaluation:
"""
Object for running convergence evaluations.
Expand Down Expand Up @@ -510,6 +526,11 @@ def _set_model_parameters_from_sample(model, inputs, sample_point):
)


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def generate_samples(eval_spec, n_points, seed=None):
"""
Samples the space of the inputs defined in the eval_spec, and creates an
Expand Down Expand Up @@ -549,6 +570,11 @@ def generate_samples(eval_spec, n_points, seed=None):
return samples


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def write_sample_file(
eval_spec, filename, convergence_evaluation_class_str, n_points, seed=None
):
Expand Down Expand Up @@ -592,6 +618,11 @@ def write_sample_file(
json.dump(jsondict, fd, indent=3)


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def run_convergence_evaluation_from_sample_file(sample_file):
"""
Run convergence evaluation using specified sample file.
Expand Down Expand Up @@ -624,6 +655,11 @@ def run_convergence_evaluation_from_sample_file(sample_file):
return run_convergence_evaluation(jsondict, conv_eval)


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def run_single_sample_from_sample_file(sample_file, name):
"""
Run single convergence evaluation from sample in provided file.
Expand Down Expand Up @@ -657,6 +693,11 @@ def run_single_sample_from_sample_file(sample_file, name):
return run_single_sample(jsondict, conv_eval, name)


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def run_single_sample(sample_file_dict, conv_eval, name):
"""
Run single sample from dict and return IPOPT stats.
Expand All @@ -676,6 +717,11 @@ def run_single_sample(sample_file_dict, conv_eval, name):
return _run_ipopt_with_stats(model, solver)


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def run_convergence_evaluation(sample_file_dict, conv_eval):
"""
Run convergence evaluation and generate the statistics based on information
Expand Down Expand Up @@ -754,6 +800,11 @@ def run_convergence_evaluation(sample_file_dict, conv_eval):
return inputs, samples, global_results


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def generate_baseline_statistics(
conv_eval, n_points: int, seed: int = None, display: bool = True
):
Expand Down Expand Up @@ -818,6 +869,11 @@ def generate_baseline_statistics(
return jsondict


@deprecated(
msg="This function has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
def save_convergence_statistics(
inputs, results, dmf=None, display=True, json_path=None, report_path=None
):
Expand All @@ -838,6 +894,11 @@ def save_convergence_statistics(
return s


@deprecated(
msg="This class has been deprecated in favor of the new Parameter Sweep "
"tools and may be removed in a future release.",
version="2.3.0",
)
class Stats(object):
def __init__(self, inputs=None, results=None, from_dict=None, from_json=None):
"""A convergence stats and results object. This class stores the
Expand Down

0 comments on commit bffa953

Please sign in to comment.