IDAES / idaes-pse

The IDAES Process Systems Engineering Framework
https://idaes-pse.readthedocs.io/
Other
216 stars 234 forks source link

Pysmo fails on ARM64 #841

Closed eslickj closed 1 year ago

eslickj commented 2 years ago

On both macOS and all Linux distress I tried with ARM64 processors Pysmo tests fails. I can't really see a clear reason by the test output is below.


=================================== FAILURES ===================================
______________ TestPysmoSurrogate.test_evaluate_unisurrogate_poly ______________

self = <idaes.core.surrogate.tests.test_pysmo_surrogate.TestPysmoSurrogate object at 0xffff71c686a0>
pysmo_surr1 = <idaes.core.surrogate.pysmo_surrogate.PysmoSurrogate object at 0xffff8abae430>

    @pytest.mark.unit
    def test_evaluate_unisurrogate_poly(self, pysmo_surr1):
        # Test ``evaluate_surrogate`` for one output with interaction terms
        x = [
            -2,
            -1.8,
            -1.6,
            -1.4,
            -1.2,
            -1.0,
            -0.8,
            -0.6,
            -0.4,
            -0.2,
            0,
            0.2,
            0.4,
            0.6,
            0.8,
            1.0,
            1.2,
            1.4,
            1.6,
            1.8,
            2.0,
        ]

        inputs = np.array([np.tile(x, len(x)), np.repeat(x, len(x))])
        inputs = pd.DataFrame(inputs.transpose(), columns=["x1", "x2"])

        out = pysmo_surr1.evaluate_surrogate(inputs)
        for i in range(inputs.shape[0]):
>           assert pytest.approx(out["z1"][i], rel=1e-8) == (
                -75.26111111111476
                - 8.815277777775934 * inputs["x1"][i]
                + 18.81527777777826 * inputs["x2"][i]
                - 2.2556956302821618e-13 * (inputs["x2"][i] * inputs["x1"][i])
            )
E           assert -38.372222222227634 ± 3.8e-07 == -95.26111111112031
E             comparison failed
E             Obtained: -95.26111111112031
E             Expected: -38.372222222227634 ± 3.8e-07

core/surrogate/tests/test_pysmo_surrogate.py:1357: AssertionError
---------------------------- Captured stdout setup -----------------------------

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

max_fraction_training_samples set at  0.5
Number of adaptive samples (no_adaptive_samples) set at  4
Maximum number of iterations (Max_iter) set at:  0

Initial surrogate model is of order 1  with a cross-val error of 0.000000
Initial Regression Model Performance:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000  / Adjusted R^2: 1.000000

Polynomial regression generates a good surrogate model for the input data.

-------------------------------------------------
-------------------------------------------------
Best solution found:  
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R_sq: 1.000000  / Adjusted R^2: 1.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | -18.372222
(x_ 1 )^ 1      | 5.406944
(x_ 2 )^ 1      | 4.593056
x_ 1 .x_ 2      | -0.0

Results saved in  solution.pickle
2022-05-03 20:00:30 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z1 trained successfully
------------------------------ Captured log setup ------------------------------
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z1 trained successfully
___________ TestPysmoSurrogate.test_populate_block_unisurrogate_poly ___________

self = <idaes.core.surrogate.tests.test_pysmo_surrogate.TestPysmoSurrogate object at 0xffff725f30a0>
pysmo_surr1 = <idaes.core.surrogate.pysmo_surrogate.PysmoSurrogate object at 0xffff8a7bca30>

    @pytest.mark.unit
    def test_populate_block_unisurrogate_poly(self, pysmo_surr1):
        # Test ``populate_block`` for one output with interaction terms
        blk = SurrogateBlock(concrete=True)

        blk.build_model(pysmo_surr1)
        blk.display()

        assert isinstance(blk.inputs, Var)
        assert blk.inputs["x1"].bounds == (0, 5)
        assert blk.inputs["x2"].bounds == (0, 10)
        assert isinstance(blk.outputs, Var)
        assert blk.outputs["z1"].bounds == (None, None)
        assert isinstance(blk.pysmo_constraint, Constraint)
        assert len(blk.pysmo_constraint) == 1
>       assert str(blk.pysmo_constraint["z1"].body) == (
            "outputs[z1] - (-75.26111111111476 - 8.815277777775934*inputs[x1] + 18.81527777777826*inputs[x2] - 2.2556956302821618e-13*(inputs[x2]*inputs[x1]))"
        )
