Changeset 9493


Ignore:
Timestamp:
Dec 14, 2014 10:52:09 PM (4 years ago)
Author:
wehart
Message:

Updating relaxation tests. These were disabled (expected
failures). Also, added a test that verifies that
relaxation occurs over indexed variables.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyomo/trunk/pyomo/core/tests/transform/test_transform.py

    r9486 r9493  
    3737            return False
    3838
    39     @unittest.expectedFailure
    4039    def test_relax_integrality1(self):
    41         """ Coverage of the _clear_attribute method """
     40        # Coverage of the _clear_attribute method
    4241        self.model.A = RangeSet(1,4)
    4342        self.model.a = Var()
     
    4847        self.model.f = Var(domain=Boolean)
    4948        instance=self.model.create()
    50         rinst = apply_transformation('relax_integrality',instance)
     49        rinst = apply_transformation('base.relax_integrality',instance)
    5150        self.assertEqual(type(rinst.a.domain), type(Reals))
    52         self.assertEqual(type(rinst.b.domain), type(Reals))
    53         self.assertEqual(type(rinst.c.domain), type(Reals))
     51        self.assertEqual(type(rinst.b.domain), RealInterval)
     52        self.assertEqual(type(rinst.c.domain), RealInterval)
    5453        self.assertEqual(type(rinst.d.domain), type(Reals))
    55         self.assertEqual(type(rinst.e.domain), type(Reals))
    56         self.assertEqual(type(rinst.f.domain), type(Reals))
     54        self.assertEqual(type(rinst.e.domain), RealInterval)
     55        self.assertEqual(type(rinst.f.domain), RealInterval)
    5756        self.assertEqual(rinst.a.bounds, instance.a.bounds)
    5857        self.assertEqual(rinst.b.bounds, instance.b.bounds)
     
    6160        self.assertEqual(rinst.e.bounds, instance.e.bounds)
    6261        self.assertEqual(rinst.f.bounds, instance.f.bounds)
     62
     63    def test_relax_integrality2(self):
     64        # Coverage of the _clear_attribute method
     65        self.model.A = RangeSet(1,4)
     66        self.model.a = Var([1,2,3])
     67        self.model.b = Var([1,2,3], within=self.model.A)
     68        self.model.c = Var([1,2,3], within=NonNegativeIntegers)
     69        self.model.d = Var([1,2,3], within=Integers, bounds=(-2,3))
     70        self.model.e = Var([1,2,3], within=Boolean)
     71        self.model.f = Var([1,2,3], domain=Boolean)
     72        instance=self.model.create()
     73        rinst = apply_transformation('base.relax_integrality',instance)
     74        self.assertEqual(type(rinst.a[1].domain), type(Reals))
     75        self.assertEqual(type(rinst.b[1].domain), RealInterval)
     76        self.assertEqual(type(rinst.c[1].domain), RealInterval)
     77        self.assertEqual(type(rinst.d[1].domain), type(Reals))
     78        self.assertEqual(type(rinst.e[1].domain), RealInterval)
     79        self.assertEqual(type(rinst.f[1].domain), RealInterval)
     80        self.assertEqual(rinst.a[1].bounds, instance.a[1].bounds)
     81        self.assertEqual(rinst.b[1].bounds, instance.b[1].bounds)
     82        self.assertEqual(rinst.c[1].bounds, instance.c[1].bounds)
     83        self.assertEqual(rinst.d[1].bounds, instance.d[1].bounds)
     84        self.assertEqual(rinst.e[1].bounds, instance.e[1].bounds)
     85        self.assertEqual(rinst.f[1].bounds, instance.f[1].bounds)
    6386
    6487    def test_apply_transformation1(self):
Note: See TracChangeset for help on using the changeset viewer.