Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] MiniZinc parser crashes on a model with float vars #1098

Open
SYury opened this issue May 21, 2024 · 3 comments
Open

[BUG] MiniZinc parser crashes on a model with float vars #1098

SYury opened this issue May 21, 2024 · 3 comments
Labels

Comments

@SYury
Copy link

SYury commented May 21, 2024

Describe the bug
Consider the following MiniZinc model:

var -100.0..100.0: x;
var -100.0..100.0: y;
constraint 2 * x + 3 * y >= 10;
solve satisfy;

When I run Choco on this model in MiniZinc IDE, it crashes with the following stacktrace:

%% Choco 231102
line 1:44 mismatched input '.' expecting {',', ']'}
Exception in thread "main" java.lang.UnsupportedOperationException: Parameter#buildArray ARRAY: unexpected type for X_INTRODUCED_2_
	at org.chocosolver.parser.flatzinc.ast.FParameter.buildArray(FParameter.java:162)
	at org.chocosolver.parser.flatzinc.ast.FParameter.make_parameter(FParameter.java:49)
	at org.chocosolver.parser.flatzinc.Flatzinc4Parser.param_decl(Flatzinc4Parser.java:1168)
	at org.chocosolver.parser.flatzinc.Flatzinc4Parser.flatzinc_model(Flatzinc4Parser.java:212)
	at org.chocosolver.parser.flatzinc.Flatzinc.parse(Flatzinc.java:199)
	at org.chocosolver.parser.flatzinc.Flatzinc.buildModel(Flatzinc.java:152)
	at org.chocosolver.parser.flatzinc.ChocoFZN.main(ChocoFZN.java:27)

It looks like the line array [1..2] of float: X_INTRODUCED_2_ = [-2.0,-3.0]; in generated flatzinc representation kills the parser. When I change the variables to ints it works.
Environment (please complete the following information):

  • Choco-solver 4.10.14 (I found no related commits since the release, so the bug is probably still around)
  • MiniZinc IDE 2.8.4
  • JRE 22.0.1
  • Windows 10
@SYury SYury added the bug label May 21, 2024
@cprudhom
Copy link
Member

That's because the flatzinc parser of choco-solver does not support float variables and constraints.

@SYury
Copy link
Author

SYury commented May 21, 2024

That's because the flatzinc parser of choco-solver does not support float variables and constraints.

That's unfortunate. Is there any way to pass a model with float variables to choco-solver without writing the Java code by hand?

@cprudhom
Copy link
Member

Sadly, no, it requires to update the parser in order to support float variables and float constraints declaration.
It is probably not too difficult, a copying-and-pasting strategy could be applied, but I already have two projects underway.

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

No branches or pull requests

2 participants