Ticket #7805: trac_7805.patch

File trac_7805.patch, 1.9 KB (added by ncohen, 10 years ago)
  • sage/numerical/mip.pyx

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1263657713 -3600
    # Node ID aa038f082d348797931963a983c8963849b4f39c
    # Parent  33c04bb5aea0255c4fac02782a9974deaf33f1ce
    Smqll updqte of MixedIntegerLinearProgram.show
    
    diff -r 33c04bb5aea0 -r aa038f082d34 sage/numerical/mip.pyx
    a b  
    370370            sage: p = MixedIntegerLinearProgram()
    371371            sage: x = p.new_variable()
    372372            sage: p.set_objective(x[1] + x[2])
    373             sage: p.add_constraint(-3*x[1] + 2*x[2], max=2)
     373            sage: p.add_constraint(-3*x[1] + 2*x[2], max=2, name="Constraint_1")
    374374            sage: p.show()
    375375            Maximization:
    376376              x_0 +x_1
    377377            Constraints:
    378               -3 x_0 +2 x_1 <= 2
     378              Constraint_1: -3 x_0 +2 x_1 <= 2
    379379            Variables:
    380380              x_0 is a real variable (min=0.0, max=+oo)
    381381              x_1 is a real variable (min=0.0, max=+oo)
    382382        """
    383383
     384        self._update_variables_name()
     385
    384386        inv_variables = [0]*len(self._variables)
    385387        for (v,id) in self._variables.iteritems():
    386388            inv_variables[id]=v
     
    396398            value+=str(sum([inv_variables[i]*c for (i,c) in zip(self._objective_i, self._objective_values)]))
    397399
    398400        value += "\nConstraints:"
    399         for (c,min,max) in self.constraints():
    400             value += "\n  " + (str(min)+" <= " if min!=None else "")+str(c)+(" <= "+str(max) if max!=None else "")
     401        for (c,min,max), name in zip(self.constraints(), self._constraints_name):
     402            value += "\n  "+(name+":" if name is not None else "")+" " + (str(min)+" <= " if min!=None else "")+str(c)+(" <= "+str(max) if max!=None else "")
    401403        value += "\nVariables:"
    402404        for _,v in sorted([(str(x),x) for x in self._variables.keys()]):
    403405