initial import
Thu Dec 7 13:06:18 PST 2006 kilian.sprotte@gmail.com
* initial import
diff -rN -u old-gecol/examples.lisp new-gecol/examples.lisp
--- old-gecol/examples.lisp 1969-12-31 16:00:00.000000000 -0800
+++ new-gecol/examples.lisp 2014-07-25 08:23:54.000000000 -0700
@@ -0,0 +1,95 @@
+;;; -*- Mode: LISP; Syntax: COMMON-LISP; Base: 10 -*-
+;;; arch-tag: 7debdb50-4feb-4e57-b6fd-a1d1eaf6ceab
+
+;;; Copyright (c) 2006, Kilian Sprotte. All rights reserved.
+
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions
+;;; are met:
+
+;;; * Redistributions of source code must retain the above copyright
+;;; notice, this list of conditions and the following disclaimer.
+
+;;; * Redistributions in binary form must reproduce the above
+;;; copyright notice, this list of conditions and the following
+;;; disclaimer in the documentation and/or other materials
+;;; provided with the distribution.
+
+;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
+;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+(in-package :cl-user)
+
+(defun cartesian-product ()
+ (let ((s (gecol:create-space 3 1 3 0)))
+ (gecol:gec-branch-vars-min s)
+ (let ((e (gecol:create-search-engine s)))
+ (loop
+ for sol = (gecol:search-next e)
+ until (cffi:null-pointer-p sol)
+ do (format t "~a, ~a, ~a~%"
+ (gecol:space-read-int sol 0)
+ (gecol:space-read-int sol 1)
+ (gecol:space-read-int sol 2))
+ do (gecol:dispose-space sol))
+ (gecol:dispose-search-engine e)
+ (gecol:dispose-space s))))
+
+(defun distinct ()
+ (let ((s (gecol:create-space 3 1 3 0)))
+ (gecol:gec-distinct s (list 0 1 2) :icl-def)
+ (gecol:gec-branch-vars-min s)
+ (let ((e (gecol:create-search-engine s)))
+ (loop
+ for sol = (gecol:search-next e)
+ until (cffi:null-pointer-p sol)
+ do (format t "~a, ~a, ~a~%"
+ (gecol:space-read-int sol 0)
+ (gecol:space-read-int sol 1)
+ (gecol:space-read-int sol 2))
+ do (gecol:dispose-space sol))
+ (gecol:dispose-search-engine e)
+ (gecol:dispose-space s))))
+
+(defun sorted ()
+ (let ((s (gecol:create-space 3 1 3 0)))
+ (gecol:gec-rel-var s 0 :irt-< 1 :icl-def)
+ (gecol:gec-rel-var s 1 :irt-< 2 :icl-def)
+ (gecol:gec-branch-vars-min s)
+ (let ((e (gecol:create-search-engine s)))
+ (loop
+ for sol = (gecol:search-next e)
+ until (cffi:null-pointer-p sol)
+ do (format t "~a, ~a, ~a~%"
+ (gecol:space-read-int sol 0)
+ (gecol:space-read-int sol 1)
+ (gecol:space-read-int sol 2))
+ do (gecol:dispose-space sol))
+ (gecol:dispose-search-engine e)
+ (gecol:dispose-space s))))
+
+(defun cartesian-product-distr-max ()
+ (let ((s (gecol:create-space 3 1 3 0)))
+ (gecol:gec-branch-vars-max s)
+ (let ((e (gecol:create-search-engine s)))
+ (loop
+ for sol = (gecol:search-next e)
+ until (cffi:null-pointer-p sol)
+ do (format t "~a, ~a, ~a~%"
+ (gecol:space-read-int sol 0)
+ (gecol:space-read-int sol 1)
+ (gecol:space-read-int sol 2))
+ do (gecol:dispose-space sol))
+ (gecol:dispose-search-engine e)
+ (gecol:dispose-space s))))
+
+
diff -rN -u old-gecol/ffi.lisp new-gecol/ffi.lisp
--- old-gecol/ffi.lisp 1969-12-31 16:00:00.000000000 -0800
+++ new-gecol/ffi.lisp 2014-07-25 08:23:54.000000000 -0700
@@ -0,0 +1,297 @@
+;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: GECOL; Base: 10 -*-
+;;; arch-tag: 09C25807-504D-487A-B9D3-275276CF17B1
+
+;;; Copyright (c) 2006, Kilian Sprotte. All rights reserved.
+
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions
+;;; are met:
+
+;;; * Redistributions of source code must retain the above copyright
+;;; notice, this list of conditions and the following disclaimer.
+
+;;; * Redistributions in binary form must reproduce the above
+;;; copyright notice, this list of conditions and the following
+;;; disclaimer in the documentation and/or other materials
+;;; provided with the distribution.
+
+;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
+;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+(in-package :gecol)
+
+(defcenum int-rel-type
+ :irt-= ; =
+ :irt-/= ; /=
+ :irt-<= ; <=
+ :irt-< ; <
+ :irt->= ; >=
+ :irt-> ; >
+ )
+
+(defcenum int-con-level
+ :icl-val ; Value consistency (naive)
+ :icl-bnd ; Bounds consistency.
+ :icl-dom ; Domain consistency.
+ :icl-def ;The default consistency for a constraint.
+ )
+
+(defcfun ("create_space" create-space) :pointer
+ (varnum :int)
+ (varmin :int)
+ (varmax :int)
+ (boolnum :int))
+
+(defcfun ("dispose_space" dispose-space) :void
+ (space :pointer))
+
+(defcfun ("create_search_engine" create-search-engine) :pointer
+ (space :pointer))
+
+(defcfun ("dispose_search_engine" dispose-search-engine) :void
+ (engine :pointer))
+
+(defcfun ("search_next" search-next) :pointer
+ (engine :pointer))
+
+(defcfun space-read-int :int
+ (space :pointer)
+ (index :int))
+
+(defcfun space-read-bool :boolean
+ (space :pointer)
+ (index :int))
+
+(defcfun gec-branch-vars-min :void
+ (space :pointer))
+
+(defcfun gec-branch-vars-med :void
+ (space :pointer))
+
+(defcfun gec-branch-vars-max :void
+ (space :pointer))
+
+(defcfun ("gec_rel_var" gec-rel-var) :void
+ (space :pointer)
+ (x :int)
+ (type int-rel-type)
+ (y :int)
+ (level int-con-level))
+
+(defcfun ("gec_rel_const" gec-rel-const) :void
+ (space :pointer)
+ (x :int)
+ (type int-rel-type)
+ (c :int)
+ (level int-con-level))
+
+(defcfun ("gec_rel_reif" gec-rel-reif) :void
+ (space :pointer)
+ (x :int)
+ (type int-rel-type)
+ (y :int)
+ (b :int)
+ (level int-con-level))
+
+(defcfun ("gec_dom_var" gec-dom-var) :void
+ (space :pointer)
+ (x :int)
+ (min :int)
+ (max :int)
+ (level int-con-level))
+
+(defcfun ("gec_dom_var_set" %gec-dom-var-set) :void
+ (space :pointer)
+ (x :int)
+ (dom :pointer)
+ (n :int)
+ (level int-con-level))
+
+(defcfun ("gec_linear_var" %gec-linear-var) :void
+ (space :pointer)
+ (res :int)
+ (type int-rel-type)
+ (xs :pointer)
+ (n :int)
+ (level int-con-level))
+
+(defcfun ("gec_linear_const" %gec-linear-const) :void
+ (space :pointer)
+ (res :int)
+ (type int-rel-type)
+ (xs :pointer)
+ (n :int)
+ (level int-con-level))
+
+(defcfun ("gec_distinct" %gec-distinct) :void
+ (space :pointer)
+ (xs :pointer)
+ (n :int)
+ (level int-con-level))
+
+(defcfun ("gec_distance" gec-distance) :void
+ (space :pointer)
+ (res :int)
+ (a :int)
+ (b :int))
+
+(defcfun gec-distance-const :void
+ (space :pointer)
+ (res :int)
+ (a :int)
+ (b :int))
+
+(defcfun ("gec_min" gec-min) :void
+ (space :pointer)
+ (res :int)
+ (a :int)
+ (b :int)
+ (level int-con-level))
+
+(defcfun ("gec_max" gec-max) :void
+ (space :pointer)
+ (res :int)
+ (a :int)
+ (b :int)
+ (level int-con-level))
+
+(defcfun ("gec_mult" gec-mult) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_minus" gec-minus) :void
+ (space :pointer)
+ (res :int)
+ (a :int)
+ (b :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_eq" gec-bool-eq) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_eq_const" gec-bool-eq-const) :void
+ (space :pointer)
+ (a :int)
+ (const :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_not" gec-bool-not) :void
+ (space :pointer)
+ (a :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_and" gec-bool-and) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_and_const" gec-bool-and-const) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_or" gec-bool-or) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_or_const" gec-bool-or-const) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_xor" gec-bool-xor) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_xor_const" gec-bool-xor-const) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_imp" gec-bool-imp) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_imp_const" gec-bool-imp-const) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_eqv" gec-bool-eqv) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_bool_eqv_const" gec-bool-eqv-const) :void
+ (space :pointer)
+ (a :int)
+ (b :int)
+ (res :int)
+ (level int-con-level))
+
+(defcfun ("gec_int_assigned" gec-int-assigned) :boolean
+ (space :pointer)
+ (x :int))
+
+(defcfun ("gec_bool_assigned" gec-bool-assigned) :boolean
+ (space :pointer)
+ (x :int))
+
+(defcfun ("gec_element_const" %gec-element-const) :void
+ (space :pointer)
+ (ns :pointer)
+ (n :int)
+ (x0 :int)
+ (x1 :int)
+ (level int-con-level))
+
+(defcfun ("gec_element_vars" %gec-element-vars) :void
+ (space :pointer)
+ (xs :pointer)
+ (n :int)
+ (x0 :int)
+ (x1 :int)
+ (level int-con-level))
+
+(defcfun ("gec_mod_12" gec-mod-12) :void
+ (space :pointer)
+ (x :int)
+ (m :int))
+
diff -rN -u old-gecol/gec.lisp new-gecol/gec.lisp
--- old-gecol/gec.lisp 1969-12-31 16:00:00.000000000 -0800
+++ new-gecol/gec.lisp 2014-07-25 08:23:54.000000000 -0700
@@ -0,0 +1,72 @@
+;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: GECOL; Base: 10 -*-
+;;; arch-tag: B2840A52-3BDD-47DB-A03F-1C700ACFF6BC
+
+;;; Copyright (c) 2006, Kilian Sprotte. All rights reserved.
+
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions
+;;; are met:
+
+;;; * Redistributions of source code must retain the above copyright
+;;; notice, this list of conditions and the following disclaimer.
+
+;;; * Redistributions in binary form must reproduce the above
+;;; copyright notice, this list of conditions and the following
+;;; disclaimer in the documentation and/or other materials
+;;; provided with the distribution.
+
+;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
+;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+(in-package :gecol)
+
+(defun gec-dom-var-set (space x dom level)
+ (let ((n (length dom)))
+ (with-foreign-object (xs :int n)
+ (dotimes (i n)
+ (setf (mem-aref xs :int i) (nth i dom)))
+ (%gec-dom-var-set space x xs n level))))
+
+(defun gec-linear-var (space res type list level)
+ (let ((n (length list)))
+ (with-foreign-object (xs :int n)
+ (dotimes (i n)
+ (setf (mem-aref xs :int i) (nth i list)))
+ (%gec-linear-var space res type xs n level))))
+
+(defun gec-linear-const (space res type list level)
+ (let ((n (length list)))
+ (with-foreign-object (xs :int n)
+ (dotimes (i n)
+ (setf (mem-aref xs :int i) (nth i list)))
+ (%gec-linear-const space res type xs n level))))
+
+(defun gec-distinct (space list level)
+ (let ((n (length list)))
+ (with-foreign-object (xs :int n)
+ (dotimes (i n)
+ (setf (mem-aref xs :int i) (nth i list)))
+ (%gec-distinct space xs n level))))
+
+(defun gec-element-vars (space list ind var level)
+ (let ((n (length list)))
+ (with-foreign-object (xs :int n)
+ (dotimes (i n)
+ (setf (mem-aref xs :int i) (nth i list)))
+ (%gec-element-vars space xs n ind var level))))
+
+(defun gec-element-const (space list ind var level)
+ (let ((n (length list)))
+ (with-foreign-object (xs :int n)
+ (dotimes (i n)
+ (setf (mem-aref xs :int i) (nth i list)))
+ (%gec-element-const space xs n ind var level))))
\ No newline at end of file
diff -rN -u old-gecol/glue.cpp new-gecol/glue.cpp
--- old-gecol/glue.cpp 1969-12-31 16:00:00.000000000 -0800
+++ new-gecol/glue.cpp 2014-07-25 08:23:54.000000000 -0700
@@ -0,0 +1,450 @@
+// arch-tag: DB2FEBED-DE12-4185-B2F1-225EC7A49C12
+
+// Copyright (c) 2006, Kilian Sprotte. All rights reserved.
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials
+// provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
+// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "gecode/int.hh"
+#include "gecode/search.hh"
+#include "gecode/minimodel.hh"
+
+using namespace Gecode;
+
+extern "C" {
+ void* create_space(int varnum, int varmin, int varmax, int boolnum);
+ void dispose_space(void* space);
+ void* create_search_engine(void* space);
+ void dispose_search_engine(void* engine);
+ void* search_next(void* engine);
+ bool gec_int_assigned(void* space, int x);
+ bool gec_bool_assigned(void* space, int x);
+ int space_read_int(void* space, int index);
+ int space_read_bool(void* space, int index);
+ void gec_branch_vars_min(void* space);
+ void gec_branch_vars_med(void* space);
+ void gec_branch_vars_max(void* space);
+
+ void gec_rel_var(void* space, int x, int type, int y, int level);
+ void gec_rel_const(void* space, int x, int type, int c, int level);
+ void gec_rel_reif(void* space, int x, int type, int y, int b, int level);
+ void gec_dom_var(void* space, int x, int min, int max, int level);
+ void gec_dom_var_set(void* space, int x, int* d, int n, int level);
+ void gec_linear_var(void* space, int res, int type, int* xs, int n, int level);
+ void gec_linear_const(void* space, int res, int type, int* xs, int n, int level);
+ void gec_distinct(void* space, int* xs, int n, int level);
+ void gec_distance(void* space, int res, int a, int b);
+ void gec_distance_const(void* space, int res, int a, int b);
+ void gec_min(void* space, int res, int a, int b, int level);
+ void gec_max(void* space, int res, int a, int b, int level);
+ void gec_mult(void* space, int a, int b, int res, int level);
+ void gec_minus(void* space, int res, int a, int b, int level);
+
+ void gec_bool_eq(void* space, int a, int b, int level);
+ void gec_bool_eq_const(void* space, int a, int b, int level);
+ void gec_bool_not(void* space, int a, int res, int level);
+ void gec_bool_and(void* space, int a, int b, int res, int level);
+ void gec_bool_and_const(void* space, int a, int b, int res, int level);
+ void gec_bool_or(void* space, int a, int b, int res, int level);
+ void gec_bool_or_const(void* space, int a, int b, int res, int level);
+ void gec_bool_xor(void* space, int a, int b, int res, int level);
+ void gec_bool_xor_const(void* space, int a, int b, int res, int level);
+ void gec_bool_imp(void* space, int a, int b, int res, int level);
+ void gec_bool_imp_const(void* space, int a, int b, int res, int level);
+ void gec_bool_eqv(void* space, int a, int b, int res, int level);
+ void gec_bool_eqv_const(void* space, int a, int b, int res, int level);
+
+ void gec_element_const(void* space, int* ns, int n, int x0, int x1, int level);
+ void gec_element_vars(void* space, int* xs, int n, int x0, int x1, int level);
+
+ void gec_mod_12(void* space, int x, int m);
+}
+
+class Simple : public Space {
+protected:
+ IntVarArray vars;
+ BoolVarArray bools;
+public:
+ Simple(int varnum, int varmin, int varmax,
+ int boolnum) : vars(this, varnum, varmin, varmax),
+ bools(this, boolnum, 0, 1)
+ {
+ }
+ /// Constructor for cloning \a s
+ Simple(bool share, Simple& s) : Space(share,s) {
+ vars.update(this, share, s.vars);
+ bools.update(this, share, s.bools);
+ }
+ /// Copy during cloning
+ virtual Space*
+ copy(bool share) {
+ return new Simple(share,*this);
+ }
+ IntVarArray* get_vars () {
+ return &vars;
+ }
+ IntVarArray get_vars2 () {
+ return vars;
+ }
+ BoolVarArray get_bools2 () {
+ return bools;
+ }
+};
+
+void* create_space(int varnum, int varmin, int varmax, int boolnum)
+{
+ Simple* s = new Simple(varnum, varmin, varmax, boolnum);
+ return (void*)s;
+}
+
+void dispose_space(void* space)
+{
+ delete (Simple*)space;
+}
+
+void* create_search_engine(void* space)
+{
+ Simple* s = (Simple*)space;
+ DFS<Simple>* e = new DFS<Simple>(s,1,1);
+ return (void*)e;
+}
+
+void dispose_search_engine(void* engine)
+{
+ delete (DFS<Simple>*)engine;
+}
+
+void* search_next(void* engine)
+{
+ DFS<Simple>* e = (DFS<Simple>*)engine;
+ return (void*)e->next();
+}
+
+// TODO ch to get_vars2
+int space_read_int(void* space, int index)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray* array = s->get_vars();
+ IntVar x = (*array)[index];
+ return x.val();
+}
+
+int space_read_bool(void* space, int index)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray array = s->get_bools2();
+ BoolVar x = array[index];
+ return x.val();
+}
+
+void gec_branch_vars_min(void* space)
+{
+ branch((Simple*)space,(*((Simple*)space)->get_vars()),BVAR_NONE,BVAL_MIN);
+}
+
+void gec_branch_vars_med(void* space)
+{
+ branch((Simple*)space,(*((Simple*)space)->get_vars()),BVAR_NONE,BVAL_MED);
+}
+
+void gec_branch_vars_max(void* space)
+{
+ branch((Simple*)space,(*((Simple*)space)->get_vars()),BVAR_NONE,BVAL_MAX);
+}
+
+void gec_rel_var(void* space, int x, int type, int y, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ rel(s, vars[x], (IntRelType)type, vars[y], (IntConLevel)level);
+}
+
+void gec_rel_const(void* space, int x, int type, int c, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ rel(s, vars[x], (IntRelType)type, c, (IntConLevel)level);
+}
+
+void gec_rel_reif(void* space, int x, int type, int y, int b, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ BoolVarArray bools = s->get_bools2();
+ rel(s, vars[x], (IntRelType)type, vars[y], bools[b], (IntConLevel)level);
+}
+
+void gec_dom_var(void* space, int x, int min, int max, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ dom(s, vars[x], min, max, (IntConLevel)level);
+}
+
+void gec_dom_var_set(void* space, int x, int* d, int n, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntSet set(d, n);
+ dom(s, vars[x], set, (IntConLevel)level);
+}
+
+void gec_linear_var(void* space, int res, int type, int* xs, int n, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntVarArgs a = IntVarArgs(n);
+ int i;
+ for(i=0;i<n;i++) {
+ IntVar q;
+ q = vars[xs[i]];
+ a[i] = q;
+ }
+ linear(s, a, (IntRelType)type, vars[res], (IntConLevel)level);
+}
+
+void gec_linear_const(void* space, int res, int type, int* xs, int n, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntVarArgs a = IntVarArgs(n);
+ int i;
+ for(i=0;i<n;i++) {
+ IntVar q;
+ q = vars[xs[i]];
+ a[i] = q;
+ }
+ linear(s, a, (IntRelType)type, res, (IntConLevel)level);
+}
+
+void gec_distinct(void* space, int* xs, int n, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntVarArgs a = IntVarArgs(n);
+ int i;
+ for(i=0;i<n;i++) {
+ IntVar q;
+ q = vars[xs[i]];
+ a[i] = q;
+ }
+ distinct(s, a, (IntConLevel)level);
+}
+
+void gec_distance(void* space, int res, int a, int b)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntVar m;
+ m = minus(s, vars[a], vars[b], ICL_DEF);
+ abs(s, m, vars[res], ICL_DEF);
+}
+
+void gec_distance_const(void* space, int res, int a, int b)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntVar m;
+ IntVar resvar = IntVar(s, res, res);
+ m = minus(s, vars[a], vars[b], ICL_DEF);
+ abs(s, m, resvar, ICL_DEF);
+}
+
+
+void gec_min(void* space, int res, int a, int b, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ min(s, vars[a], vars[b], vars[res], (IntConLevel)level);
+}
+
+void gec_max(void* space, int res, int a, int b, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ max(s, vars[a], vars[b], vars[res], (IntConLevel)level);
+}
+
+void gec_mult(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ mult(s, vars[a], vars[b], vars[res], (IntConLevel)level);
+}
+
+void gec_minus(void* space, int res, int a, int b, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntVar x = vars[a];
+ IntVar y = vars[b];
+ IntVar z = vars[res];
+ dom(s, z, x.min()-y.max(), x.max()-y.min(), (IntConLevel)level);
+ Int::Linear::Term ts[3];
+ ts[0].a = 1; ts[0].x = x;
+ ts[1].a = -1; ts[1].x = y;
+ ts[2].a = -1; ts[2].x = z;
+ Int::Linear::post(s, ts, 3, IRT_EQ, 0, (IntConLevel)level);
+}
+
+void gec_bool_eq(void* space, int a, int b, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_eq(s, bools[a], bools[b], (IntConLevel)level);
+}
+
+void gec_bool_eq_const(void* space, int a, int b, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ rel(s, bools[a], IRT_EQ, b, (IntConLevel)level);
+}
+
+void gec_bool_not(void* space, int a, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_not(s, bools[a], bools[res], (IntConLevel)level);
+}
+
+void gec_bool_and(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_and(s, bools[a], bools[b], bools[res], (IntConLevel)level);
+}
+
+void gec_bool_and_const(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_and(s, bools[a], bools[b], res, (IntConLevel)level);
+}
+
+void gec_bool_or(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_or(s, bools[a], bools[b], bools[res], (IntConLevel)level);
+}
+
+void gec_bool_or_const(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_or(s, bools[a], bools[b], res, (IntConLevel)level);
+}
+
+void gec_bool_xor(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_xor(s, bools[a], bools[b], bools[res], (IntConLevel)level);
+}
+
+void gec_bool_xor_const(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_xor(s, bools[a], bools[b], res, (IntConLevel)level);
+}
+
+void gec_bool_imp(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_imp(s, bools[a], bools[b], bools[res], (IntConLevel)level);
+}
+
+void gec_bool_imp_const(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_imp(s, bools[a], bools[b], res, (IntConLevel)level);
+}
+
+void gec_bool_eqv(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_eqv(s, bools[a], bools[b], bools[res], (IntConLevel)level);
+}
+
+void gec_bool_eqv_const(void* space, int a, int b, int res, int level)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ bool_eqv(s, bools[a], bools[b], res, (IntConLevel)level);
+}
+
+bool gec_int_assigned(void* space, int x)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ return (vars[x]).assigned();
+}
+
+bool gec_bool_assigned(void* space, int x)
+{
+ Simple* s = (Simple*)space;
+ BoolVarArray bools = s->get_bools2();
+ return (bools[x]).assigned();
+}
+
+void gec_element_const(void* space, int* ns, int n, int x0, int x1, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntArgs a = IntArgs(n);
+ int i;
+ for(i=0;i<n;i++) {
+ a[i] = ns[i];
+ }
+ element(s, a, vars[x0], vars[x1], (IntConLevel)level);
+}
+
+void gec_element_vars(void* space, int* xs, int n, int x0, int x1, int level)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntVarArgs a = IntVarArgs(n);
+ int i;
+ for(i=0;i<n;i++) {
+ IntVar q;
+ q = vars[xs[i]];
+ a[i] = q;
+ }
+ element(s, a, vars[x0], vars[x1], (IntConLevel)level);
+}
+
+void gec_mod_12(void* space, int x, int m)
+{
+ Simple* s = (Simple*)space;
+ IntVarArray vars = s->get_vars2();
+ IntVar twelve(s, 12, 12);
+ IntVar oct(s, 1, 11);
+ IntVar start = minus(s, vars[x], vars[m], ICL_DOM);
+ mult(s, oct, twelve, start, ICL_DOM);
+}
diff -rN -u old-gecol/package.lisp new-gecol/package.lisp
--- old-gecol/package.lisp 1969-12-31 16:00:00.000000000 -0800
+++ new-gecol/package.lisp 2014-07-25 08:23:54.000000000 -0700
@@ -0,0 +1,79 @@
+;;; -*- Mode: LISP; Syntax: COMMON-LISP; Base: 10 -*-
+;;; arch-tag: 69AB34D5-8516-DBE0-76B43C49CD70
+
+;;; Copyright (c) 2006, Kilian Sprotte. All rights reserved.
+
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions
+;;; are met:
+
+;;; * Redistributions of source code must retain the above copyright
+;;; notice, this list of conditions and the following disclaimer.
+
+;;; * Redistributions in binary form must reproduce the above
+;;; copyright notice, this list of conditions and the following
+;;; disclaimer in the documentation and/or other materials
+;;; provided with the distribution.
+
+;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
+;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+(in-package :cl-user)
+
+(defpackage :gecol
+ (:documentation "This is the gecol package, providing bindings to work with GECODE.")
+ (:use :cl :geno :iterate :arnesi :cffi)
+ (:export
+ #:create-search-engine
+ #:create-space
+ #:dispose-search-engine
+ #:dispose-space
+ #:search-next
+ #:space-read-int
+ #:space-read-bool
+ ;; propagators
+ #:gec-bool-and
+ #:gec-bool-and-const
+ #:gec-bool-assigned
+ #:gec-bool-eq
+ #:gec-bool-eq-const
+ #:gec-bool-eqv
+ #:gec-bool-eqv-const
+ #:gec-bool-imp
+ #:gec-bool-imp-const
+ #:gec-bool-not
+ #:gec-bool-or
+ #:gec-bool-or-const
+ #:gec-bool-xor
+ #:gec-bool-xor-const
+ #:gec-branch-vars-max
+ #:gec-branch-vars-med
+ #:gec-branch-vars-min
+ #:gec-distance
+ #:gec-distance-const
+ #:gec-distinct
+ #:gec-dom-var
+ #:gec-dom-var-set
+ #:gec-element-const
+ #:gec-element-vars
+ #:gec-int-assigned
+ #:gec-linear-const
+ #:gec-linear-var
+ #:gec-max
+ #:gec-min
+ #:gec-minus
+ #:gec-mod-12
+ #:gec-mult
+ #:gec-rel-const
+ #:gec-rel-reif
+ #:gec-rel-var
+ ))
diff -rN -u old-gecol/placeholder new-gecol/placeholder
--- old-gecol/placeholder 2014-07-25 08:23:54.000000000 -0700
+++ new-gecol/placeholder 1969-12-31 16:00:00.000000000 -0800
@@ -1,2 +0,0 @@
-this is just for testing
-another line