# How to display the range of coefficients in docplex log?

A typical gurobi log can have a section where it shows the range of coefficients. Something like:

Coefficient statistics:
Matrix range     [1e+00, 6e+01]
Objective range  [5e+01, 9e+01]
Bounds range     [1e+00, 1e+00]
RHS range        [2e+04, 2e+04]


I've been looking around the docplex package and so far, I've only found the print_information method of the Model class which only shows general statistics about the model such as number and type of variables and constraints.

Is there a way to display the range of coefficients in docplex log?

Note:

1. CPLEX Interactive Optimizer has display problem stats but that's not what I'm looking for.
2. I'm interested in knowing how or if this can be done in docplex API and not the cplex python API.

even from docplex you can get access to the cplex python API. See example in SO for sensitivity analysis at https://stackoverflow.com/questions/62475139/sensitivity-analysis-in-docplex

Plus before the solve see

https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/DataCheck.html

« When the value of this parameter is set to level 2, CPX_DATACHECK_ASSIST, CPLEX turns on both data consistency checking and modeling assistance. At this level, CPLEX issues warnings at the start of the optimization about disproportionate values (too large, too small) in coefficients, bounds, and righthand sides (RHS). «

that can if data check set to 2 spot numerical problems before solve

regards

You can try the following code snippets to get the statistics just like Gurobi.

def get_model_stats(solver):
cpx = solver.get_engine().get_cplex()
stats = cpx.get_stats()
model_stats = {}
model_stats['Matrix range'] = [stats.min_linear_constraints, stats.max_linear_constraints]
model_stats['Objective range'] = [stats.min_linear_objective, stats.max_linear_objective]
model_stats['Bounds range'] = [stats.min_lower_bound, stats.max_upper_bound]
model_stats['RHS range'] = [stats.min_linear_constraints_rhs, stats.max_linear_constraints_rhs]

print('-'*100)
print(model_stats)
print('-'*100)

get_model_stats(mdl)
$$$$
`
New contributor
Vikas Garg is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.