Пример #1
0
    def test_kaug_deprecated(self):
        m = param_ex.create_model()
        m.perturbed_eta1 = Param(initialize = 4.0)
        m.perturbed_eta2 = Param(initialize = 1.0)

        output = StringIO()
        with LoggingIntercept(output, 'pyomo.contrib.sensitivity_toolbox', logging.WARNING):
            kaug(m,[m.eta1,m.eta1],
                 [m.perturbed_eta1,m.perturbed_eta2],
                 cloneModel=False)        
        self.assertIn("DEPRECATED: The kaug function has been deprecated. Use the "
                      "sensitivity_calculation() function with method='k_aug'",
                      output.getvalue().replace('\n', ' '))
Пример #2
0
    def test_kaug_equivalent(self):
        m1 = param_ex.create_model()
        m1.perturbed_eta1 = Param(initialize = 4.0)
        m1.perturbed_eta2 = Param(initialize = 1.0)

        m2 = param_ex.create_model()
        m2.perturbed_eta1 = Param(initialize = 4.0)
        m2.perturbed_eta2 = Param(initialize = 1.0)

        m11 = kaug(m1,[m1.eta1,m1.eta2],
                   [m1.perturbed_eta1,m1.perturbed_eta2],
                   cloneModel=True)        
        m22 = sensitivity_calculation('k_aug',m2,[m2.eta1,m2.eta2],
                                      [m2.perturbed_eta1,m2.perturbed_eta2],
                                      cloneModel=True)        
        out1 = StringIO()
        out2 = StringIO()
        m11._SENSITIVITY_TOOLBOX_DATA.constList.pprint(ostream=out1)
        m22._SENSITIVITY_TOOLBOX_DATA.constList.pprint(ostream=out2)
        self.assertMultiLineEqual(out1.getvalue(), out2.getvalue())