Generated on Tue Apr 18 10:22:18 2017 for Gecode by doxygen 1.6.3

zebra.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2014
00008  *
00009  *  Last modified:
00010  *     $Date: 2014-11-04 13:28:32 +0100 (Tue, 04 Nov 2014) $ by $Author: schulte $
00011  *     $Revision: 14287 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #include "test/flatzinc.hh"
00039 
00040 namespace Test { namespace FlatZinc {
00041 
00042   namespace {
00044     class Create {
00045     public:
00046 
00048       Create(void) {
00049         (void) new FlatZincTest("zebra",
00050 "predicate all_different_int(array [int] of var int: x);\n\
00051 predicate all_equal_int(array [int] of var int: x);\n\
00052 predicate among(var int: n, array [int] of var int: x, set of int: v);\n\
00053 predicate array_bool_lq(array [int] of var bool: x, array [int] of var bool: y);\n\
00054 predicate array_bool_lt(array [int] of var bool: x, array [int] of var bool: y);\n\
00055 predicate array_int_lq(array [int] of var int: x, array [int] of var int: y);\n\
00056 predicate array_int_lt(array [int] of var int: x, array [int] of var int: y);\n\
00057 predicate array_set_partition(array [int] of var set of int: S, set of int: universe);\n\
00058 predicate at_least_int(int: n, array [int] of var int: x, int: v);\n\
00059 predicate at_most_int(int: n, array [int] of var int: x, int: v);\n\
00060 predicate bool_lin_ge(array [int] of int: a, array [int] of var bool: x, var int: c);\n\
00061 predicate bool_lin_gt(array [int] of int: a, array [int] of var bool: x, var int: c);\n\
00062 predicate bool_lin_lt(array [int] of int: a, array [int] of var bool: x, var int: c);\n\
00063 predicate bool_lin_ne(array [int] of int: a, array [int] of var bool: x, var int: c);\n\
00064 predicate count(array [int] of var int: x, var int: y, var int: c);\n\
00065 predicate count_reif(array [int] of var int: x, var int: y, var int: c, var bool: b);\n\
00066 predicate cumulatives(array [int] of var int: s, array [int] of var int: d, array [int] of var int: r, var int: b);\n\
00067 predicate decreasing_bool(array [int] of var bool: x);\n\
00068 predicate decreasing_int(array [int] of var int: x);\n\
00069 predicate disjoint(var set of int: s1, var set of int: s2);\n\
00070 predicate gecode_array_set_element_union(var set of int: x, array [int] of var set of int: y, var set of int: z);\n\
00071 predicate gecode_bin_packing_load(array [int] of var int: l, array [int] of var int: bin, array [int] of int: w, int: minIndex);\n\
00072 predicate gecode_circuit(int: offset, array [int] of var int: x);\n\
00073 predicate gecode_int_set_channel(array [int] of var int: x, int: xoff, array [int] of var set of int: y, int: yoff);\n\
00074 predicate gecode_inverse_set(array [int] of var set of int: f, array [int] of var set of int: invf, int: xoff, int: yoff);\n\
00075 predicate gecode_link_set_to_booleans(var set of int: s, array [int] of var bool: b, int: idx);\n\
00076 predicate gecode_member_bool_reif(array [int] of var bool: x, var bool: y, var bool: b);\n\
00077 predicate gecode_member_int_reif(array [int] of var int: x, var int: y, var bool: b);\n\
00078 predicate gecode_nooverlap(array [int] of var int: x, array [int] of var int: w, array [int] of var int: y, array [int] of var int: h);\n\
00079 predicate gecode_precede(array [int] of var int: x, int: s, int: t);\n\
00080 predicate gecode_precede_set(array [int] of var set of int: x, int: s, int: t);\n\
00081 predicate gecode_range(array [int] of var int: x, int: xoff, var set of int: s, var set of int: t);\n\
00082 predicate gecode_set_weights(array [int] of int: csi, array [int] of int: cs, var set of int: x, var int: y);\n\
00083 predicate global_cardinality(array [int] of var int: x, array [int] of int: cover, array [int] of var int: counts);\n\
00084 predicate global_cardinality_closed(array [int] of var int: x, array [int] of int: cover, array [int] of var int: counts);\n\
00085 predicate global_cardinality_low_up(array [int] of var int: x, array [int] of int: cover, array [int] of int: lbound, array [int] of int: ubound);\n\
00086 predicate global_cardinality_low_up_closed(array [int] of var int: x, array [int] of int: cover, array [int] of int: lbound, array [int] of int: ubound);\n\
00087 predicate increasing_bool(array [int] of var bool: x);\n\
00088 predicate increasing_int(array [int] of var int: x);\n\
00089 predicate inverse_offsets(array [int] of var int: f, int: foff, array [int] of var int: invf, int: invfoff);\n\
00090 predicate maximum_int(var int: m, array [int] of var int: x);\n\
00091 predicate member_bool(array [int] of var bool: x, var bool: y);\n\
00092 predicate member_int(array [int] of var int: x, var int: y);\n\
00093 predicate minimum_int(var int: m, array [int] of var int: x);\n\
00094 predicate nvalue(var int: n, array [int] of var int: x);\n\
00095 predicate regular(array [int] of var int: x, int: Q, int: S, array [int, int] of int: d, int: q0, set of int: F);\n\
00096 predicate sort(array [int] of var int: x, array [int] of var int: y);\n\
00097 predicate table_bool(array [int] of var bool: x, array [int, int] of bool: t);\n\
00098 predicate table_int(array [int] of var int: x, array [int, int] of int: t);\n\
00099 var bool: BOOL____00001 :: is_defined_var :: var_is_introduced;\n\
00100 var bool: BOOL____00002 :: is_defined_var :: var_is_introduced;\n\
00101 var bool: BOOL____00004 :: is_defined_var :: var_is_introduced;\n\
00102 var bool: BOOL____00005 :: is_defined_var :: var_is_introduced;\n\
00103 var bool: BOOL____00007 :: is_defined_var :: var_is_introduced;\n\
00104 var bool: BOOL____00008 :: is_defined_var :: var_is_introduced;\n\
00105 array [1..5] of var 1..5: animal :: output_array([0..4]);\n\
00106 array [1..5] of var 1..5: colour :: output_array([0..4]);\n\
00107 array [1..5] of var 1..5: drink :: output_array([0..4]);\n\
00108 array [1..5] of var 1..5: nation :: output_array([0..4]);\n\
00109 array [1..5] of var 1..5: smoke :: output_array([0..4]);\n\
00110 constraint all_different_int(animal);\n\
00111 constraint all_different_int(colour);\n\
00112 constraint all_different_int(drink);\n\
00113 constraint all_different_int(nation);\n\
00114 constraint all_different_int(smoke);\n\
00115 constraint array_bool_or([BOOL____00001, BOOL____00002], true);\n\
00116 constraint array_bool_or([BOOL____00004, BOOL____00005], true);\n\
00117 constraint array_bool_or([BOOL____00007, BOOL____00008], true);\n\
00118 constraint int_eq(3, drink[3]);\n\
00119 constraint int_eq(animal[1], nation[2]);\n\
00120 constraint int_eq(animal[5], smoke[1]);\n\
00121 constraint int_eq(colour[1], nation[1]);\n\
00122 constraint int_eq(colour[2], drink[1]);\n\
00123 constraint int_eq(colour[4], smoke[2]);\n\
00124 constraint int_eq(drink[2], nation[3]);\n\
00125 constraint int_eq(drink[4], smoke[4]);\n\
00126 constraint int_eq(nation[4], 1);\n\
00127 constraint int_eq(smoke[5], nation[5]);\n\
00128 constraint int_lin_eq([-1, 1], [colour[2], colour[3]], -1);\n\
00129 constraint int_lin_eq_reif([-1, 1], [animal[2], smoke[3]], -1, BOOL____00002) :: defines_var(BOOL____00002);\n\
00130 constraint int_lin_eq_reif([-1, 1], [animal[3], smoke[2]], -1, BOOL____00005) :: defines_var(BOOL____00005);\n\
00131 constraint int_lin_eq_reif([-1, 1], [colour[5], nation[4]], -1, BOOL____00008) :: defines_var(BOOL____00008);\n\
00132 constraint int_lin_eq_reif([1, -1], [animal[2], smoke[3]], -1, BOOL____00001) :: defines_var(BOOL____00001);\n\
00133 constraint int_lin_eq_reif([1, -1], [animal[3], smoke[2]], -1, BOOL____00004) :: defines_var(BOOL____00004);\n\
00134 constraint int_lin_eq_reif([1, -1], [colour[5], nation[4]], -1, BOOL____00007) :: defines_var(BOOL____00007);\n\
00135 solve satisfy;\n\
00136 ", "animal = array1d(0..4, [4, 1, 2, 5, 3]);\n\
00137 colour = array1d(0..4, [3, 5, 4, 1, 2]);\n\
00138 drink = array1d(0..4, [5, 2, 3, 4, 1]);\n\
00139 nation = array1d(0..4, [3, 4, 2, 1, 5]);\n\
00140 smoke = array1d(0..4, [3, 1, 2, 4, 5]);\n\
00141 ----------\n\
00142 ");
00143       }
00144     };
00145 
00146     Create c;
00147   }
00148 
00149 }}
00150 
00151 // STATISTICS: test-flatzinc