Ticket #12973: 16400.patch

File 16400.patch, 2.3 KB (added by ncohen, 8 years ago)
  • sage/numerical/backends/gurobi_backend.pxd

    # HG changeset patch
    # User Emil R. Vaughan <e.vaughan@qmul.ac.uk>
    # Date 1337355279 -3600
    # Node ID 60f31b1575f300ebf13e79ce149d61f5cb29efe7
    # Parent  d135ca074adac6ffef21aa5d1b45c59d24048153
    trac 12973 <Added copy() to GurbobiBackend. Also changed solver="Gurobi" to solver="GUROBI" in the doctests, so that they work.>
    
    diff --git a/sage/numerical/backends/gurobi_backend.pxd b/sage/numerical/backends/gurobi_backend.pxd
    a b  
    2424
    2525     int GRBloadenv(GRBenv **, char *)
    2626     int GRBnewmodel(GRBenv *env, GRBmodel **modelP, char *Pname, int numvars, double *obj, double *lb, double *ub, char *vtype, char **varnames)
     27     GRBmodel * GRBcopymodel (GRBmodel *model)
     28
    2729     int GRBaddvar(GRBmodel *model, int numnz, int *vind, double *vval, double obj, double lb, double ub, char vtype, char *varname)
    2830     int GRBaddvars (GRBmodel*model, intnumvars, intnumnz, int*vbeg, int*vind, double*vval, double*obj, double*lb, double*ub, char*vtype, char** varnames )
    2931
  • sage/numerical/backends/gurobi_backend.pyx

    diff --git a/sage/numerical/backends/gurobi_backend.pyx b/sage/numerical/backends/gurobi_backend.pyx
    a b  
    12051205        else:
    12061206            raise RuntimeError("This should not happen.")
    12071207
     1208    cpdef GurobiBackend copy(self):
     1209        """
     1210        Returns a copy of self.
     1211
     1212        EXAMPLE::
     1213
     1214            sage: from sage.numerical.backends.generic_backend import get_solver    # optional - GUROBI
     1215            sage: p = MixedIntegerLinearProgram(solver = "GUROBI")                  # optional - GUROBI
     1216            sage: b = p.new_variable()                                              # optional - GUROBI
     1217            sage: p.add_constraint(b[1] + b[2] <= 6)                                # optional - GUROBI
     1218            sage: p.set_objective(b[1] + b[2])                                      # optional - GUROBI
     1219            sage: copy(p).solve()                                                   # optional - GUROBI
     1220            6.0
     1221        """
     1222        cdef GurobiBackend p = GurobiBackend(maximization = self.is_maximization())
     1223        p.model[0] = GRBcopymodel(self.model[0])
     1224        p.env = GRBgetenv(p.model[0])
     1225        return p
     1226
    12081227    def __dealloc__(self):
    12091228        """
    12101229        Destructor