General Constraint error: Invalid general function options or missing closing brackets
AnsweredHello,
I am trying to solve the Three-hump camelback problem using general constraints options in Gurobi.
I am writing the model in .lp formt and following the example given on the page: https://www.gurobi.com/documentation/9.0/refman/lp_format.html
However whenever I try to define a general constraint I end up getting this error saying "Invalid general function options or missing closing brackets" (see the screenshot below):

My lp file follows below:
Minimize
k
Subject to
General constraints
gc1: ( PieceLength=0.001 ) k = POLY ( 12 x ^ 2 - 6.3 x ^ 4 + 1 x ^ 6 - 6 x * y + 6 y ^ 2 )
Bounds
-10 <= x <= 10
-10 <= y <= 10
End
Best wishes,
Tanuj
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Tanuj,
We don't recommend writing LP files by hand. Why don't you use an API to create the LP file?
There are multiple issues with your file. E.g.:
- You can only model univariate polynomials (i.e., you cannot use two variables x and y).
- You should order the terms in the polynomial decreasingly by degree.
- The attribute for controlling piece length is called FuncPieceLength. (This might be wrong in the LP format documentation.)
- Bounds should go before the general constraints.
I would really recommend building the model using one of our APIs!
Silke
1
Post is closed for comments.
Comments
2 comments