E       AssertionError: assert 'outputs[z1] ...*inputs[x1]))' == 'outputs[z1] ...*inputs[x1]))'
E         - outputs[z1] - (-75.26111111111476 - 8.815277777775934*inputs[x1] + 18.81527777777826*inputs[x2] - 2.2556956302821618e-13*(inputs[x2]*inputs[x1]))
E         + outputs[z1] - (-18.37222222222536 + 5.406944444444783*inputs[x1] + 4.593055555556168*inputs[x2] - 9.323097849289752e-14*(inputs[x2]*inputs[x1]))

core/surrogate/tests/test_pysmo_surrogate.py:1379: AssertionError
---------------------------- Captured stdout setup -----------------------------

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

max_fraction_training_samples set at  0.5
Number of adaptive samples (no_adaptive_samples) set at  4
Maximum number of iterations (Max_iter) set at:  0

Initial surrogate model is of order 1  with a cross-val error of 0.000000
Initial Regression Model Performance:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000  / Adjusted R^2: 1.000000

Polynomial regression generates a good surrogate model for the input data.

-------------------------------------------------
-------------------------------------------------
Best solution found:  
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R_sq: 1.000000  / Adjusted R^2: 1.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | -18.372222
(x_ 1 )^ 1      | 5.406944
(x_ 2 )^ 1      | 4.593056
x_ 1 .x_ 2      | -0.0

Results saved in  solution.pickle
2022-05-03 20:00:30 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z1 trained successfully
------------------------------ Captured log setup ------------------------------
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z1 trained successfully
----------------------------- Captured stdout call -----------------------------
Setting bound of inputs[x1] to (0, 5).
Setting bound of inputs[x2] to (0, 10).
Model _ScalarSurrogateBlock

  Variables:
    inputs : Size=2, Index=inputs_set
        Key : Lower : Value : Upper : Fixed : Stale : Domain
         x1 :     0 :     0 :     5 : False : False :  Reals
         x2 :     0 :     0 :    10 : False : False :  Reals
    outputs : Size=1, Index=outputs_set
        Key : Lower : Value : Upper : Fixed : Stale : Domain
         z1 :  None :     0 :  None : False : False :  Reals

  Objectives:
    None

  Constraints:
    pysmo_constraint : Size=1
        Key : Lower : Body              : Upper
         z1 :   0.0 : 18.37222222222536 :   0.0
_____________ TestPysmoSurrogate.test_evaluate_multisurrogate_poly _____________

self = <idaes.core.surrogate.tests.test_pysmo_surrogate.TestPysmoSurrogate object at 0xffff721cbb50>
pysmo_surr2_poly = (<idaes.core.surrogate.pysmo_surrogate.PysmoTrainedSurrogate object at 0xffff68660d00>, <idaes.core.surrogate.pysmo_surrogate.PysmoSurrogate object at 0xffff68660220>)

    @pytest.mark.unit
    def test_evaluate_multisurrogate_poly(self, pysmo_surr2_poly):
        # Test ``evaluate_surrogate`` for multiple output polynomials with interaction terms
        x = [
            -2,
            -1.8,
            -1.6,
            -1.4,
            -1.2,
            -1.0,
            -0.8,
            -0.6,
            -0.4,
            -0.2,
            0,
            0.2,
            0.4,
            0.6,
            0.8,
            1.0,
            1.2,
            1.4,
            1.6,
            1.8,
            2.0,
        ]

        inputs = np.array([np.tile(x, len(x)), np.repeat(x, len(x))])
        inputs = pd.DataFrame(inputs.transpose(), columns=["x1", "x2"])

        _, poly_trained = pysmo_surr2_poly
        out = poly_trained.evaluate_surrogate(inputs)
        for i in range(inputs.shape[0]):
>           assert pytest.approx(out["z1"][i], rel=1e-8) == (
                -75.26111111111476
                - 8.815277777775934 * inputs["x1"][i]
                + 18.81527777777826 * inputs["x2"][i]
                - 2.2556956302821618e-13 * (inputs["x2"][i] * inputs["x1"][i])
            )
E           assert -38.372222222227634 ± 3.8e-07 == -95.26111111112031
E             comparison failed
E             Obtained: -95.26111111112031
E             Expected: -38.372222222227634 ± 3.8e-07

core/surrogate/tests/test_pysmo_surrogate.py:1416: AssertionError
---------------------------- Captured stdout setup -----------------------------

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

max_fraction_training_samples set at  0.5
Number of adaptive samples (no_adaptive_samples) set at  4
Maximum number of iterations (Max_iter) set at:  0

