gecode - debugging minizinc (anyway, did I found a bug?) -


I am familiar with the origin of MiniZinc, therefore armed with minisan IDE, I write snippets

  Complete the solution; String: s1 = "hello"; String: s2 = "world"; List of functions int: cdr (list of int: v) = [v [i] | | I in 1. Length (V)]; Function list of string: cdr (list of string: v) = [v [i] | | I in 1. Length (V)]; Function string: Conceat (string list: V) = If length (V) == 0 then "V" [0] ++ Context (CDR) is endif; Output [Conteat ([s1, "", s2]) ++ "++ Show (CDR ([1,2,3])];  

It displays

  Hmmmling is running hello.mzn Hello world [1, 2, 3] ---------- End in 49msec  

Now, The CDR in the list of ints seems incorrect. I think this is my bug, although I can not find it.

Can I help here? Since I am GACDE (and then I have GIT) To use I actually put my code in production, am I Can I follow the path?

Any signaling appreciation ...

edit this snippet

  solution Complete the string; function list of string: cdr_s (list of string: v) = [v [i] | i in 2. length (v)]; function string: vcat (string list: v) = if length ( V) == 0 Then "second V [1] ++ vcat (cdr_s (V)) Andif; Output [vcat (["hello", "", "world"]]];  

report

  MiniZinc: type error: no function or distraction was found with this signature: `cdr_s (array of string [int] '/ tmp / MiniZinc IDE-9nYiuF / hello.ozn: 2  

I'm a little confused It seems that there is a bug and there are some other problems.

Produce the model "CDR ([1,2,3])" to give "[1,2,3]". "CDR" It shows that you want the "first" function, but minis is a default 1-based system (Not 0-based) so that your function probably

  function list int: cdr (list of int: v) = [v [i] | i in 2. length (v)] ;  

Since one can define the index of an array (like the starting index is 0), a more general definition is this (which I'm not very happy with, List):

  List of functions int: cdr3 (list of int: v) = [v [i] | i index_set (v) diff {min (index_set (v)) }] In;  

So now you can Some can write:

 % ... int [int] int: t = array1d (0..3, [1,2,3,4]) output [show (CDR 3 (t))]; In addition, your "concat" function is not used at all, try using the built-in "concat" (replace your version with "Context 1" instead). .) That's why you do not get any error in creating "V [0]" (which should be out of bound error). I expected an error to be made to define an underlying, but in some zones, MiniZinc 2.0 is more acceptable than version 1.6. 

And I agree with Excel's general comment, MiniZinc is not very effective as a general programming language (at least in my book) the actual power comes when you add the barriers and decision variables in the model . Please note that the list of MiniZank / ARE handling with fuses variables is not dynamic as prolong, in general you should always think of the period of Array as a fixed period.

It's great that you start watching the mini-park. I hope these comments have helped you when minisan learns.

/ Hakan


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -