Trees | Indices | Help |
|
---|
|
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Class Variables | |
type = FilterType() See FilterType() |
Method Details |
Creates a new SolnPoolFilterInterface. The solution pool filter interface is exposed by the top-level Cplex class as Cplex.solution.pool.filter. This constructor is not meant to be used externally.
|
Adds a diversity filter to the solution pool. The arguments determine, in order, the lower bound (float) the upper bound (float) the variables and values it takes as either a SparsePair or a list of two lists. a set of weights (a list of floats with the same length as expression). If an empty list is given, then weights of 1.0 (one) will be used. name (string) Returns the index of the added diversity filter. >>> import cplex >>> c = cplex.Cplex() >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.solve() >>> c.solution.pool.filter.add_diversity_filter( ... 300, 600, [['x1','x2'], [1,1]], [2,1], "") 0 |
Adds a range filter to the solution pool. The arguments determine, in order, the lower bound (float) the upper bound (float) the variables and values it takes as either a SparsePair or a list of two lists. name (string) Returns the index of the added range filter. >>> import cplex >>> c = cplex.Cplex() >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.solve() >>> c.solution.pool.filter.add_range_filter( ... 300, 600, [['x1','x2'], [1,1]], "") 0 |
Returns a set of diversity filters. Returns filters as pairs of (SparsePair, weights), where weights is a list of floats. Can be called by four forms. >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names = ['x','y'], types = ["BB"]) >>> f = cplex.SparsePair(ind = ['x'],val = [1.0]) >>> [c.solution.pool.filter.add_diversity_filter( ... 0, 1, f, [1], str(i)) ... for i in range(2)] [0, 1] >>> c.solution.pool.filter.get_diversity_filters(0) (SparsePair(ind = [0], val = [1.0]), [1.0]) >>> c.solution.pool.filter.get_diversity_filters("1") (SparsePair(ind = [0], val = [1.0]), [1.0]) >>> c.solution.pool.filter.get_diversity_filters([0, "1"]) [(SparsePair(ind = [0], val = [1.0]), [1.0]), (SparsePair(ind = [0], val = [1.0]), [1.0])] >>> c.solution.pool.filter.get_diversity_filters() [(SparsePair(ind = [0], val = [1.0]), [1.0]), (SparsePair(ind = [0], val = [1.0]), [1.0])] |
Returns a set of range filters. Returns filters as SparsePair instances. Can be called by four forms. >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names = ['x','y'], types = ["II"]) >>> f = cplex.SparsePair(ind = ['x'],val = [1.0]) >>> [c.solution.pool.filter.add_range_filter( ... 0.0, 1.0, f, str(i)) for i in range(2)] [0, 1] >>> c.solution.pool.filter.get_range_filters(0) SparsePair(ind = [0], val = [1.0]) >>> c.solution.pool.filter.get_range_filters("1") SparsePair(ind = [0], val = [1.0]) >>> c.solution.pool.filter.get_range_filters([0, "1"]) [SparsePair(ind = [0], val = [1.0]), SparsePair(ind = [0], val = [1.0])] >>> c.solution.pool.filter.get_range_filters() [SparsePair(ind = [0], val = [1.0]), SparsePair(ind = [0], val = [1.0])] |
Returns (lb, ub) pairs for a set of filters. Can be called by four forms. >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names=['x', 'y'], types=["BB"]) >>> f = cplex.SparsePair(ind=['x'], val=[1.0]) >>> [c.solution.pool.filter.add_diversity_filter( ... 0, 1, f, [1], "div{0}".format(i)) for i in range(2)] [0, 1] >>> [c.solution.pool.filter.add_range_filter( ... 0, 1, f, "rng{0}".format(i)) for i in range(2)] [2, 3] >>> c.solution.pool.filter.get_bounds(0) (0.0, 1.0) >>> c.solution.pool.filter.get_bounds("rng0") (0.0, 1.0) >>> c.solution.pool.filter.get_bounds(["div0", 2]) [(0.0, 1.0), (0.0, 1.0)] >>> c.solution.pool.filter.get_bounds() [(0.0, 1.0), (0.0, 1.0), (0.0, 1.0), (0.0, 1.0)] |
Returns the number of variables specified by a set of filters. Can be called by four forms. >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names=['x', 'y'], types=["BB"]) >>> f = cplex.SparsePair(ind=['x'], val=[1.0]) >>> [c.solution.pool.filter.add_diversity_filter( ... 0, 1, f, [1], "div{0}".format(i)) for i in range(2)] [0, 1] >>> [c.solution.pool.filter.add_range_filter( ... 0, 1, f, "rng{0}".format(i)) for i in range(2)] [2, 3] >>> c.solution.pool.filter.get_num_nonzeros(0) 1 >>> c.solution.pool.filter.get_num_nonzeros("rng0") 1 >>> c.solution.pool.filter.get_num_nonzeros(["div0", 2]) [1, 1] >>> c.solution.pool.filter.get_num_nonzeros() [1, 1, 1, 1] |
Deletes filters from the problem. There are four forms by which filters.delete may be called.
See CPXdelsolnpoolfilters 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']) >>> f = cplex.SparsePair(ind=['x'], val=[1.0]) >>> [c.solution.pool.filter.add_range_filter( ... 0.0, 1.0, f, str(i)) for i in range(10)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> c.solution.pool.filter.get_num() 10 >>> c.solution.pool.filter.delete(8) >>> c.solution.pool.filter.get_names() ['0', '1', '2', '3', '4', '5', '6', '7', '9'] >>> c.solution.pool.filter.delete('1', 3) >>> c.solution.pool.filter.get_names() ['0', '4', '5', '6', '7', '9'] >>> c.solution.pool.filter.delete([2, '0', 5]) >>> c.solution.pool.filter.get_names() ['4', '6', '7'] >>> c.solution.pool.filter.delete() >>> c.solution.pool.filter.get_names() [] |
Returns the types of a set of filters. Can be called by four forms. >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names = ['x','y'], types = ["II"]) >>> f = cplex.SparsePair(ind = ['x'],val = [1.0]) >>> [c.solution.pool.filter.add_range_filter( ... 0.0, 1.0, f, str(i)) for i in range(10)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> c.solution.pool.filter.get_types(3) 2 >>> c.solution.pool.filter.get_types("5") 2 >>> c.solution.pool.filter.get_types([2, "8"]) [2, 2] >>> c.solution.pool.filter.get_types() [2, 2, 2, 2, 2, 2, 2, 2, 2, 2] |
Returns the names of filters, given their indices. There are four forms by which solution.pool.filter.get_names may be called.
>>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names = ['x','y'], types = ["II"]) >>> f = cplex.SparsePair(ind = ['x'],val = [1.0]) >>> [c.solution.pool.filter.add_range_filter( ... 0.0, 1.0, f, str(i)) for i in range(10)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> c.solution.pool.filter.get_names() ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] >>> c.solution.pool.filter.get_names(6) '6' >>> c.solution.pool.filter.get_names([5, 3]) ['5', '3'] >>> c.solution.pool.filter.get_names(3, 5) ['3', '4', '5'] |
Writes the filters to a file. 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.solution.pool.filter.add_range_filter( ... 300, 600, [['x1','x2'], [1,1]], "") 0 >>> c.solution.pool.filter.write("ind.flt") |
Reads filters from a file. 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.solution.pool.filter.add_range_filter( ... 300, 600, [['x1','x2'], [1,1]], "") 0 >>> c.solution.pool.filter.write("ind.flt") >>> c.solution.pool.filter.read("ind.flt") |
Returns the number of filters in the problem. 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.solution.pool.filter.add_range_filter( ... 300, 600, [['x1','x2'], [1,1]], "") 0 >>> c.solution.pool.filter.get_num() 1 |
Trees | Indices | Help |
|
---|