Initial surrogate model is of order 1  with a cross-val error of 0.000000
Initial Regression Model Performance:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000  / Adjusted R^2: 1.000000

Polynomial regression generates a good surrogate model for the input data.

-------------------------------------------------
-------------------------------------------------
Best solution found:  
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R_sq: 1.000000  / Adjusted R^2: 1.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | -18.372222
(x_ 1 )^ 1      | 5.406944
(x_ 2 )^ 1      | 4.593056
x_ 1 .x_ 2      | -0.0

Results saved in  solution.pickle
2022-05-03 20:00:30 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z1 trained successfully

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

max_fraction_training_samples set at  0.5
Number of adaptive samples (no_adaptive_samples) set at  4
Maximum number of iterations (Max_iter) set at:  0

Initial surrogate model is of order 1  with a cross-val error of 0.000000
Initial Regression Model Performance:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000  / Adjusted R^2: 1.000000

Polynomial regression generates a good surrogate model for the input data.

-------------------------------------------------
-------------------------------------------------
Best solution found:  
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R_sq: 1.000000  / Adjusted R^2: 1.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | 1.942932
(x_ 1 )^ 1      | 1.485733
(x_ 2 )^ 1      | 0.514267
x_ 1 .x_ 2      | 0.0

Results saved in  solution.pickle
2022-05-03 20:00:30 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z2 trained successfully
------------------------------ Captured log setup ------------------------------
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z1 trained successfully
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z2 trained successfully
__________ TestPysmoSurrogate.test_populate_block_multisurrogate_poly __________

self = <idaes.core.surrogate.tests.test_pysmo_surrogate.TestPysmoSurrogate object at 0xffff721c1b80>
pysmo_surr2_poly = (<idaes.core.surrogate.pysmo_surrogate.PysmoTrainedSurrogate object at 0xffff8aa9b310>, <idaes.core.surrogate.pysmo_surrogate.PysmoSurrogate object at 0xffff72eea4f0>)

    @pytest.mark.unit
    def test_populate_block_multisurrogate_poly(self, pysmo_surr2_poly):
        # Test ``populate_block`` for multiple output polynomials with interaction terms
        blk = SurrogateBlock(concrete=True)

        (
            _,
            poly_trained,
        ) = pysmo_surr2_poly
        blk.build_model(poly_trained)

        assert isinstance(blk.inputs, Var)
        assert blk.inputs["x1"].bounds == (None, None)
        assert blk.inputs["x2"].bounds == (None, None)
        assert isinstance(blk.outputs, Var)
        assert blk.outputs["z1"].bounds == (None, None)
        assert blk.outputs["z2"].bounds == (None, None)
        assert isinstance(blk.pysmo_constraint, Constraint)
        assert len(blk.pysmo_constraint) == 2
>       assert str(blk.pysmo_constraint["z1"].body) == (
            "outputs[z1] - (-75.26111111111476 - 8.815277777775934*inputs[x1] + 18.81527777777826*inputs[x2] - 2.2556956302821618e-13*(inputs[x2]*inputs[x1]))"
        )
E       AssertionError: assert 'outputs[z1] ...*inputs[x1]))' == 'outputs[z1] ...*inputs[x1]))'
E         - outputs[z1] - (-75.26111111111476 - 8.815277777775934*inputs[x1] + 18.81527777777826*inputs[x2] - 2.2556956302821618e-13*(inputs[x2]*inputs[x1]))
E         + outputs[z1] - (-18.37222222222536 + 5.406944444444783*inputs[x1] + 4.593055555556168*inputs[x2] - 9.323097849289752e-14*(inputs[x2]*inputs[x1]))

core/surrogate/tests/test_pysmo_surrogate.py:1448: AssertionError
---------------------------- Captured stdout setup -----------------------------

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

max_fraction_training_samples set at  0.5
Number of adaptive samples (no_adaptive_samples) set at  4
Maximum number of iterations (Max_iter) set at:  0

Initial surrogate model is of order 1  with a cross-val error of 0.000000
Initial Regression Model Performance:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000  / Adjusted R^2: 1.000000

Polynomial regression generates a good surrogate model for the input data.

-------------------------------------------------
-------------------------------------------------
Best solution found:  
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R_sq: 1.000000  / Adjusted R^2: 1.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | -18.372222
(x_ 1 )^ 1      | 5.406944
(x_ 2 )^ 1      | 4.593056
x_ 1 .x_ 2      | -0.0

