Skip to content

Commit c3c95ad

Browse files
authored
Merge pull request #3609 from dansplain/fix_writemps_quadobj
Fix how QUADOBJ section written to MPS files
2 parents 9a7ff8d + 24d44ae commit c3c95ad

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

pyomo/repn/plugins/mps.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,16 +725,14 @@ def yield_all_constraints():
725725
% (var1_label, var2_label, _no_negative_zero(coef * 2))
726726
)
727727
else:
728-
# the matrix needs to be symmetric so split
729-
# the coefficient (but remember it is divided by 2)
728+
# The Q matrix is symmetric (but remember it is divided by 2).
729+
# For the QUADOBJ section we output only the upper (or lower)
730+
# triangle of the Q matrix, so a single element represents a pair
731+
# of non-zero elements.
730732
output_file.write(
731733
column_template
732734
% (var1_label, var2_label, _no_negative_zero(coef))
733735
)
734-
output_file.write(
735-
column_template
736-
% (var2_label, var1_label, _no_negative_zero(coef))
737-
)
738736

739737
#
740738
# QCMATRIX section

pyomo/repn/tests/mps/column_ordering_quadratic.mps.baseline

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ BOUNDS
2323
QUADOBJ
2424
c c 2
2525
c b 1
26-
b c 1
2726
c a 1
28-
a c 1
2927
b b 2
3028
b a 1
31-
a b 1
3229
a a 2
3330
QCMATRIX c_u_con_
3431
c c 1

pyomo/repn/tests/mps/no_column_ordering_quadratic.mps.baseline

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ BOUNDS
2323
QUADOBJ
2424
a a 2
2525
a b 1
26-
b a 1
2726
a c 1
28-
c a 1
2927
b b 2
3028
b c 1
31-
c b 1
3229
c c 2
3330
QCMATRIX c_u_con_
3431
a a 1

0 commit comments

Comments
 (0)