|
|
Trees | Indices | Help |
|
|---|
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
| Class Variables | |
effort_level = EffortLevel()See EffortLevel() |
|
| Method Details |
Creates a new MIPStartsInterface. The MIP starts interface is exposed by the top-level Cplex class as Cplex.MIP_starts. This constructor is not meant to be used externally.
|
Returns the number of MIP starts currently stored. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add( ... names = [str(i) for i in range(11)], ... types = "I" * 11) >>> indices = c.MIP_starts.add( ... [(cplex.SparsePair(ind = [i], val = [0.0]), ... c.MIP_starts.effort_level.auto) for i in range(5)]) >>> c.MIP_starts.get_num() 5 |
Reads MIP starts from a file. This method reads a file in the format MST and copies the information of all the MIP starts contained in that file into a CPLEX problem object. The parameter cplex.parameters.advance must be set to cplex.parameters.advance.values.standard, its default value, or cplex.parameters.advance.values.alternate in order for the MIP starts to be used.
Example usage: >>> import cplex >>> c = cplex.Cplex() >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.solve() >>> c.MIP_starts.write("test_all.mst") >>> c.MIP_starts.read("test_all.mst") |
Writes a set of MIP starts to a file. If called with only a filename, writes all MIP starts to that file. If called with a filename and one index or name of a MIP start, writes only that MIP start to the file. If called with a filename and two indices or names of MIP starts, writes all MIP starts between the first and second index or name, inclusive of begin and end, to the file. >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add( ... names = [str(i) for i in range(11)], types = "I" * 11) >>> indices = c.MIP_starts.add( ... [(cplex.SparsePair(ind = [i], val = [0.0]), ... c.MIP_starts.effort_level.auto) for i in range(5)]) >>> c.MIP_starts.write("test_all.mst") >>> c.MIP_starts.write("test_one.mst", 1) >>> c.MIP_starts.write("test_four.mst", 1, 4) |
Adds MIP starts to the problem. To add a single MIP start, call this method as cpx.MIP_starts.add(start, effort_level, name) The first argument, start, must be either a SparsePair instance or a list of two lists, the first of which contains variable indices or names, the second of which contains the values that those variables take. The second argument, effort_level, must be an attribute of MIP_starts.effort_level. The third optional argument is the name of the MIP start. To add a set of MIP starts, call this method as cpx.MIP_starts.add(sequence) where sequence is a list or tuple of pairs (start, effort_level) or triples (start, effort_level, name) as described above. >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names = [str(i) for i in range(11)], ... types = "I" * 11) >>> indices = c.MIP_starts.add( ... cplex.SparsePair(ind = [0], val = [0.0]), ... c.MIP_starts.effort_level.repair, "first") >>> indices = c.MIP_starts.add( ... cplex.SparsePair(ind = [1], val = [0.0]), ... c.MIP_starts.effort_level.solve_MIP) >>> indices = c.MIP_starts.add( ... [([[2, 4], [0.0, 1.0]], ... c.MIP_starts.effort_level.auto, "third"), ... ([[3, 4], [1.0, 3.0]], ... c.MIP_starts.effort_level.check_feasibility)]) >>> c.MIP_starts.get_num() 4 >>> c.MIP_starts.get_names() ['first', 'm2', 'third', 'm4'] |
Changes a MIP start or set of MIP starts. To change a single MIP start, call this method as cpx.MIP_starts.change(ID, start, effort_level) The first argument, ID, must be an index or name of an existing MIP start. The second argument, start, must be either a SparsePair instance or a list of two lists, the first of which contains variable indices or names, the second of which contains the values that those variables take. If the MIP start identified by ID already has a value for a variable specified by start, that value is replaced. The third argument, effort_level, must be an attribute of MIP_starts.effort_level. To change multiple MIP starts, call this method as cpx.MIP_starts.change(sequence) where sequence is a list of tuple of triples (ID, start, effort_level) as described above. >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add( ... names = ["x{0}".format(i) for i in range(4)], ... types = "I" * 4 ... ) >>> indices = c.MIP_starts.add( ... [(cplex.SparsePair(ind = [i], val = [0.0]), ... c.MIP_starts.effort_level.auto) for i in range(3)]) >>> for s in c.MIP_starts.get_starts(): ... print(s) (SparsePair(ind = [0], val = [0.0]), 0) (SparsePair(ind = [1], val = [0.0]), 0) (SparsePair(ind = [2], val = [0.0]), 0) >>> c.MIP_starts.get_names() ['m1', 'm2', 'm3'] >>> check = c.MIP_starts.effort_level.check_feasibility >>> repair = c.MIP_starts.effort_level.repair >>> c.MIP_starts.change("m1", [["x0", "x1"], [1.0, 2.0]], check) >>> c.MIP_starts.get_starts("m1") (SparsePair(ind = [0, 1], val = [1.0, 2.0]), 1) >>> c.MIP_starts.change(1, [[1, 2], [-1.0, -2.0]], repair) >>> c.MIP_starts.get_starts("m2") (SparsePair(ind = [1, 2], val = [-1.0, -2.0]), 4) >>> c.MIP_starts.change([(1, [[0, 2], [-1.0, 2.0]], check), ... ("m3", [["x0", 2], [3.0, 2.0]], repair)]) >>> for s in c.MIP_starts.get_starts(["m2", "m3"]): ... print(s) (SparsePair(ind = [0, 1, 2], val = [-1.0, -1.0, 2.0]), 1) (SparsePair(ind = [0, 2], val = [3.0, 2.0]), 4) |
Deletes MIP starts from the problem. There are four forms by which MIP_starts.delete may be called.
See CPXdelmipstarts in the Callable Library Reference Manual for more detail. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names=['x', 'y'], types=["II"]) >>> indices = c.MIP_starts.add( ... [(cplex.SparsePair(ind=['x'], val=[1.0]), ... c.MIP_starts.effort_level.auto, str(i)) ... for i in range(10)]) >>> c.MIP_starts.get_num() 10 >>> c.MIP_starts.delete(8) >>> c.MIP_starts.get_names() ['0', '1', '2', '3', '4', '5', '6', '7', '9'] >>> c.MIP_starts.delete("1", 3) >>> c.MIP_starts.get_names() ['0', '4', '5', '6', '7', '9'] >>> c.MIP_starts.delete([2, "0", 5]) >>> c.MIP_starts.get_names() ['4', '6', '7'] >>> c.MIP_starts.delete() >>> c.MIP_starts.get_names() [] |
Returns a set of MIP starts. Returns a SparsePair instance or a list of SparsePair instances. Can be called by four forms.
>>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add( ... names=[str(i) for i in range(11)], ... types="B" * 11) >>> indices =c.MIP_starts.add( ... [(cplex.SparsePair(ind=[i], val=[1.0 * i]), ... c.MIP_starts.effort_level.auto, str(i)) ... for i in range(10)]) >>> c.MIP_starts.get_num() 10 >>> c.MIP_starts.get_starts(7) (SparsePair(ind = [7], val = [7.0]), 0) >>> for s in c.MIP_starts.get_starts("0", 2): ... print(s) (SparsePair(ind = [0], val = [0.0]), 0) (SparsePair(ind = [1], val = [1.0]), 0) (SparsePair(ind = [2], val = [2.0]), 0) >>> for s in c.MIP_starts.get_starts([2, "0", 5]): ... print(s) (SparsePair(ind = [2], val = [2.0]), 0) (SparsePair(ind = [0], val = [0.0]), 0) (SparsePair(ind = [5], val = [5.0]), 0) >>> c.MIP_starts.delete(3,9) >>> for s in c.MIP_starts.get_starts(): ... print(s) (SparsePair(ind = [0], val = [0.0]), 0) (SparsePair(ind = [1], val = [1.0]), 0) (SparsePair(ind = [2], val = [2.0]), 0) >>> c.MIP_starts.effort_level[0] 'auto' |
Returns the effort levels for a set of MIP starts. Can be called by four forms.
>>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add( ... names = [str(i) for i in range(10)], ... types = "B" * 10) >>> indices = c.MIP_starts.add( ... [(cplex.SparsePair(ind = [i], val = [1.0 * i]), ... c.MIP_starts.effort_level.auto, str(i)) ... for i in range(10)]) >>> c.MIP_starts.change([(1, [[0], [0.0]], c.MIP_starts.effort_level.check_feasibility), (2, [[0], [0.0]], c.MIP_starts.effort_level.solve_fixed), (3, [[0], [0.0]], c.MIP_starts.effort_level.solve_MIP), (4, [[0], [0.0]], c.MIP_starts.effort_level.repair), (5, [[0], [0.0]], c.MIP_starts.effort_level.no_check)]) >>> c.MIP_starts.get_num() 10 >>> c.MIP_starts.effort_level[c.MIP_starts.get_effort_levels(3)] 'solve_MIP' >>> [c.MIP_starts.effort_level[i] for i in c.MIP_starts.get_effort_levels("0",2)] ['auto', 'check_feasibility', 'solve_fixed'] >>> [c.MIP_starts.effort_level[i] for i in c.MIP_starts.get_effort_levels([2,"0",5])] ['solve_fixed', 'auto', 'no_check'] >>> c.MIP_starts.get_effort_levels() [0, 1, 2, 3, 4, 5, 0, 0, 0, 0] |
Returns the number of variables specified by a set of MIP starts. Can be called by four forms.
>>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add( ... names = [str(i) for i in range(11)], ... types = "B" * 11) >>> indices = c.MIP_starts.add( ... [(cplex.SparsePair(ind = range(i), val = [0.0] * i), ... c.MIP_starts.effort_level.auto, str(i - 1)) ... for i in range(1, 11)]) >>> c.MIP_starts.get_num() 10 >>> c.MIP_starts.get_num_entries(3) 4 >>> c.MIP_starts.get_num_entries("0",2) [1, 2, 3] >>> c.MIP_starts.get_num_entries([2,"0",5]) [3, 1, 6] >>> c.MIP_starts.get_num_entries() [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
Returns the names of a set of MIP starts. Can be called by four forms.
>>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add( ... names = [str(i) for i in range(11)], ... types = "B" * 11) >>> indices = c.MIP_starts.add( ... [(cplex.SparsePair(ind = range(i), val = [0.0] * i), ... c.MIP_starts.effort_level.auto, "mst" + str(i - 1)) ... for i in range(1, 11)]) >>> c.MIP_starts.get_num() 10 >>> c.MIP_starts.get_names(8) 'mst8' >>> c.MIP_starts.get_names(1, 3) ['mst1', 'mst2', 'mst3'] >>> c.MIP_starts.get_names([2, 0, 5]) ['mst2', 'mst0', 'mst5'] >>> c.MIP_starts.get_names() ['mst0', 'mst1', 'mst2', 'mst3', 'mst4', 'mst5', 'mst6', 'mst7', 'mst8', 'mst9'] |
|
|
Trees | Indices | Help |
|
|---|