Results saved in  solution.pickle
2022-05-03 20:00:30 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z1 trained successfully

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

max_fraction_training_samples set at  0.5
Number of adaptive samples (no_adaptive_samples) set at  4
Maximum number of iterations (Max_iter) set at:  0

Initial surrogate model is of order 1  with a cross-val error of 0.000000
Initial Regression Model Performance:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000  / Adjusted R^2: 1.000000

Polynomial regression generates a good surrogate model for the input data.

-------------------------------------------------
-------------------------------------------------
Best solution found:  
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R_sq: 1.000000  / Adjusted R^2: 1.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | 1.942932
(x_ 1 )^ 1      | 1.485733
(x_ 2 )^ 1      | 0.514267
x_ 1 .x_ 2      | 0.0

Results saved in  solution.pickle
2022-05-03 20:00:30 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z2 trained successfully
------------------------------ Captured log setup ------------------------------
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z1 trained successfully
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z2 trained successfully
_________ TestPysmoSurrogate.test_evaluate_multisurrogate_poly_userdef _________

self = <idaes.core.surrogate.tests.test_pysmo_surrogate.TestPysmoSurrogate object at 0xffff721c1640>
pysmo_surr4 = <idaes.core.surrogate.pysmo_surrogate.PysmoSurrogate object at 0xffff6a78dc70>

    @pytest.mark.unit
    def test_evaluate_multisurrogate_poly_userdef(self, pysmo_surr4):
        # Test ``evaluate_surrogate`` for multiple output polynomials with ratio-type user-defined features
        x = [
            -2,
            -1.8,
            -1.6,
            -1.4,
            -1.2,
            -1.0,
            -0.8,
            -0.6,
            -0.4,
            -0.2,
            0.2,
            0.4,
            0.6,
            0.8,
            1.0,
            1.2,
            1.4,
            1.6,
            1.8,
            2.0,
            2.2,
        ]

        inputs = np.array([np.tile(x, len(x)), np.repeat(x, len(x))])
        inputs = pd.DataFrame(inputs.transpose(), columns=["x1", "x2"])

        out = pysmo_surr4.evaluate_surrogate(inputs)
        for i in range(inputs.shape[0]):
>           assert pytest.approx(out["z1"][i], rel=1e-8) == (
                -110.15000000001504
                - 17.53750000000189 * inputs["x1"][i]
                + 27.537500000006148 * inputs["x2"][i]
                - 5.3967136315336006e-11 * (inputs["x1"][i] / inputs["x2"][i])
            )
E           assert -22.133323509263356 ± 2.2e-07 == -130.15000000007754
E             comparison failed
E             Obtained: -130.15000000007754
E             Expected: -22.133323509263356 ± 2.2e-07

core/surrogate/tests/test_pysmo_surrogate.py:1601: AssertionError
---------------------------- Captured stdout setup -----------------------------

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

No iterations will be run.

Best surrogate model is of order 1  with a cross-val S.S. Error  of 0.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | -2.133333
(x_ 1 )^ 1      | 9.466666
(x_ 2 )^ 1      | 0.533333

The coefficients of the extra terms in additional_regression_features are:

Coeff. additional_regression_features[ 1 ]:  8e-06

Regression model performance on training data:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000

Results saved in  solution.pickle
2022-05-03 20:00:30 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z1 trained successfully

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

No iterations will be run.

Best surrogate model is of order 1  with a cross-val S.S. Error  of 0.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | 0.088889
(x_ 1 )^ 1      | 1.022222
(x_ 2 )^ 1      | 0.977778

The coefficients of the extra terms in additional_regression_features are:

Coeff. additional_regression_features[ 1 ]:  0.0

Regression model performance on training data:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000

Results saved in  solution.pickle
2022-05-03 20:00:30 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z2 trained successfully
------------------------------ Captured log setup ------------------------------
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z1 trained successfully
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z2 trained successfully
______ TestPysmoSurrogate.test_populate_block_multisurrogate_poly_userdef ______

