Hi all,
I am using the Java AMPL API [2.0.12]. If I call ampl.solve();, the following gets written into my JAVA IDE console:
com.ampl.AMPLException: presolve, constraint fix_value_1_4_to_1:
all variables eliminated, but lower bound = 1 > 0
I tried to surround the ampl.solve() with a try-catch to catch an AMPLException or anything throwable but JAVA does not catch the exception.
Am I doing something wrong or is this a bug?
THX M
1 Like
Hi @michael,
Thanks for reporting this issue. What is the operating system you are running the application on?
Hi @fdabrandao
Anything new on this topic?
Greetings M
Hi @michael,
Sorry for the late reply. There seems to be some compiler optimization happening in Visual Studio (the Java API works on top of the C++ API) that is causing the exception to not be passed to Java. We were able to reproduce the issue and we are working on a fix.
1 Like
Hi @michael,
It turns out that the reason for the exception not being thrown is that the message is being classified as warning and not as an error. By default warnings are only displayed. A workaround while we are working on an update is:
ampl.solve();
if (!ampl.getValue("solve_result").equals("solved")) {
// handle the error
}
1 Like
Hi @fdabrandao
thank you for your reply.
The if condition should look like
ampl.solve();
if (!ampl.getValue("solve_result").equals("solved")) {
// handle the error
}
as in the code snippet you provided, Java always goes into the if condition. 
Wish u all the best! M
1 Like