Ignore:
Timestamp:
Jan 2, 2010 2:45:21 AM (10 years ago)
Author:
wehart
Message:

Changing the API of the SolutionSet? object. Now, all variables, constraints, etc
can be indexed with 1-based integer indices (rather than 0-based). This change
makes this object consistent with the 1-based indexing API supported by Pyomo.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.opt/trunk/coopr/opt/tests/base/test_soln.py

    r1937 r2109  
    3434        self.results = coopr.opt.SolverResults()
    3535        self.soln = self.results.solution.add()
    36         self.soln.variable[0]=0.0
    3736        self.soln.variable[1]=0.0
    38         self.soln.variable[3]=0.0
     37        self.soln.variable[2]=0.0
     38        self.soln.variable[4]=0.0
    3939        pyutilib.services.TempfileManager.clear_tempfiles()
    4040
     
    118118    def test_soln_pprint1(self):
    119119        """ Write a solution with only zero values, using the results 'write()' method """
    120         self.soln.variable[0]=0.0
    121120        self.soln.variable[1]=0.0
    122         self.soln.variable[3]=0.0
     121        self.soln.variable[2]=0.0
     122        self.soln.variable[4]=0.0
    123123        self.results.write(filename=currdir+"soln_pprint.txt")
    124124        if not os.path.exists(currdir+"soln_pprint.txt"):
     
    128128    def test_soln_pprint2(self):
    129129        """ Write a solution with only zero values, using the Solution.pprint() method """
    130         self.soln.variable[0]=0.0
    131130        self.soln.variable[1]=0.0
    132         self.soln.variable[3]=0.0
     131        self.soln.variable[2]=0.0
     132        self.soln.variable[4]=0.0
    133133        pyutilib.misc.setup_redirect(currdir+"soln_pprint2.out")
    134134        print self.soln
     
    139139    def test_soln_suffix_iter(self):
    140140        """ Test a suffix iterator """
    141         self.soln.variable[0]=0.0
    142         self.soln.variable[1]=0.1
    143         self.soln.variable[3]=0.3
     141        self.soln.variable[1]=0.0
     142        self.soln.variable[2]=0.1
     143        self.soln.variable[4]=0.3
    144144        i=0
    145145        for key in self.soln.variable:
     
    150150    def test_soln_suffix_getiter(self):
    151151        self.soln.variable["x0"]=0.0
    152         self.soln.variable[1]=0.1
     152        self.soln.variable[2]=0.1
    153153        self.soln.variable["x3"]=0.3
    154154        self.failUnlessEqual(self.soln.variable["x3"].value,0.3)
    155155        #print "HERE",self.soln.variable._names
    156         self.failUnlessEqual(self.soln.variable[1].value,0.1)
     156        self.failUnlessEqual(self.soln.variable[2].value,0.1)
    157157
    158158    def test_soln_suffix_setattr(self):
Note: See TracChangeset for help on using the changeset viewer.