Newbie question about handbook listing 2.1.6 in v2.8.0

34 views
Skip to first unread message

meta_leap

unread,
Nov 19, 2023, 6:13:16 PM11/19/23
to MiniZinc
Hi all,

I just started working through the handbook, being generally new to solvers (in practice — theory too =)

Well I have this version of listing 2.1.6 that is identical except no `output` directive, and subjectively-more-self-documenting identifier renames (as I'm not too fond of the common naming patterns in the logic/maths scenes). So now with this, running without data file from IDE, top 3 var inits being as-if-loan1.dzn:

```
var float: quarterly_repayment = 260.0;
var float: principal_borrowed = 1000.0;
var 0.0 .. 10.0: quarterly_interest_rate_percent = 0.04;

var float: owing_after_q1;
var float: owing_after_q2;
var float: owing_after_q3;
var float: owing_after_q4;

constraint owing_after_q1 = principal_borrowed * (1.0 + quarterly_interest_rate_percent) - quarterly_repayment;

constraint owing_after_q2 = owing_after_q1 * (1.0 + quarterly_interest_rate_percent) - quarterly_repayment;

constraint owing_after_q3 = owing_after_q2 * (1.0 + quarterly_interest_rate_percent) - quarterly_repayment;

constraint owing_after_q4 = owing_after_q3 * (1.0 + quarterly_interest_rate_percent) - quarterly_repayment;

solve satisfy;

```

only 'HiGHS 1.6.0' and 'COIN-BC 2.10.11/1.17.9' compute successfully.
  • Chuffed: "no floats supported" — OK, understood, no prob.
  • findMUS: "Unrecognized option or bad format `--output-objective'" — known issue?
  • Gecode: "UNSATISFIABLE" — odd? Chapter says that solver "might" not be as optimal for floats as others — but this message sounds oddly assured of unsatisfiability! Just wondering if possible un/known-issue of simply the possible-not-guaranteed-outcome of a "might-or-might-not-suffice-for-floats" solver.
  • Globalizer: Unrecognized option or bad format `--output-objective' — known issue?
  • OR Tools: "Not supported float_lin_eq" — is that general "no floats supported" just with technically-driven phrasing? Or should it actually work?
Just trying to figure out if I can mentally-discard all those solvers for float-problems or whether I stumbled on yet-to-be/currently-being investigated/fixed quirks.

Glad to have found MiniZinc with its "programmer-friendly" dialects and this great handbook, because the usual-syntaxes alone have chased me off every solver I ever wanted to explore previously so far. (Those just being optimized for other target audiences, I'm sure =)

Many thanks!

Jip Dekker

unread,
Nov 19, 2023, 6:26:00 PM11/19/23
to MiniZinc
Floating point variables are generally quite hard to support for many paradigms. Both the HiGHS solver and the CBC solver are MIP solvers, which work very well with floating point numbers.

You are right that Chuffed and OR-Tools just in general do not support floating point variables. 

FindMUS and Globaliser are not solvers (they are tools that can be very useful while develop models, see the handbook). The error they are giving at the moment is a bug in MiniZinc, and they can be made to work by disabling the "Output objective value" option in the "configuration editor" of the IDE. I believe these tools also do not support floating point variables.

Gecode is a CP solver that does support floating point variables, but it is limited to 32-bit floating point numbers if I remember correctly. I think the problem might just lie in the numerics of the problem itself. For example, changing the parameters to
var float: quarterly_repayment = 26.0;
var float: principal_borrowed = 100.0;
does allow you solve the problem with Gecode.

There are other (MIP) solvers that also work well with MiniZinc that do support floating point numbers. You can have a look at Gurobi, CPLEX, XPRESS, (paid licenses), or SCIP (open source).

krzysztof....@gmail.com

unread,
Nov 20, 2023, 2:37:06 AM11/20/23
to MiniZinc
Just a short comment. As it was pointed out floating points are special and problems are usually caused by rounding of numbers. JaCoP tries to avoid this problem by making conservative assumptions and, in fact, solves your original problem and provides the following solution.

owing_after_q1 = 780.0;

owing_after_q2 = 551.2;

owing_after_q3 = 313.248;

owing_after_q4 = 65.77792000000005;

----------

==========

Message has been deleted

meta_leap

unread,
Nov 20, 2023, 2:39:23 AM11/20/23
to MiniZinc
Thanks all! For the handbook journey, will stick to the out-of-box solvers. Thereafter, in the real world, also explore the others  =)
Reply all
Reply to author
Forward
0 new messages