Skip to content

Conversation

odow
Copy link
Member

@odow odow commented Sep 10, 2025

I still need to do indicator constraints.

Closes #2836
Closes #2351

c3: 2 x2 + 3 x4 <= 25
bounds
0 <= x1 <= +infinity
0 >= x2 <= 10
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now throws "Upper bound already set" which seems okay

@@ -1,13 +0,0 @@
\ File: lo1.lp
maximize
obj: 3 x1 + + x2 + 5 x3 + x4
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can handle + + now

obj: 3 x1 + x2 + 5 x3 + x4
subject to
c1: 3 x1 + x2 + 2 x3 = 30
c2: 2 x1 + x2 + - 3 x3 + x4 >= 15
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can handle + - now

@@ -513,7 +510,7 @@ function test_read_model1_tricky()
@test occursin("CON4: 1 V5 + 1 V6 + 1 V7 <= 1", file)
@test occursin("CON1: 1 V1 >= 0", file)
@test occursin("CON5: [ 1 Var4 ^ 2 - 1.2 V5 * V1 ] <= 0", file)
@test occursin("R1: 1 V2 >= 2", file)
@test occursin("1 V2 >= 2", file)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The decision to arbitrarily give the constraint a name was ... suspect. If the user didn't provide a name. We don't need to add one.

@odow odow marked this pull request as ready for review September 11, 2025 01:45
@odow
Copy link
Member Author

odow commented Sep 11, 2025

At this point, I'm kind of over-engineering this. But LP files are finicky enough that having good error messages is a nice quality of life improvement.

[ Info: invalid_after_end.lp
Error parsing LP file. Got an unexpected token on line 7:
C: 1 x <= 2
^
No file contents are allowed after `end`.
[ Info: invalid_bound_2.lp
Error parsing LP file. Got an unexpected token on line 6:
 x1 != 10 
    ^
We expected this to be an inequality like `>=`, `<=` ,or `==`.
[ Info: invalid_constraint.lp
Error parsing LP file. Got an unexpected token on line 5:
c2:  2 x1 + x2 + c2: + 3 x3 + x4 >= 15 
                   ^
We expected this to be an inequality like `>=`, `<=` ,or `==`.
[ Info: invalid_sos_constraint.lp
Error parsing LP file. Got an unexpected token on line 11:
 csos2: S2::
            ^
SOS constraints cannot be spread across lines.
[ Info: invalid_sos_set.lp
Error parsing LP file. Got an unexpected token on line 10:
 csos2: S3:: V2:2 V4:1 V5:2.5
        ^
This must be either `S1` for SOS-I or `S2` for SOS-II.
[ Info: invalid_variable_name.lp
Error parsing LP file. Got an unexpected token on line 2:
obj: 3 1x1 + x2 + 5 x3 + x4 
       ^
Got a number, But we expected this to be a new term in the expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[FileFormats.LP] Size Limit for read_from_file [FileFormats.LP] write a proper parser
1 participant