Skip to content

Commit 77587b1

Browse files
authored
Merge pull request #2729 from ERGO-Code/fix-2721-2725
Fix 2721 and 2725
2 parents a96bbfb + db50752 commit 77587b1

File tree

4 files changed

+47
-9
lines changed

4 files changed

+47
-9
lines changed

examples/call_highs_from_python.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,11 @@ def user_callback(
328328
solution = h.getSolution()
329329
basis = h.getBasis()
330330
info = h.getInfo()
331-
#
332-
col_status = basis.col_status
333-
col_value = list(solution.col_value)
334331
# basis.col_status is already a list, but accessing values in
335332
# solution.col_value directly is very inefficient, so convert it to a
336333
# list
334+
col_status = basis.col_status
335+
col_value = list(solution.col_value)
337336
model_status = h.getModelStatus()
338337
print("Model status = ", h.modelStatusToString(model_status))
339338
print("Optimal objective = ", info.objective_function_value)

examples/call_highs_from_python_highspy.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
print()
3636

3737
# Print solution information
38-
# solution = h.getSolution()
39-
# basis = h.getBasis()
38+
solution = h.getSolution()
39+
basis = h.getBasis()
4040
info = h.getInfo()
4141
model_status = h.getModelStatus()
4242

@@ -49,4 +49,23 @@
4949
h.solutionStatusToString(info.dual_solution_status))
5050
print('Basis validity = ', h.basisValidityToString(info.basis_validity))
5151

52+
# basis.col_status is already a list, but accessing values in
53+
# solution.col_value directly is very inefficient, so convert it to a
54+
# list
55+
col_status = basis.col_status
56+
row_status = basis.row_status
57+
col_value = list(solution.col_value)
58+
row_value = list(solution.row_value)
59+
60+
num_var = h.getNumCol()
61+
num_row = h.getNumRow()
62+
print("Variables")
63+
for icol in range(num_var):
64+
print(icol, col_value[icol],
65+
h.basisStatusToString(col_status[icol]))
66+
print("Constraints")
67+
for irow in range(num_row):
68+
print(irow, row_value[irow],
69+
h.basisStatusToString(row_status[irow]))
70+
5271
h.clear()

examples/call_highs_from_python_mps.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Initialize an instance of Highs
1313
# h = highspy.Highs()
1414
# Here we are re-using the one from above.
15-
h.readModel('check/instances/25fv47.mps')
15+
h.readModel('check/instances/avgas.mps')
1616

1717
# Print
1818
lp = h.getLp()
@@ -37,3 +37,23 @@
3737
print('Dual solution status = ',
3838
h.solutionStatusToString(info.dual_solution_status))
3939
print('Basis validity = ', h.basisValidityToString(info.basis_validity))
40+
41+
# basis.col_status is already a list, but accessing values in
42+
# solution.col_value directly is very inefficient, so convert it to a
43+
# list
44+
col_status = basis.col_status
45+
row_status = basis.row_status
46+
col_value = list(solution.col_value)
47+
row_value = list(solution.row_value)
48+
49+
num_var = h.getNumCol()
50+
num_row = h.getNumRow()
51+
print("Variables")
52+
for icol in range(num_var):
53+
print(icol, col_value[icol],
54+
h.basisStatusToString(col_status[icol]))
55+
print("Constraints")
56+
for irow in range(num_row):
57+
print(irow, row_value[irow],
58+
h.basisStatusToString(row_status[irow]))
59+

highs/lp_data/Highs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ HighsStatus Highs::passModel(HighsModel model) {
374374
// Ensure that any non-zero Hessian of dimension less than the
375375
// number of columns in the model is completed
376376
if (hessian.dim_) completeHessian(this->model_.lp_.num_col_, hessian);
377+
// if (model_.lp_.num_row_>0 && model_.lp_.num_col_>0)
378+
// writeLpMatrixPicToFile(options_, "LpMatrix", model_.lp_);
379+
377380
// Clear solver status, solution, basis and info associated with any
378381
// previous model; clear any HiGHS model object; create a HiGHS
379382
// model object for this LP
@@ -1038,9 +1041,6 @@ HighsStatus Highs::optimizeModel() {
10381041
HighsInt min_highs_debug_level = kHighsDebugLevelMin;
10391042
// kHighsDebugLevelCostly;
10401043
// kHighsDebugLevelMax;
1041-
//
1042-
// if (model_.lp_.num_row_>0 && model_.lp_.num_col_>0)
1043-
// writeLpMatrixPicToFile(options_, "LpMatrix", model_.lp_);
10441044
if (options_.highs_debug_level < min_highs_debug_level)
10451045
options_.highs_debug_level = min_highs_debug_level;
10461046

0 commit comments

Comments
 (0)