self = <idaes.core.surrogate.tests.test_pysmo_surrogate.TestPysmoSurrogate object at 0xffff721c16a0>
pysmo_surr4 = <idaes.core.surrogate.pysmo_surrogate.PysmoSurrogate object at 0xffff6bb055b0>

    @pytest.mark.unit
    def test_populate_block_multisurrogate_poly_userdef(self, pysmo_surr4):
        # Test ``populate_block`` for multiple output polynomials with interaction terms
        blk = SurrogateBlock(concrete=True)

        blk.build_model(pysmo_surr4)

        assert isinstance(blk.inputs, Var)
        assert blk.inputs["x1"].bounds == (None, None)
        assert blk.inputs["x2"].bounds == (None, None)
        assert isinstance(blk.outputs, Var)
        assert blk.outputs["z1"].bounds == (None, None)
        assert blk.outputs["z2"].bounds == (None, None)
        assert isinstance(blk.pysmo_constraint, Constraint)
        assert len(blk.pysmo_constraint) == 2
>       assert str(blk.pysmo_constraint["z1"].body) == (
            "outputs[z1] - (-110.15000000001504 - 17.53750000000189*inputs[x1] + 27.537500000006148*inputs[x2] - 5.3967136315336006e-11*(inputs[x1]/inputs[x2]))"
        )
E       AssertionError: assert 'outputs[z1] .../inputs[x2]))' == 'outputs[z1] .../inputs[x2]))'
E         - outputs[z1] - (-110.15000000001504 - 17.53750000000189*inputs[x1] + 27.537500000006148*inputs[x2] - 5.3967136315336006e-11*(inputs[x1]/inputs[x2]))
E         + outputs[z1] - (-2.1333333038658475 + 9.466666246499225*inputs[x1] + 0.5333330308951045*inputs[x2] + 8.34939114827528e-06*(inputs[x1]/inputs[x2]))

core/surrogate/tests/test_pysmo_surrogate.py:1629: AssertionError
---------------------------- Captured stdout setup -----------------------------

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

No iterations will be run.

Best surrogate model is of order 1  with a cross-val S.S. Error  of 0.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | -2.133333
(x_ 1 )^ 1      | 9.466666
(x_ 2 )^ 1      | 0.533333

The coefficients of the extra terms in additional_regression_features are:

Coeff. additional_regression_features[ 1 ]:  8e-06

Regression model performance on training data:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000

Results saved in  solution.pickle
2022-05-03 20:00:31 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z1 trained successfully

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

No iterations will be run.

Best surrogate model is of order 1  with a cross-val S.S. Error  of 0.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | 0.088889
(x_ 1 )^ 1      | 1.022222
(x_ 2 )^ 1      | 0.977778

The coefficients of the extra terms in additional_regression_features are:

Coeff. additional_regression_features[ 1 ]:  0.0

Regression model performance on training data:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000

Results saved in  solution.pickle
2022-05-03 20:00:31 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z2 trained successfully
------------------------------ Captured log setup ------------------------------
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z1 trained successfully
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z2 trained successfully
______________________ TestPysmoSurrogate.test_save_poly1 ______________________

self = <idaes.core.surrogate.tests.test_pysmo_surrogate.TestPysmoSurrogate object at 0xffff71cb7310>
pysmo_surr1 = <idaes.core.surrogate.pysmo_surrogate.PysmoSurrogate object at 0xffff6b8c24c0>

    @pytest.mark.unit
    def test_save_poly1(self, pysmo_surr1):
        # Test save for polynomial regression with single output with bounds supplied
        stream1 = StringIO()
        pysmo_surr1.save(stream1)
>       assert re.sub("errors.*?}", "", jstring_poly_1) == re.sub(
            "errors.*?}", "", stream1.getvalue()
        )
