Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecating RBF options in ALMAOpy #1226

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
17 changes: 13 additions & 4 deletions idaes/core/surrogate/alamopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class Screener(Enum):
"sinfcns",
"cosfcns",
"constant",
"grbfcns",
"rbfparam",
# "grbfcns", # TODO: deprecated
# "rbfparam", # TODO: deprecated
"modeler",
"builder",
"backstepper",
Expand Down Expand Up @@ -282,15 +282,15 @@ class AlamoTrainer(SurrogateTrainer):
description="Include cosine basis functions if True.",
),
)
CONFIG.declare(
CONFIG.declare( # TODO: deprecated option
"grbfcns",
ConfigValue(
default=None,
domain=Bool,
description="Include Gaussian radial basis functions if True.",
),
)
CONFIG.declare(
CONFIG.declare( # TODO: deprecated option
"rbfparam",
ConfigValue(
default=None,
Expand Down Expand Up @@ -669,6 +669,15 @@ class AlamoTrainer(SurrogateTrainer):
def __init__(self, **settings):
super().__init__(**settings)

# TODO: Deprecation warnings for RBF options
if self.config.grbfcns is not None or self.config.rbfparam is not None:
raise ConfigurationError(
"Support for radial basis functions in the ALAMOpy wrapper have been "
"deprecated due to limitations in the current implementation. "
"Pull requests are welcome to address this, otherwise we recommend using "
"Pysmo which includes support for radial basis functions."
)

self._temp_context = None
self._almfile = None
self._trcfile = None
Expand Down
41 changes: 39 additions & 2 deletions idaes/core/surrogate/tests/test_alamopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,45 @@ def alamo_trainer(self):
training_dataframe=data,
)

@pytest.mark.unit
def test_rbf_deprecation(self):
data = {"x1": [1, 2, 3, 4], "x2": [5, 6, 7, 8], "z1": [10, 20, 30, 40]}
data = pd.DataFrame(data)

input_labels = ["x1", "x2"]
output_labels = ["z1"]
bnds = {"x1": (0, 5), "x2": (0, 10)}

with pytest.raises(
ConfigurationError,
match="Support for radial basis functions in the ALAMOpy wrapper have been "
"deprecated due to limitations in the current implementation. "
"Pull requests are welcome to address this, otherwise we recommend using "
"Pysmo which includes support for radial basis functions.",
):
AlamoTrainer(
input_labels=input_labels,
output_labels=output_labels,
input_bounds=bnds,
training_dataframe=data,
grbfcns=True,
)

with pytest.raises(
ConfigurationError,
match="Support for radial basis functions in the ALAMOpy wrapper have been "
"deprecated due to limitations in the current implementation. "
"Pull requests are welcome to address this, otherwise we recommend using "
"Pysmo which includes support for radial basis functions.",
):
AlamoTrainer(
input_labels=input_labels,
output_labels=output_labels,
input_bounds=bnds,
training_dataframe=data,
rbfparam=1.0,
)

@pytest.mark.unit
def test_get_files(self, alamo_trainer):
alamo_trainer.config.filename = "foo.alm"
Expand Down Expand Up @@ -486,8 +525,6 @@ def test_writer_full_config(self, alamo_trainer):
"sinfcns 1\n"
"cosfcns 0\n"
"constant 1\n"
"grbfcns 1\n"
"rbfparam 7.0\n"
"modeler 3\n"
"builder 1\n"
"backstepper 0\n"
Expand Down
Loading