diff --git a/examples/call_highs_from_python.py b/examples/call_highs_from_python.py index 5d606740cf..632ee2c918 100644 --- a/examples/call_highs_from_python.py +++ b/examples/call_highs_from_python.py @@ -328,12 +328,11 @@ def user_callback( solution = h.getSolution() basis = h.getBasis() info = h.getInfo() -# -col_status = basis.col_status -col_value = list(solution.col_value) # basis.col_status is already a list, but accessing values in # solution.col_value directly is very inefficient, so convert it to a # list +col_status = basis.col_status +col_value = list(solution.col_value) model_status = h.getModelStatus() print("Model status = ", h.modelStatusToString(model_status)) print("Optimal objective = ", info.objective_function_value) diff --git a/examples/call_highs_from_python_highspy.py b/examples/call_highs_from_python_highspy.py index 1cf6302a4a..011674b0ac 100644 --- a/examples/call_highs_from_python_highspy.py +++ b/examples/call_highs_from_python_highspy.py @@ -35,8 +35,8 @@ print() # Print solution information -# solution = h.getSolution() -# basis = h.getBasis() +solution = h.getSolution() +basis = h.getBasis() info = h.getInfo() model_status = h.getModelStatus() @@ -49,4 +49,23 @@ h.solutionStatusToString(info.dual_solution_status)) print('Basis validity = ', h.basisValidityToString(info.basis_validity)) +# basis.col_status is already a list, but accessing values in +# solution.col_value directly is very inefficient, so convert it to a +# list +col_status = basis.col_status +row_status = basis.row_status +col_value = list(solution.col_value) +row_value = list(solution.row_value) + +num_var = h.getNumCol() +num_row = h.getNumRow() +print("Variables") +for icol in range(num_var): + print(icol, col_value[icol], + h.basisStatusToString(col_status[icol])) +print("Constraints") +for irow in range(num_row): + print(irow, row_value[irow], + h.basisStatusToString(row_status[irow])) + h.clear() diff --git a/examples/call_highs_from_python_mps.py b/examples/call_highs_from_python_mps.py index 69a74549b2..5594e2ae6a 100644 --- a/examples/call_highs_from_python_mps.py +++ b/examples/call_highs_from_python_mps.py @@ -12,7 +12,7 @@ # Initialize an instance of Highs # h = highspy.Highs() # Here we are re-using the one from above. -h.readModel('check/instances/25fv47.mps') +h.readModel('check/instances/avgas.mps') # Print lp = h.getLp() @@ -37,3 +37,23 @@ print('Dual solution status = ', h.solutionStatusToString(info.dual_solution_status)) print('Basis validity = ', h.basisValidityToString(info.basis_validity)) + +# basis.col_status is already a list, but accessing values in +# solution.col_value directly is very inefficient, so convert it to a +# list +col_status = basis.col_status +row_status = basis.row_status +col_value = list(solution.col_value) +row_value = list(solution.row_value) + +num_var = h.getNumCol() +num_row = h.getNumRow() +print("Variables") +for icol in range(num_var): + print(icol, col_value[icol], + h.basisStatusToString(col_status[icol])) +print("Constraints") +for irow in range(num_row): + print(irow, row_value[irow], + h.basisStatusToString(row_status[irow])) + diff --git a/highs/lp_data/Highs.cpp b/highs/lp_data/Highs.cpp index c25778987e..859a897a87 100644 --- a/highs/lp_data/Highs.cpp +++ b/highs/lp_data/Highs.cpp @@ -374,6 +374,9 @@ HighsStatus Highs::passModel(HighsModel model) { // Ensure that any non-zero Hessian of dimension less than the // number of columns in the model is completed if (hessian.dim_) completeHessian(this->model_.lp_.num_col_, hessian); + // if (model_.lp_.num_row_>0 && model_.lp_.num_col_>0) + // writeLpMatrixPicToFile(options_, "LpMatrix", model_.lp_); + // Clear solver status, solution, basis and info associated with any // previous model; clear any HiGHS model object; create a HiGHS // model object for this LP @@ -1038,9 +1041,6 @@ HighsStatus Highs::optimizeModel() { HighsInt min_highs_debug_level = kHighsDebugLevelMin; // kHighsDebugLevelCostly; // kHighsDebugLevelMax; - // - // if (model_.lp_.num_row_>0 && model_.lp_.num_col_>0) - // writeLpMatrixPicToFile(options_, "LpMatrix", model_.lp_); if (options_.highs_debug_level < min_highs_debug_level) options_.highs_debug_level = min_highs_debug_level;