Using minizinc instance with or-tools cp solver

2,248 views
Skip to first unread message

Pierre

unread,
Feb 1, 2013, 5:41:36 AM2/1/13
to or-tools...@googlegroups.com
Hello,

I am trying to use miniZinc instance as input for the or-tools CP solver but I didn't find anywhere any reference to zinc / flatzinc / minizinc classes in the or-tools compiled library. There is an interesting "flatzinc" directory in the or-tools sources but how to use it ? Do I need a special compilation to have the zinc classes in the compiled library ?
And how is it intended to be used ? 

Thanks for your anwsers

Laurent Perron

unread,
Feb 1, 2013, 5:48:24 AM2/1/13
to or-tools...@googlegroups.com
Hello, 

to use it, you need to compile the flatzinc binary:
  make fz

then in <minizinc-dir>/lib/minizinc, create a link to <or-tools>/lib/flatzinc/minizinc name or-tools (or copy the minizinc directory in or-tools and rename it to or-tools).

once this is done, you can run a minizinc example by running:

minizinc -G or-tools -f <or-tools>/bin/fz example.mzn

you can run a flatzinc example by running:

<or-tools>/bin/fz example.fzn

I home this helps.

--Laurent

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00




--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Pierre

unread,
Feb 1, 2013, 10:11:28 AM2/1/13
to or-tools...@googlegroups.com
Hello,

Compiling the flatzinc library *only* creates fz.lib and the runnable binary.
I haven't found compiled dynamic library nor anything to use fz in c#. It seems that the or-tools c# wrapper doesn't take care of fz.

Moreover, isn't it any other way of using fz that calling directly its binary fz ?

Naively, I was looking for something like 
Solver s = new Solver("mySolver");
s.loadMiniZinc("myMiniZincFile.mnz")
s.newSearch ....

or in a more OOP abstractive way
Solver s = new Solver("mySolver");
new FZParser("myMiniZincFile.mnz").injectInto(s);
s.newSearch ...

Was I wrong to hope such interaction between fz and or-tools ?

Laurent Perron

unread,
Feb 18, 2013, 3:11:56 PM2/18/13
to or-tools...@googlegroups.com
Hello, 

Using the flatzinc binary outside of minizinc is clearly not in the spirit of the minizinc usage.

In C++, the usage is quite close to what you describe:

  if (!fz_model.Parse(std::cin)) {
      return -1;
  }
  fz_model.Solve(parameters, parallel_support);

This, in turn, call methods in fz_search.cc and flatzinc.cc.

I know teams who have implemented their own search on top of the model parsing. (replace the Solve() method and associated CreateDecisionBuilder).

This being said, I am reluctant to export this in C#.

Thanks

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



Mark Manser

unread,
Sep 4, 2014, 2:54:09 PM9/4/14
to or-tools...@googlegroups.com
Am I interpreting it correctly that there is no way to parse and solve a FlatZinc model using ortools in a C# program?
Has this changed since this thread was last responded to 19 months ago?

Laurent Perron

unread,
Sep 4, 2014, 3:18:39 PM9/4/14
to or-tools...@googlegroups.com
Since I have rewritten everything in flatzinc2, there is now a clean 'model' object and a clean solver API that consumes it. So we are closer to your request.

two things are missing:
  - the actual swig declaration for it.
  - a real solution query API on the solver. Currently flatzinc outout is a text  console output.

--Laurent
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark

unread,
Jul 14, 2015, 10:53:32 AM7/14/15
to or-tools...@googlegroups.com
I see that you are doing some additional work on the FlatZinc interpreter for this year's MiniZinc challenge.  
Would it be possible to implement the two missing features you stated are required for this request while your focus is on this topic?
For more options, visit https://groups.google.com/d/optout.

Laurent Perron

unread,
Jul 14, 2015, 3:05:32 PM7/14/15
to or-tools...@googlegroups.com
Hi, 

I have pushed incomplete (unfinished) support for your requests.
you can type

make csharpfz

the example source code is in examples/csharp/csfz.exe

Please note that it crashes as I cannot read solution values yet.

Thanks

Laurent Perron

unread,
Jul 14, 2015, 4:51:46 PM7/14/15
to or-tools...@googlegroups.com
Hi,

support is complete. Please look at the examples/csharp/csfz.cs

Thanks
Reply all
Reply to author
Forward
0 new messages