Trees | Indices | Help |
|
---|
|
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
Class Variables | |
incumbent = -1 See _constants.CPX_INCUMBENT_ID |
|
quality_metric = QualityMetric() See QualityMetric() |
Instance Variables | |
filter See SolnPoolFilterInterface() |
Properties | |
Inherited from |
Method Details |
Creates a new SolnPoolInterface. The solution pool interface is exposed by the top-level Cplex class as Cplex.solution.pool. This constructor is not meant to be used externally.
|
Returns the objective value for a member of the solution pool. 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() >>> obj_val = c.solution.pool.get_objective_value(0) >>> abs(obj_val - 499.0) < 1e-6 True |
Returns the values of a set of variables for a given solution. Can be called by four forms. >>> import cplex >>> c = cplex.Cplex() >>> c.parameters.randomseed.set(1) >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.solve() >>> c.solution.pool.get_values(1, 2) 244.0 >>> abs(c.solution.pool.get_values(1, "x2")) 0.0 >>> val = c.solution.pool.get_values(1, ["x2", 2]) >>> [x if x else 0.0 for x in val] [0.0, 244.0] >>> val = c.solution.pool.get_values(1) >>> val[2] 244.0 |
Returns a set of linear slacks for a given solution. Can be called by four forms. >>> 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.get_linear_slacks(2, 1) 0.0 >>> c.solution.pool.get_linear_slacks(2, "c2") 0.0 >>> c.solution.pool.get_linear_slacks(2, ["c2", 1]) [0.0, 0.0] >>> linslack = c.solution.pool.get_linear_slacks(2) >>> abs(linslack[2]) < 1e-6 True |
Returns a set of quadratic slacks for a given solution. Can be called by four forms. >>> import cplex >>> c = cplex.Cplex() >>> c.parameters.randomseed.set(1) >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("miqcp.lp") >>> c.solve() >>> var = c.solution.pool.get_quadratic_slacks(1, 1) >>> var = c.solution.pool.get_quadratic_slacks(1, "QC3") >>> vars = c.solution.pool.get_quadratic_slacks(1, ["QC3", 1]) >>> vars = c.solution.pool.get_quadratic_slacks(1) |
Returns the integer quality of a given solution. The integer quality of a solution can either be a single attribute of solution.pool.quality_metrics or a sequence of such attributes.
>>> import cplex >>> c = cplex.Cplex() >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.solve() >>> quality_metric = c.solution.pool.quality_metric >>> misi = quality_metric.max_indicator_slack_infeasibility >>> c.solution.pool.get_integer_quality(1, misi) -1 |
Returns the float quality of a given solution. The float quality of a solution can either be a single attribute of solution.pool.quality_metrics or a sequence of such attributes.
>>> import cplex >>> c = cplex.Cplex() >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.solve() >>> qual = c.solution.pool.get_float_quality(1, c.solution.pool.quality_metric.max_indicator_slack_infeasibility) >>> abs(qual) < 1.e-6 True |
Returns the average among the objective values in the solution pool. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> c.parameters.randomseed.set(1) >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.solve() >>> mov = c.solution.pool.get_mean_objective_value() |
Deletes solutions from the solution pool. There are four forms by which pool.delete may be called.
See CPXdelsolnpoolsolns in the Callable Library Reference Manual for more detail. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.parameters.randomseed.set(1) >>> c.parameters.mip.limits.populate.set(5) >>> c.populate_solution_pool() >>> names = c.solution.pool.get_names() >>> c.solution.pool.delete(1) >>> n = c.solution.pool.get_names() >>> del names[1] >>> n == names True >>> c.solution.pool.delete(names[1]) >>> n = c.solution.pool.get_names() >>> names.remove(names[1]) >>> n == names True >>> c.solution.pool.delete([names[1], 0]) >>> n = c.solution.pool.get_names() >>> names.remove(names[1]) >>> del names[0] >>> n == names True >>> c.solution.pool.delete() >>> c.solution.pool.get_names() [] |
Returns the names of a set of solutions. There are four forms by which solution.pool.get_names may be called.
>>> import cplex >>> c = cplex.Cplex() >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.parameters.randomseed.set(1) >>> c.parameters.mip.limits.populate.set(10) >>> c.populate_solution_pool() >>> names = c.solution.pool.get_names() >>> names[1] == c.solution.pool.get_names(1) True >>> [names[i] for i in [1,2]] == c.solution.pool.get_names([1,2]) True >>> names[1:5] == c.solution.pool.get_names(1, 4) True |
Returns the number of solution pool members that have been replaced. 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.get_num_replaced() 0 |
Returns the number of solutions in the solution pool. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> c.parameters.randomseed.set(1) >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.solve() >>> num = c.solution.pool.get_num() |
Writes solutions to a file. If no second argument is provided, all solutions are written to file. If a second argument is provided, it is the index of a solution in the solution pool. Only that solution will be written to file. >>> import cplex >>> c = cplex.Cplex() >>> out = c.set_results_stream(None) >>> out = c.set_log_stream(None) >>> c.read("ind.lp") >>> c.parameters.randomseed.set(1) >>> c.parameters.mip.limits.populate.set(10) >>> c.populate_solution_pool() >>> c.solution.pool.write("ind.sol",4) |
Returns an object containing measures of the quality of the specified solution. See QualityMetrics |
Trees | Indices | Help |
|
---|