Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/call_highs_from_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 21 additions & 2 deletions examples/call_highs_from_python_highspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()
22 changes: 21 additions & 1 deletion examples/call_highs_from_python_mps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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]))

6 changes: 3 additions & 3 deletions highs/lp_data/Highs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
Loading