E       assert '{"model_enco...ype": "poly"}' == '{"model_enco...ype": "poly"}'
E         Skipping 149 identical leading characters in diff, use -v to show
E         - rray": [[-18.37222222222536], [5.406944444444783], [4.593055555556168], [-9.323097849289752e-14]], "final_polynomial_order": 1, ", "extra_terms_feature_vector": ["IndexedParam[x1]", "IndexedParam[x2]"]}, "map": {"regression_data_columns": "list", "multinomials": "str", "additional_term_expressions": "list", "optimal_weights_array": "numpy", "final_polynomial_order": "str", "}}, "input_labels": ["x1", "x2"], "output_labels": ["z1"], "input_bounds": {"x1": [0, 5], "x2": [0, 10]}, "surrogate_type": "poly"}
E         ?...
E         
E         ...Full output truncated (3 lines hidden), use '-vv' to show

core/surrogate/tests/test_pysmo_surrogate.py:2030: AssertionError
---------------------------- Captured stdout setup -----------------------------

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

max_fraction_training_samples set at  0.5
Number of adaptive samples (no_adaptive_samples) set at  4
Maximum number of iterations (Max_iter) set at:  0

Initial surrogate model is of order 1  with a cross-val error of 0.000000
Initial Regression Model Performance:
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R^2: 1.000000  / Adjusted R^2: 1.000000

Polynomial regression generates a good surrogate model for the input data.

-------------------------------------------------
-------------------------------------------------
Best solution found:  
Order:  1  / MAE: 0.000000  / MSE: 0.000000  / R_sq: 1.000000  / Adjusted R^2: 1.000000

------------------------------------------------------------
The final coefficients of the regression terms are: 

k               | -18.372222
(x_ 1 )^ 1      | 5.406944
(x_ 2 )^ 1      | 4.593056
x_ 1 .x_ 2      | -0.0

Results saved in  solution.pickle
2022-05-03 20:00:31 [INFO] idaes.core.surrogate.pysmo_surrogate: Model for output z1 trained successfully
------------------------------ Captured log setup ------------------------------
INFO     idaes.core.surrogate.pysmo_surrogate:pysmo_surrogate.py:225 Model for output z1 trained successfully
______________________ TestPysmoSurrogate.test_save_poly2 ______________________

self = <idaes.core.surrogate.tests.test_pysmo_surrogate.TestPysmoSurrogate object at 0xffff71cb7130>
pysmo_surr2_poly = (<idaes.core.surrogate.pysmo_surrogate.PysmoTrainedSurrogate object at 0xffff6bd43070>, <idaes.core.surrogate.pysmo_surrogate.PysmoSurrogate object at 0xffff6bd43250>)

    @pytest.mark.unit
    def test_save_poly2(self, pysmo_surr2_poly):
        # Test save for polynomial regression with multiple outputs - most complicated to save
        _, poly_trained = pysmo_surr2_poly
        stream2a = StringIO()
        poly_trained.save(stream2a)
>       assert re.sub("errors.*?}", "", jstring_poly_2) == re.sub(
            "errors.*?}", "", stream2a.getvalue()
        )
E       assert '{"model_enco...ype": "poly"}' == '{"model_enco...ype": "poly"}'
E         Skipping 149 identical leading characters in diff, use -v to show
E         - rray": [[-18.37222222222536], [5.406944444444783], [4.593055555556168], [-9.323097849289752e-14]], "final_polynomial_order": 1, ", "extra_terms_feature_vector": ["IndexedParam[x1]", "IndexedParam[x2]"]}, "map": {"regression_data_columns": "list", "multinomials": "str", "additional_term_expressions": "list", "optimal_weights_array": "numpy", "final_polynomial_order": "str", "}, "z2": {"attr": {"regression_data_columns": ["x1", "x2"], "multinomials": 1, "additional_term_expressions": [], "optimal_weights_a...
E         
E         ...Full output truncated (2 lines hidden), use '-vv' to show

core/surrogate/tests/test_pysmo_surrogate.py:2040: AssertionError
---------------------------- Captured stdout setup -----------------------------

===========================Polynomial Regression===============================================

Warning: solution.pickle already exists; previous file will be overwritten.

No iterations will be run.
Default parameter estimation method is used.
Parameter estimation method:  pyomo 

max_fraction_training_samples set at  0.5
Number of adaptive samples (no_adaptive_samples) ```
eslickj commented 2 years ago

I think I found the issue. The tests that fail seem to have multiple solutions. It seems it's not a problem with Pysmo just that the tests have different equally good results. Here's an example from the first failure. pysmo_test.xlsx

OOAmusat commented 2 years ago

Yeah, I suspected that was the problem given the small size of the training data and the fact that the input variables are strongly correlated. I will probably have to increase the training set size or define a different test problem entirely.

andrewlee94 commented 2 years ago

@OOAmusat Any update on this issue? I assume it is not making it into the August release at this point,

OOAmusat commented 2 years ago

@andrewlee94 No updates for now. It'll be addressed, but not before the August release.

ksbeattie commented 1 year ago

@OOAmusat any time soon to get to this?

OOAmusat commented 1 year ago

@ksbeattie Not likely. I think we should probably close this for now

eslickj commented 1 year ago

The problem is pretty straight forward and it would be nice if it didn't fail on ARM64. Maybe I can take a little time to see if there is a quick fix to make it so there is unique solution for the test problem.

eslickj commented 1 year ago

I think this should be fixed in PR #1070.

andrewlee94 commented 1 year ago

Closing as fixed, although we are seeing some random failures for one test case (Kriging) - we suspect that this is due to random sampling which should be fixed.