Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa98b6b94c | ||
|
|
1d2eb7a8d2 | ||
|
|
fa65627150 | ||
|
|
0e293b57b8 | ||
|
|
954cd02724 | ||
|
|
cd42d5a38b | ||
|
|
32cc34b0d5 | ||
|
|
cbc533dd63 | ||
|
|
997f87303e | ||
|
|
bb4bca56fb | ||
|
|
1c07710e8e | ||
|
|
b1f370cd56 | ||
|
|
3e500e64bf | ||
|
|
2d5c52acd5 | ||
|
|
658ddb53f2 | ||
|
|
3172c8ff23 | ||
|
|
2c00eb0c44 | ||
|
|
cb4a92bd4b | ||
|
|
5f31ee7019 | ||
|
|
49d91518ae | ||
|
|
e6dea62c32 | ||
|
|
f29077d926 | ||
|
|
24ebfae73b | ||
|
|
5bddbc5008 | ||
|
|
f06ce5a58e | ||
|
|
81bd4b0237 | ||
|
|
8f9ad51172 | ||
|
|
8ded925717 | ||
|
|
c1453e09a4 | ||
|
|
859c8282ea | ||
|
|
c17ceea043 | ||
|
|
791eec9d8c |
@@ -722,6 +722,15 @@ version if BRLCAD_BUNDLED_LIBS is also AUTO.
|
||||
Aliases: ENABLE_SPR
|
||||
|
||||
|
||||
--- BRLCAD_BSON ---
|
||||
|
||||
Option for enabling and disabling compilation of the Libbson library
|
||||
provided with BRL-CAD's source code. Default is BUNDLED, using
|
||||
the included other/src version.
|
||||
|
||||
Aliases: ENABLE_BSON
|
||||
|
||||
|
||||
--- BRLCAD_SC ---
|
||||
|
||||
Option for enabling and disabling compilation of the NIST Step Class
|
||||
@@ -732,16 +741,6 @@ first for a system version if BRLCAD_BUNDLED_LIBS is also AUTO.
|
||||
Aliases: ENABLE_SCL, ENABLE_STEP, ENABLE_STEP_CLASS_LIBRARIES
|
||||
|
||||
|
||||
--- BRLCAD_GECODE ---
|
||||
|
||||
Option for enabling and disabling compilation of the Gecode Constraint
|
||||
Solving Libraries provided with BRL-CAD's source code. Default is AUTO,
|
||||
responsive to the toplevel BRLCAD_BUNDLED_LIBS option and testing
|
||||
first for a system version if BRLCAD_BUNDLED_LIBS is also AUTO.
|
||||
|
||||
Aliases: ENABLE_GECODE
|
||||
|
||||
|
||||
--- BRLCAD_VDS ---
|
||||
|
||||
Option for enabling and disabling compilation of the libvds triangle
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
branch/binary-attributes
|
||||
========================
|
||||
|
||||
To turn on the use of binary attributes define:
|
||||
|
||||
USE_BINARY_ATTRIBUTES
|
||||
|
||||
E.g., prior to running CMake:
|
||||
|
||||
export CFLAGS=-DUSE_BINARY_ATTRIBUTES
|
||||
export CXXFLAGS=-DUSE_BINARY_ATTRIBUTES
|
||||
|
||||
external code added:
|
||||
-------------------
|
||||
|
||||
BSON
|
||||
specification: http://bsonspec.org/spec.html
|
||||
libbson source: https://github.com/mongodb/libbson
|
||||
current release tarball: https://github.com/mongodb/libbson/releases/
|
||||
libbson-1.3.0-beta0.tar.gz
|
||||
converter: libbson has tools included to convert BSON to/from JSON
|
||||
|
||||
Scheme
|
||||
------
|
||||
|
||||
The BRL-CAD V5 database seems to allow an arbitrary binary chunk
|
||||
following the ASCII attributes. The idea is to define the total
|
||||
attribute chunk length to include any desired binary objects. The
|
||||
read or write (RW) of the ASCII attributes stops with the char* RW of
|
||||
a double NULL which should be a sufficient stop RW mark. Then, any
|
||||
difference in length read versus attribute chunk length is the length
|
||||
of a chunk of binary attributes (BAs) which we will define as a BSON
|
||||
collection of BSON documents (??? check BSON terminology). At that
|
||||
point we use libbson to RW the BAs.
|
||||
|
||||
As a minumum, a BA must have an ASCII key and a binary value.
|
||||
Following the BSON specification, the user can add other objects in
|
||||
the BA if desired.
|
||||
|
||||
The user interface relies on AVS handling which will have to also
|
||||
handle the BAs (that appears to be doable). Our best practice should
|
||||
encourage (maybe require?) a BA to have a short ASCII comment.
|
||||
|
||||
We will need appropriate functions to convert BAs to/from AVS
|
||||
objects. In the course of developing the BA capability we will add a
|
||||
file IO scheme for users to manipulate the BAs.
|
||||
|
||||
User interface (mged)
|
||||
---------------------
|
||||
|
||||
Current attr usage
|
||||
******************
|
||||
|
||||
mged> attr
|
||||
Usage: attr {[-c sep_char] set|get|show|rm|append|sort|list} object [key [value] ... ]
|
||||
|
||||
Proposed attr usage
|
||||
*******************
|
||||
|
||||
mged> attr
|
||||
Usage: attr {[-c sep_char][-b] set|get|show|rm|append|sort|list} object [key [value] ... ]
|
||||
|
||||
Where the '-b', indicating a binary attribute (BA), works with 'get'
|
||||
and 'set' only (and ignored for the other commands).
|
||||
|
||||
Note that 'set' and 'get' for binary attributes require an external
|
||||
file name (which must must be a valid JSON file for 'set') and must
|
||||
NOT exist for 'get'. The 'append' command will NOT work for a BA.
|
||||
|
||||
The 'show', 'sort', and 'list' commands will show for BAs their key
|
||||
followed by followed by '(binary)' followed by their comment string,
|
||||
if it exists (we should make that mandatory I believe). The 'rm'
|
||||
command will remove the BA referenced by the key.
|
||||
|
||||
The BAs will have both a key and a comment, and it is an error to try
|
||||
to add a BA with a key the same as an existing key.
|
||||
|
||||
Tentative JSON format of a BA
|
||||
-----------------------------
|
||||
|
||||
(See http://www.json.org/ for the JSON specification.)
|
||||
|
||||
Functions needed
|
||||
----------------
|
||||
|
||||
JSON BA to/from in-memory AVS
|
||||
see current functions:
|
||||
|
||||
AVS BA to/from on-disk attribute body
|
||||
see current functions:
|
||||
|
||||
...
|
||||
|
||||
Macro definitions needed
|
||||
------------------------
|
||||
|
||||
Data structures needed
|
||||
----------------------
|
||||
|
||||
Other notes
|
||||
-----------
|
||||
Files affected:
|
||||
|
||||
./include/bu/parse.h
|
||||
./include/bu/avs.h
|
||||
./src/librt/db5_io.c
|
||||
./src/librt/attributes.c
|
||||
|
||||
Features to be implemented and other considerations:
|
||||
|
||||
+ add a binary attribute using similar syntax as a string attribute
|
||||
+ a binary attribute should have an optional description field
|
||||
+ implement auto update of an object's ctime (creation time) and
|
||||
mtime (last modification)
|
||||
+ mtime and ctime should be 64-bit integers (based on Unix time and
|
||||
epoch) (int64_t; see src/libbu/y2038/time64_config.h)
|
||||
+ binary attributes should be able to be entered from or output to a
|
||||
file
|
||||
|
||||
A db admin tool:
|
||||
|
||||
./src/util/db-admin-tool.cpp
|
||||
|
||||
On-disk format of a binary attribute [following the (char*)NULL
|
||||
(char*)NULL end of the normal attributes]:
|
||||
|
||||
While I believe we can use the existing AVS attribute section for BAs,
|
||||
I believe in the future we ought to create a separate object structure
|
||||
section for binary attributes, especially if we use a more compact
|
||||
binary representation such as CBOR.
|
||||
|
||||
The following describes the current V5 db:
|
||||
|
||||
BRL_CAD_g_format_V5.xml
|
||||
|
||||
The following describes the proposed V6 db with the binary attributes:
|
||||
|
||||
BRL_CAD_g_format_V6.xml
|
||||
|
||||
|
||||
Possible tests:
|
||||
|
||||
1. Simple TGM
|
||||
+ create a single-object TGM
|
||||
+ copy the TGM to a new file (TGM2)
|
||||
+ add multiple binary attributes to TGM2
|
||||
+ add a file to TGM2
|
||||
+ use the admin-db tool to check TGM2
|
||||
+ export the file; check that it is the same as was imported
|
||||
+ delete the added binary attributes from TGM2
|
||||
+ run cmp on TGM and TGM2 to see they are the same
|
||||
|
||||
2. Complex TGM
|
||||
+ select a complex TGM in the db directory as a test subject
|
||||
+ copy the TGM to a new file (TGM2)
|
||||
+ add multiple binary attributes to TGM2
|
||||
+ add a file to TGM2
|
||||
+ use the admin-db tool to check TGM2
|
||||
+ export the file; check that it is the same as was imported
|
||||
+ delete the added binary attributes from TGM2
|
||||
+ run cmp on TGM and TGM2 to see they are the same
|
||||
|
||||
See the TODO file, sections "ATTRIBUTES" and "THESE BREAK PROTOCOL OR
|
||||
ARE BACKWARDS-INCOMPATIBLE" for more official information.
|
||||
@@ -190,6 +190,10 @@ do
|
||||
shift;;
|
||||
--disable-spr) options="$options -DBRLCAD_SPR=SYSTEM";
|
||||
shift;;
|
||||
--enable-bson) options="$options -DBRLCAD_BSON=BUNDLED";
|
||||
shift;;
|
||||
--disable-bson) options="$options -DBRLCAD_BSON=SYSTEM";
|
||||
shift;;
|
||||
--enable-scl) options="$options -DBRLCAD_SC=BUNDLED";
|
||||
shift;;
|
||||
--disable-scl) options="$options -DBRLCAD_SC=SYSTEM";
|
||||
@@ -202,10 +206,6 @@ do
|
||||
shift;;
|
||||
--disable-step-class-libraries) options="$options -DBRLCAD_SC=SYSTEM";
|
||||
shift;;
|
||||
--enable-gecode) options="$options -DBRLCAD_GECODE=BUNDLED";
|
||||
shift;;
|
||||
--disable-gecode) options="$options -DBRLCAD_GECODE=SYSTEM";
|
||||
shift;;
|
||||
--enable-vds) options="$options -DBRLCAD_VDS=BUNDLED";
|
||||
shift;;
|
||||
--disable-vds) options="$options -DBRLCAD_VDS=SYSTEM";
|
||||
|
||||
@@ -92,8 +92,8 @@
|
||||
are combined using boolean operations to form regions of homogeneous material.
|
||||
</para>
|
||||
<para>
|
||||
The database is organized as a <emphasis>directed acyclic graph</emphasis> (DAG), which
|
||||
comprises
|
||||
The database is organized as a <emphasis>directed acyclic graph</emphasis> (DAG), which is
|
||||
comprised of:
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
@@ -107,7 +107,7 @@
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis>arcs</emphasis> - contain boolean operators and 4x4 homogeneous transformation matrices.</para>
|
||||
<para><emphasis>arcs</emphasis> - containing boolean operators and 4x4 homogeneous transformation matrices.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
@@ -1600,14 +1600,6 @@
|
||||
place of anameN+1 signals the end of the ASCII attribute data.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
PROPOSED: A second type of attribute has an ASCII key but a binary value.
|
||||
Such attributes follow the ASCII-valued ones after the double NULLs:
|
||||
<literallayout class="normal">anameN+1 NULL uintN <uintN binary bytes> [...0 or more binary attribute pairs]</literallayout>
|
||||
where, for each binary attribute pair, the uintN is of size AWid and is
|
||||
the length of the binary value for its ASCII key.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Every object in the database may have zero or more attributes
|
||||
attached to it; the meaning of these attributes will vary
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,10 @@
|
||||
#include "bu/magic.h"
|
||||
#include "bu/vls.h"
|
||||
|
||||
#if defined(USE_BINARY_ATTRIBUTES)
|
||||
#include "bson.h"
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
# F I N D G E C O D E . C M A K E
|
||||
# BRL-CAD
|
||||
#
|
||||
# Copyright (c) 2011-2014 United States Government as represented by
|
||||
# the U.S. Army Research Laboratory.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. 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.
|
||||
#
|
||||
# 3. The name of the author may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
# 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.
|
||||
#
|
||||
###
|
||||
# - Find Gecode constraint programming libraries
|
||||
#
|
||||
# The following variables are set:
|
||||
#
|
||||
# GECODE_INCLUDE_DIR
|
||||
# GECODE_LIBRARIES
|
||||
|
||||
find_path(GECODE_INCLUDE_DIR gecode/search.hh)
|
||||
|
||||
find_library(GECODE_SUPPORT_LIB NAMES gecodesupport)
|
||||
find_library(GECODE_KERNEL_LIB NAMES gecodekernel)
|
||||
find_library(GECODE_SEARCH_LIB NAMES gecodesearch)
|
||||
find_library(GECODE_INT_LIB NAMES gecodeint)
|
||||
find_library(GECODE_SET_LIB NAMES gecodeset)
|
||||
find_library(GECODE_FLOAT_LIB NAMES gecodefloat)
|
||||
find_library(GECODE_MINIMODEL_LIB NAMES gecodeminimodel)
|
||||
find_library(GECODE_DRIVER_LIB NAMES gecodedriver)
|
||||
find_library(GECODE_FLATZINC_LIB NAMES gecodeflatzinc)
|
||||
|
||||
set(GECODE_LIBRARIES
|
||||
${GECODE_SUPPORT_LIB}
|
||||
${GECODE_KERNEL_LIB}
|
||||
${GECODE_SEARCH_LIB}
|
||||
${GECODE_INT_LIB}
|
||||
${GECODE_SET_LIB}
|
||||
${GECODE_FLOAT_LIB}
|
||||
${GECODE_MINIMODEL_LIB}
|
||||
${GECODE_DRIVER_LIB}
|
||||
${GECODE_FLATZINC_LIB}
|
||||
)
|
||||
|
||||
set(GECODE_LIBRARIES "${GECODE_LIBRARIES}" CACHE STRING "Gecode libraries")
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GECODE DEFAULT_MSG
|
||||
GECODE_SUPPORT_LIB
|
||||
GECODE_KERNEL_LIB
|
||||
GECODE_SEARCH_LIB
|
||||
GECODE_INT_LIB
|
||||
GECODE_SET_LIB
|
||||
GECODE_FLOAT_LIB
|
||||
GECODE_MINIMODEL_LIB
|
||||
GECODE_DRIVER_LIB
|
||||
GECODE_FLATZINC_LIB
|
||||
)
|
||||
|
||||
mark_as_advanced(
|
||||
GECODE_SUPPORT_LIB
|
||||
GECODE_KERNEL_LIB
|
||||
GECODE_SEARCH_LIB
|
||||
GECODE_INT_LIB
|
||||
GECODE_SET_LIB
|
||||
GECODE_FLOAT_LIB
|
||||
GECODE_MINIMODEL_LIB
|
||||
GECODE_DRIVER_LIB
|
||||
GECODE_FLATZINC_LIB
|
||||
)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -3,6 +3,8 @@ set(BU_INCLUDE_DIRS
|
||||
${BRLCAD_BINARY_DIR}/include
|
||||
${BRLCAD_SOURCE_DIR}/include
|
||||
${TCL_INCLUDE_DIRS}
|
||||
${BRLCAD_BINARY_DIR}/src/other/libbson/src/bson
|
||||
${BRLCAD_SOURCE_DIR}/src/other/libbson/src/bson
|
||||
)
|
||||
|
||||
# locally used but not needed by users of the library
|
||||
|
||||
@@ -2,24 +2,12 @@
|
||||
set(PC_INCLUDE_DIRS
|
||||
${BRLCAD_BINARY_DIR}/include
|
||||
${BRLCAD_SOURCE_DIR}/include
|
||||
${GECODE_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(PC_LOCAL_INCLUDE_DIRS)
|
||||
|
||||
BRLCAD_LIB_INCLUDE_DIRS(pc PC_INCLUDE_DIRS PC_LOCAL_INCLUDE_DIRS)
|
||||
|
||||
BRLCAD_ADDEXEC(cartesian-heart cartesian-heart.cpp "${GECODE_LIBRARIES}" NO_INSTALL)
|
||||
BRLCAD_ADDEXEC(gecode_solver_test gecode_solver_test.cpp "${GECODE_LIBRARIES}" NO_INSTALL)
|
||||
BRLCAD_ADDEXEC(gecode_librt_test gecode_librt_test.cpp "${GECODE_LIBRARIES}" NO_INSTALL)
|
||||
|
||||
set(pc_ignore_files
|
||||
README
|
||||
solver_test.cpp
|
||||
vm_test.cpp
|
||||
perpendicular.fzn
|
||||
NOTES
|
||||
domain_constraint_propagator.cpp
|
||||
)
|
||||
CMAKEFILES(${pc_ignore_files})
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
Looking at flatzinc as a constraint solver independent way to specify
|
||||
constraints - libpc could use that standard, and then do whatever is needed on
|
||||
the back end (talk to gecode, Google's or-tools solver, etc. via flatzinc
|
||||
directly, or translate as needed.)
|
||||
|
||||
Might be worthwhile for readability to support the higher level minizinc (or at
|
||||
least some part of it) and have libpc incorporate the ability to translate
|
||||
"under the hood" to flatzinc, if appropriately licensed translators can be
|
||||
found - the G12 project's tools may be of some use, but would have to be
|
||||
converted from the Mercury language to C: http://www.mercurylang.org/
|
||||
|
||||
Would have to think about a generic C structure to hold minizinc/flatzinc
|
||||
results in a programmatically useful form - it wouldn't do to parse the text
|
||||
outputs, although they should be available for debugging if needed...
|
||||
|
||||
Minizinc 2.0 is worth keeping an eye on - license is MPL2, which is between
|
||||
Apache and LGPLv2 from a practical standpoint (can't combine with our code, but
|
||||
we can use it - do need to provide modified versions of original code, but
|
||||
license isn't viral):
|
||||
|
||||
http://www.minizinc.org/2.0/index.html
|
||||
|
||||
It's being actively developed in C++ rather than Mercury, which is a Good Thing
|
||||
from a support standpoint. Even has its own CMake build. It's not stable yet,
|
||||
but if it works out libpc might end up being a thin wrapper over this API plus
|
||||
a batch of predefined constraints...
|
||||
|
||||
Would require a flex -> perplex and bison -> lemon conversion from the looks
|
||||
of it, for a portable src/other version that doesn't use pre-generated files.
|
||||
Maybe in this case, since we presumably wouldn't be developing libminizinc
|
||||
ourselves the way we did with stepcode, we could get away with pre-generated
|
||||
cached files in the event flex/bison aren't around...
|
||||
@@ -1,120 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
|
||||
*
|
||||
* Copyright:
|
||||
* Vincent Barichard, 2012
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gecode/driver.hh>
|
||||
|
||||
#include <gecode/minimodel.hh>
|
||||
#include <gecode/float.hh>
|
||||
|
||||
using namespace Gecode;
|
||||
|
||||
/**
|
||||
* \brief %Example: Cartesian Heart
|
||||
*
|
||||
* There are many mathematical curves that produce heart shapes.
|
||||
* With a good solving effort, coordinates of a filled heart shape
|
||||
* can be computed by solving the cartesian equation:
|
||||
*
|
||||
* \f[
|
||||
* x^2+2\left(y-p\times\operatorname{abs}(x)^{\frac{1}{q}}\right)^2 = 1
|
||||
* \f]
|
||||
*
|
||||
* By setting \f$p=0.5\f$ and \f$q=2\f$, it yields to the equation:
|
||||
*
|
||||
* \f[
|
||||
* x^2+2\left(y-\frac{\operatorname{abs}(x)^{\frac{1}{2}}}{2}\right)^2 = 1
|
||||
* \f]
|
||||
*
|
||||
* To get reasonable interval starting sizes, \f$x\f$ and \f$y\f$
|
||||
* are restricted to \f$[-20;20]\f$.
|
||||
*
|
||||
* \ingroup Example
|
||||
*/
|
||||
class CartesianHeart : public Script {
|
||||
protected:
|
||||
/// The numbers
|
||||
FloatVarArray f;
|
||||
/// Minimum distance between two solutions
|
||||
FloatNum step;
|
||||
public:
|
||||
/// Actual model
|
||||
CartesianHeart(const Options&)
|
||||
: f(*this,2,-20,20), step(0.01) {
|
||||
int q = 2;
|
||||
FloatNum p = 0.5;
|
||||
// Post equation
|
||||
rel(*this, sqr(f[0]) + 2*sqr(f[1]-p*nroot(abs(f[0]),q)) == 1);
|
||||
branch(*this, f[0], FLOAT_VAL_SPLIT_MIN());
|
||||
branch(*this, f[1], FLOAT_VAL_SPLIT_MIN());
|
||||
}
|
||||
/// Constructor for cloning \a p
|
||||
CartesianHeart(bool share, CartesianHeart& p)
|
||||
: Script(share,p), step(p.step) {
|
||||
f.update(*this,share,p.f);
|
||||
}
|
||||
/// Copy during cloning
|
||||
virtual Space* copy(bool share) {
|
||||
return new CartesianHeart(share,*this);
|
||||
}
|
||||
/// Add constraints to current model to get next solution (not too close)
|
||||
virtual void constrain(const Space& _b) {
|
||||
const CartesianHeart& b = static_cast<const CartesianHeart&>(_b);
|
||||
rel(*this,
|
||||
(f[0] >= (b.f[0].max()+step)) ||
|
||||
(f[1] >= (b.f[1].max()+step)) ||
|
||||
(f[1] <= (b.f[1].min()-step)));
|
||||
}
|
||||
/// Print solution coordinates
|
||||
virtual void print(std::ostream& os) const {
|
||||
os << "XY " << f[0].med() << " " << f[1].med()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/** \brief Main-function
|
||||
* \relates CartesianHeart
|
||||
*/
|
||||
int main(int argc, char* argv[]) {
|
||||
Options opt("CartesianHeart");
|
||||
opt.parse(argc,argv);
|
||||
opt.solutions(0);
|
||||
Script::run<CartesianHeart,BAB,Options>(opt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// STATISTICS: example-any
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright:
|
||||
* Mikael Lagerkvist, 2007
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gecode/kernel.hh"
|
||||
#include "gecode/int.hh"
|
||||
#include "gecode/iter.hh"
|
||||
#include "gecode/int/rel.hh"
|
||||
|
||||
namespace Extra {
|
||||
using namespace ::Gecode;
|
||||
|
||||
/**
|
||||
* \brief Domain-consistent propagator for \f$ x_1=x_2\lor x_1=x_3\f$.
|
||||
*/
|
||||
template <class View>
|
||||
class DisEq : public TernaryPropagator<View,Int::PC_INT_DOM> {
|
||||
protected:
|
||||
using TernaryPropagator<View,Int::PC_INT_DOM>::x0;
|
||||
using TernaryPropagator<View,Int::PC_INT_DOM>::x1;
|
||||
using TernaryPropagator<View,Int::PC_INT_DOM>::x2;
|
||||
|
||||
/// Constructor for cloning \a p
|
||||
DisEq(Space* home, bool share, DisEq& p);
|
||||
/// Constructor for posting
|
||||
DisEq(Space* home, View x0, View x1, View x2);
|
||||
public:
|
||||
/// Constructor for rewriting \a p during cloning
|
||||
DisEq(Space* home, bool share, Propagator& p, View x0, View x1, View x2);
|
||||
/// Copy propagator during cloning
|
||||
virtual Actor* copy(Space* home, bool share);
|
||||
/// Perform propagation
|
||||
virtual ExecStatus propagate(Space* home, ModEventDelta);
|
||||
/// Post propagator
|
||||
static ExecStatus post(Space* home, View x0, View x1, View x2);
|
||||
};
|
||||
|
||||
template <class View>
|
||||
inline
|
||||
DisEq<View>::DisEq(Space* home, View dex0, View dex1, View dex2)
|
||||
: TernaryPropagator<View,Int::PC_INT_DOM>(home,dex0,dex1,dex2) {}
|
||||
|
||||
template <class View>
|
||||
ExecStatus
|
||||
DisEq<View>::post(Space* home, View dex0, View dex1, View dex2) {
|
||||
(void) new (home) DisEq<View>(home,dex0,dex1,dex2);
|
||||
return ES_OK;
|
||||
}
|
||||
|
||||
template <class View>
|
||||
inline
|
||||
DisEq<View>::DisEq(Space* home, bool share, DisEq<View>& p)
|
||||
: TernaryPropagator<View,Int::PC_INT_DOM>(home,share,p) {}
|
||||
|
||||
template <class View>
|
||||
inline
|
||||
DisEq<View>::DisEq(Space* home, bool share, Propagator& p,
|
||||
View dex0, View dex1, View dex2)
|
||||
: TernaryPropagator<View,Int::PC_INT_DOM>(home,share,p,dex0,dex1,dex2) {}
|
||||
|
||||
template <class View>
|
||||
Actor*
|
||||
DisEq<View>::copy(Space* home, bool share) {
|
||||
return new (home) DisEq<View>(home,share,*this);
|
||||
}
|
||||
|
||||
template <class View>
|
||||
ExecStatus
|
||||
DisEq<View>::propagate(Space* home, ModEventDelta) {
|
||||
typedef Int::ViewRanges<View> Ranges;
|
||||
|
||||
Ranges vr1(x1), vr2(x2);
|
||||
Iter::Ranges::Union<Ranges, Ranges> u12(vr1, vr2);
|
||||
GECODE_ME_CHECK(x0.inter_r(home, u12, false));
|
||||
|
||||
if (rtest_nq_dom(x0, x1) == Int::RT_TRUE)
|
||||
GECODE_REWRITE(this, (Int::Rel::EqDom<View, View>::post(home, x0, x2)));
|
||||
if (rtest_nq_dom(x0, x2) == Int::RT_TRUE)
|
||||
GECODE_REWRITE(this, (Int::Rel::EqDom<View, View>::post(home, x0, x1)));
|
||||
|
||||
return x0.assigned() && (x1.assigned() || x2.assigned()) ? ES_SUBSUMED(this,home) : ES_FIX;
|
||||
}
|
||||
|
||||
/** \brief Post propagator for \f$ x_1=x_2\lor x_1=x_3\f$
|
||||
*/
|
||||
void diseq(Space* home, IntVar x1, IntVar x2, IntVar x3) {
|
||||
Int::IntView v1(x1), v2(x2), v3(x3);
|
||||
GECODE_ES_FAIL(DisEq<Int::IntView>::post(home, v1, v2, v3));
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
/* G E C O D E _ L I B R T _ T E S T . C P P
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 2014 United States Government as represented by
|
||||
* the U.S. Army Research Laboratory.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; see the file named COPYING for more
|
||||
* information.
|
||||
*/
|
||||
/** @file gecode_librt_test.cpp
|
||||
*
|
||||
* @brief Gecode version of BRL-CAD Geometry Constraints
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gecode/int.hh>
|
||||
#include <gecode/minimodel.hh>
|
||||
#include <gecode/search.hh>
|
||||
|
||||
class GeometrySolve : public Gecode::Space {
|
||||
public:
|
||||
Gecode::IntVarArray l;
|
||||
GeometrySolve(int pnt_cnt, int min, int max) : l(*this, pnt_cnt, min, max) {}
|
||||
GeometrySolve(bool share, GeometrySolve& s) : Gecode::Space(share, s) {
|
||||
l.update(*this, share, s.l);
|
||||
}
|
||||
virtual Space* copy(bool share) {return new GeometrySolve(share,*this);}
|
||||
void print(void) const {std::cout << l << std::endl;}
|
||||
};
|
||||
|
||||
void
|
||||
add_constraint_coincident_pnt(GeometrySolve *s, int tol, int p1, int p2)
|
||||
{
|
||||
Gecode::IntVar AX(s->l[0 + 3*p1]), AY(s->l[1 + 3*p1]), AZ(s->l[2 + 3*p1]);
|
||||
Gecode::IntVar BX(s->l[0 + 3*p2]), BY(s->l[1 + 3*p2]), BZ(s->l[2 + 3*p2]);
|
||||
Gecode::rel(*s, AX - BX > -1 * tol);
|
||||
Gecode::rel(*s, AX - BX < tol);
|
||||
Gecode::rel(*s, AY - BY > -1 * tol);
|
||||
Gecode::rel(*s, AY - BY < tol);
|
||||
Gecode::rel(*s, AZ - BZ > -1 * tol);
|
||||
Gecode::rel(*s, AZ - BZ < tol);
|
||||
}
|
||||
|
||||
void
|
||||
add_constraint_perpendicular_vect(GeometrySolve *s, int tol, int p1, int p2)
|
||||
{
|
||||
Gecode::IntVar AX(s->l[0 + 3*p1]), AY(s->l[1 + 3*p1]), AZ(s->l[2 + 3*p1]);
|
||||
Gecode::IntVar BX(s->l[0 + 3*p2]), BY(s->l[1 + 3*p2]), BZ(s->l[2 + 3*p2]);
|
||||
Gecode::rel(*s, AX * BX + AY * BY + AZ * BZ > -1 * tol);
|
||||
Gecode::rel(*s, AX * BX + AY * BY + AZ * BZ < tol);
|
||||
}
|
||||
|
||||
void
|
||||
add_constraint_pnt_on_line_segment(GeometrySolve *s, int tol, int p, int s1, int s2)
|
||||
{
|
||||
Gecode::IntVar PX(s->l[0 + 3*p]), PY(s->l[1 + 3*p]), PZ(s->l[2 + 3*p]);
|
||||
Gecode::IntVar S1X(s->l[0 + 3*s1]), S1Y(s->l[1 + 3*s1]), S1Z(s->l[2 + 3*s1]);
|
||||
Gecode::IntVar S2X(s->l[0 + 3*s2]), S2Y(s->l[1 + 3*s2]), S2Z(s->l[2 + 3*s2]);
|
||||
|
||||
/* P, S1 and S2 must be colinear: (S2 - S1) X (P - S1) == 0 */
|
||||
Gecode::rel(*s, (S2Y - S1Y) * (PZ - S1Z) - (S2Z - S1Z) * (PY - S1Y) > -1 * tol);
|
||||
Gecode::rel(*s, (S2Z - S1Z) * (PX - S1X) - (S2X - S1X) * (PZ - S1Z) > -1 * tol);
|
||||
Gecode::rel(*s, (S2X - S1X) * (PY - S1Y) - (S2Y - S1Y) * (PX - S1X) > -1 * tol);
|
||||
Gecode::rel(*s, (S2Y - S1Y) * (PZ - S1Z) - (S2Z - S1Z) * (PY - S1Y) < tol);
|
||||
Gecode::rel(*s, (S2Z - S1Z) * (PX - S1X) - (S2X - S1X) * (PZ - S1Z) < tol);
|
||||
Gecode::rel(*s, (S2X - S1X) * (PY - S1Y) - (S2Y - S1Y) * (PX - S1X) < tol);
|
||||
|
||||
/* In addition to point colinearity, to check that P is between S1 and S2
|
||||
* check the dot products: */
|
||||
/* (S2 - S1) . (P - S1) >= 0 */
|
||||
/* (S2 - S1) . (P - S1) <= (S2 - S1) . (S2 - S1) */
|
||||
Gecode::rel(*s, (S2X - S1X) * (PX - S1X) + (S2Y - S1Y) * (PY - S1Y) + (S2Z - S1Z) * (PZ - S1Z) >= 0);
|
||||
Gecode::rel(*s, (S2X - S1X) * (PX - S1X) + (S2Y - S1Y) * (PY - S1Y) + (S2Z - S1Z) * (PZ - S1Z) <= (S2X - S1X) * (S2X - S1X) + (S2Y - S1Y) * (S2Y - S1Y) + (S2Z - S1Z) * (S2Z - S1Z) );
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
/* Perpendicular constraint test */
|
||||
{
|
||||
int cnt = 0;
|
||||
GeometrySolve* s = new GeometrySolve(6, -20, 20);
|
||||
Gecode::IntVar AX(s->l[0]), AY(s->l[1]), AZ(s->l[2]), BX(s->l[3]), BY(s->l[4]), BZ(s->l[5]);
|
||||
|
||||
/* Add a canned constraint */
|
||||
add_constraint_perpendicular_vect(s, 1, 0, 1);
|
||||
|
||||
/* Define some additional constraints to limit the solution set */
|
||||
Gecode::rel(*s, AX > 10);
|
||||
Gecode::rel(*s, AY == AX);
|
||||
Gecode::rel(*s, AX*AX + AY*AY + AZ*AZ == BX*BX + BY*BY + BZ*BZ);
|
||||
Gecode::branch(*s, s->l, Gecode::INT_VAR_SIZE_MIN(), Gecode::INT_VAL_MIN());
|
||||
|
||||
Gecode::DFS<GeometrySolve> e(s);
|
||||
delete s;
|
||||
while (GeometrySolve* sp = e.next()) {
|
||||
//sp->print();
|
||||
cnt++;
|
||||
/* std::cout << "in rcc_" << cnt << "_1.s rcc 0 0 0 " << sp->l[0] << " "<< sp->l[1] << " "<< sp->l[2] << " 1\n";
|
||||
std::cout << "in rcc_" << cnt << "_2.s rcc 0 0 0 " << sp->l[3] << " "<< sp->l[4] << " "<< sp->l[5] << " 1\n";
|
||||
std::cout << "g rcc_" << cnt << ".g rcc_" << cnt<< "_1.s " << "rcc_" << cnt << "_2.s\n";*/
|
||||
delete sp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Coincident point test */
|
||||
{
|
||||
GeometrySolve* s = new GeometrySolve(6, -10, 10);
|
||||
Gecode::IntVar AX(s->l[0]), AY(s->l[1]), AZ(s->l[2]), BX(s->l[3]), BY(s->l[4]), BZ(s->l[5]);
|
||||
|
||||
/* Add a canned constraint */
|
||||
add_constraint_coincident_pnt(s, 2, 0, 1);
|
||||
|
||||
/* Define some constraints to limit the solution set */
|
||||
Gecode::rel(*s, AX == BY);
|
||||
Gecode::rel(*s, AY == 2);
|
||||
Gecode::rel(*s, AX > 0);
|
||||
Gecode::rel(*s, BX > 0);
|
||||
Gecode::rel(*s, BZ > 0);
|
||||
Gecode::rel(*s, AX < 3);
|
||||
Gecode::rel(*s, BX < 5);
|
||||
Gecode::rel(*s, BZ < 6);
|
||||
Gecode::branch(*s, s->l, Gecode::INT_VAR_SIZE_MIN(), Gecode::INT_VAL_MIN());
|
||||
|
||||
Gecode::DFS<GeometrySolve> e(s);
|
||||
delete s;
|
||||
while (GeometrySolve* sp = e.next()) {
|
||||
//sp->print();
|
||||
delete sp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Point on line segment constraint test */
|
||||
{
|
||||
GeometrySolve* s = new GeometrySolve(9, 0, 1000);
|
||||
int p = 0;
|
||||
int s1 = 1;
|
||||
int s2 = 2;
|
||||
int cnt = 0;
|
||||
int maxcnt = 0;
|
||||
Gecode::IntVar PX(s->l[0 + 3*p]), PY(s->l[1 + 3*p]), PZ(s->l[2 + 3*p]);
|
||||
Gecode::IntVar S1X(s->l[0 + 3*s1]), S1Y(s->l[1 + 3*s1]), S1Z(s->l[2 + 3*s1]);
|
||||
Gecode::IntVar S2X(s->l[0 + 3*s2]), S2Y(s->l[1 + 3*s2]), S2Z(s->l[2 + 3*s2]);
|
||||
|
||||
/* Add a canned constraint */
|
||||
add_constraint_pnt_on_line_segment(s, 1, 0, 1, 2);
|
||||
|
||||
/* Define some additional constraints to pick a specific line segment */
|
||||
Gecode::rel(*s, S1X == 0);
|
||||
Gecode::rel(*s, S1Y == 0);
|
||||
Gecode::rel(*s, S1Z == 0);
|
||||
Gecode::rel(*s, S2X == 120);
|
||||
Gecode::rel(*s, S2Y == 800);
|
||||
Gecode::rel(*s, S2Z == 920);
|
||||
Gecode::branch(*s, s->l, Gecode::INT_VAR_SIZE_MIN(), Gecode::INT_VAL_MIN());
|
||||
|
||||
Gecode::DFS<GeometrySolve> e(s);
|
||||
Gecode::DFS<GeometrySolve> e2(s);
|
||||
delete s;
|
||||
while (GeometrySolve* sp = e.next()) {
|
||||
//sp->print();
|
||||
cnt++;
|
||||
std::cout << "in pnt" << cnt << ".s sph " << sp->l[0] << " " << sp->l[1] << " " << sp->l[2] << " 1\n";
|
||||
}
|
||||
maxcnt = cnt;
|
||||
cnt = 0;
|
||||
while (GeometrySolve* sp = e2.next()) {
|
||||
cnt++;
|
||||
if (cnt == 1)
|
||||
std::cout << "in line.s rcc " << sp->l[0] << " " << sp->l[1] << " " << sp->l[2];
|
||||
if (cnt == maxcnt)
|
||||
std::cout << " " << sp->l[0] << " " << sp->l[1] << " " << sp->l[2] << " 5\n";
|
||||
delete sp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C++
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "stroustrup"
|
||||
* End:
|
||||
* ex: shiftwidth=4 tabstop=8
|
||||
*/
|
||||
@@ -1,97 +0,0 @@
|
||||
/* G E C O D E _ S O L V E R _ T E S T . C P P
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 2008-2014 United States Government as represented by
|
||||
* the U.S. Army Research Laboratory.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; see the file named COPYING for more
|
||||
* information.
|
||||
*/
|
||||
/** @file gecode_solver_test.cpp
|
||||
*
|
||||
* @brief Gecode version of Simple Test cases for Constraint Solver
|
||||
*
|
||||
*/
|
||||
|
||||
/* Based on send-more-money-de-mystified.cpp
|
||||
*
|
||||
* Authors:
|
||||
* Christian Schulte <schulte@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Christian Schulte, 2008-2013
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software, to deal in the software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the software,
|
||||
* and to permit persons to whom the software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gecode/int.hh>
|
||||
#include <gecode/minimodel.hh>
|
||||
#include <gecode/search.hh>
|
||||
|
||||
class EqSolve : public Gecode::Space {
|
||||
public:
|
||||
Gecode::IntVarArray l;
|
||||
EqSolve(int v1, int v2, int v3) : l(*this, v1, v2, v3) {}
|
||||
EqSolve(bool share, EqSolve& s) : Gecode::Space(share, s) {l.update(*this, share, s.l);}
|
||||
virtual Space* copy(bool share) {return new EqSolve(share,*this);}
|
||||
void print(void) const {std::cout << l << std::endl;}
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
EqSolve* m = new EqSolve(4, 0, 10);
|
||||
|
||||
Gecode::IntVar A(m->l[0]), B(m->l[1]), C(m->l[2]), D(m->l[3]);
|
||||
|
||||
/* Define the constraints */
|
||||
|
||||
Gecode::rel(*m, A * B == 12);
|
||||
Gecode::rel(*m, B + C < 5);
|
||||
Gecode::rel(*m, A - D == 2);
|
||||
Gecode::rel(*m, A * C == 4);
|
||||
Gecode::branch(*m, m->l, Gecode::INT_VAR_SIZE_MIN(), Gecode::INT_VAL_MIN());
|
||||
|
||||
Gecode::DFS<EqSolve> e(m);
|
||||
delete m;
|
||||
while (EqSolve* s = e.next()) {
|
||||
s->print(); delete s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C++
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "stroustrup"
|
||||
* End:
|
||||
* ex: shiftwidth=4 tabstop=8
|
||||
*/
|
||||
@@ -1,40 +0,0 @@
|
||||
var -100..100: AX :: output_var;
|
||||
var -100..100: AY :: output_var;
|
||||
var -100..100: AZ :: output_var;
|
||||
var -100..100: BX :: output_var;
|
||||
var -100..100: BY :: output_var;
|
||||
var -100..100: BZ :: output_var;
|
||||
var int : AXBX;
|
||||
var int : AYBY;
|
||||
var int : AZBZ;
|
||||
var int : NAZBZ;
|
||||
var int : AXAX;
|
||||
var int : AYAY;
|
||||
var int : AXY;
|
||||
var int : AZAZ;
|
||||
var int : AXYZ;
|
||||
var int : BXBX;
|
||||
var int : BYBY;
|
||||
var int : BXY;
|
||||
var int : BZBZ;
|
||||
var int : BXYZ;
|
||||
constraint int_times(AX, BX, AXBX);
|
||||
constraint int_times(AY, BY, AYBY);
|
||||
constraint int_times(AZ, BZ, AZBZ);
|
||||
constraint int_times(AZBZ, -1, NAZBZ);
|
||||
constraint int_plus(AXBX, AYBY, NAZBZ);
|
||||
|
||||
constraint int_times(AX, AX, AXAX);
|
||||
constraint int_times(AY, AY, AYAY);
|
||||
constraint int_times(AZ, AZ, AZAZ);
|
||||
constraint int_times(BX, BX, BXBX);
|
||||
constraint int_times(BY, BY, BYBY);
|
||||
constraint int_times(BZ, BZ, BZBZ);
|
||||
constraint int_plus(AXAX, AYAY, AXY);
|
||||
constraint int_plus(AXY, AZAZ, AXYZ);
|
||||
constraint int_plus(BXBX, BYBY, BXY);
|
||||
constraint int_plus(BXY, BZBZ, BXYZ);
|
||||
constraint int_eq(AXYZ, BXYZ);
|
||||
%constraint int_eq(AX, 32);
|
||||
%solve minimize AY;
|
||||
solve satisfy;
|
||||
@@ -65,16 +65,16 @@ db5_import_attributes(struct bu_attribute_value_set *avs, const struct bu_extern
|
||||
size_t abinlen;
|
||||
cp += 2; /* We are now at the first byte of the first binary attribute... */
|
||||
while (cp != ep) {
|
||||
++bcount
|
||||
++bcount;
|
||||
cp += strlen(cp)+1; /* name */
|
||||
/* The next value is an unsigned integer of variable width
|
||||
* (a_width: DB5HDR_WIDTHCODE_x) so how do we get its
|
||||
* width? We now have a new member of struct bu_external:
|
||||
* 'unsigned char intwid'. Note that the integer
|
||||
* 'unsigned char widcode'. Note that the integer
|
||||
* is in network order and must be properly decoded for
|
||||
* the local architecture.
|
||||
*/
|
||||
cp += db5_decode_length(&abinlen, cp, ap->intwid);
|
||||
cp += db5_decode_length(&abinlen, (const unsigned char*)cp, ap->widcode);
|
||||
/* account for the abinlen bytes */
|
||||
cp += abinlen;
|
||||
}
|
||||
@@ -122,10 +122,9 @@ db5_import_attributes(struct bu_attribute_value_set *avs, const struct bu_extern
|
||||
while (cp != ep) {
|
||||
const char *name = cp; /* name */
|
||||
cp += strlen(cp)+1; /* name */
|
||||
cp += db5_decode_length(&abinlen, cp, ap->intwid);
|
||||
cp += db5_decode_length(&abinlen, (const unsigned char*)cp, ap->widcode);
|
||||
/* now decode for the abinlen bytes */
|
||||
decode_binary_attribute(const size_t len, const char *cp)
|
||||
decod
|
||||
decode_binary_attribute(abinlen, (const unsigned char*)cp);
|
||||
cp += abinlen;
|
||||
}
|
||||
/* now cp should be at the end */
|
||||
@@ -491,7 +490,7 @@ db5_fwrite_ident(FILE *fp, const char *title, double local2mm)
|
||||
|
||||
#if defined(USE_BINARY_ATTRIBUTES)
|
||||
void
|
||||
decode_binary_attribute(const size_t len, const char *cp)
|
||||
decode_binary_attribute(const size_t len, const unsigned char *cp)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -34,6 +34,10 @@ add_test(NAME rt_test_nmg_mk COMMAND test_nmg_mk)
|
||||
BRLCAD_ADDEXEC(test_nmg_copy test_nmg_copy.c "librt" NO_INSTALL)
|
||||
add_test(NAME rt_test_nmg_copy COMMAND test_nmg_copy)
|
||||
|
||||
# binary attribute testing
|
||||
BRLCAD_ADDEXEC(test_binary_attribute test_binary_attribute.c "librt" NO_INSTALL)
|
||||
add_test(NAME rt_test_binary_attribute COMMAND test_binary_attribute)
|
||||
|
||||
set(distcheck_files
|
||||
arb_intersect.g
|
||||
brep_boolean_tests.g
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* T E S T _ B I N A R Y _ A T T R I B U T E . C
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 2013-2014 United States Government as represented by
|
||||
* the U.S. Army Research Laboratory.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; see the file named COPYING for more
|
||||
* information.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
#include "bn.h"
|
||||
#include "vmath.h"
|
||||
#include "raytrace.h"
|
||||
|
||||
|
||||
int
|
||||
main(int UNUSED(argc), char **UNUSED(argv))
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* tab-width: 8
|
||||
* mode: C
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "stroustrup"
|
||||
* End:
|
||||
* ex: shiftwidth=4 tabstop=8
|
||||
*/
|
||||
+18
-17
@@ -51,6 +51,7 @@ foreach(ITEM ${dlists})
|
||||
CMAKEFILES(${dlist})
|
||||
endforeach(ITEM ${dlists})
|
||||
|
||||
#=== LIBREGEX ============================================
|
||||
# libregex library - often needed by tools, so do this one first.
|
||||
set(regex_ALIASES ENABLE_REGEX)
|
||||
set(regex_DESCRIPTION "
|
||||
@@ -94,6 +95,7 @@ if(BUILD_SHARED_LIBS AND HAVE_LIBC_REGEX AND "${BRLCAD_REGEX}" MATCHES "BUNDLED"
|
||||
set_property(DIRECTORY libregex APPEND PROPERTY COMPILE_DEFINITIONS regexec=libregex_regexec)
|
||||
set_property(DIRECTORY libregex APPEND PROPERTY COMPILE_DEFINITIONS regfree=libregex_regfree)
|
||||
endif(BUILD_SHARED_LIBS AND HAVE_LIBC_REGEX AND "${BRLCAD_REGEX}" MATCHES "BUNDLED")
|
||||
#=== END LIBREGEX ============================================
|
||||
|
||||
# Same deal for zlib Library - common requirement, deal with it up front
|
||||
set(zlib_ALIASES ENABLE_ZLIB ENABLE_LIBZ)
|
||||
@@ -741,6 +743,22 @@ if(BRLCAD_SPR_BUILD)
|
||||
SetTargetFolder(libSPR-static "Third Party Libraries")
|
||||
endif(BRLCAD_SPR_BUILD)
|
||||
|
||||
#=== LIBBSON ==================================================
|
||||
# Libbson needed for binary attributes, always use this local version
|
||||
set(libbson_ALIASES ENABLE_BSON)
|
||||
set(libbson_DESCRIPTION "
|
||||
Option for enabling and disabling compilation of the Libbson library
|
||||
provided with BRL-CAD's source code. Default is BUNDLED, using
|
||||
the included other/src version.
|
||||
")
|
||||
THIRD_PARTY(libbson BSON Libbson libbson_DESCRIPTION ALIASES
|
||||
${libbson_ALIASES} FLAGS NOSYS)
|
||||
if(BRLCAD_BSON_BUILD)
|
||||
SetTargetFolder(libBSON "Third Party Libraries")
|
||||
SetTargetFolder(libBSON-static "Third Party Libraries")
|
||||
endif(BRLCAD_BSON_BUILD)
|
||||
#=== END LIBBSON ==================================================
|
||||
|
||||
# STEPcode
|
||||
# Need Lemon/Perplex to build STEP - conditionalize
|
||||
|
||||
@@ -808,23 +826,6 @@ SetTargetFolder(stepeditor "Third Party Libraries")
|
||||
SetTargetFolder(steputils "Third Party Libraries")
|
||||
SetTargetFolder(version_string "Compilation Utilities")
|
||||
|
||||
set(gecode_ALIASES ENABLE_GECODE)
|
||||
set(gecode_DESCRIPTION "
|
||||
Option for enabling and disabling compilation of the Gecode Constraint
|
||||
Solving Libraries provided with BRL-CAD's source code. Default is AUTO,
|
||||
responsive to the toplevel BRLCAD_BUNDLED_LIBS option and testing
|
||||
first for a system version if BRLCAD_BUNDLED_LIBS is also AUTO.
|
||||
")
|
||||
set(GECODE_USE_QT OFF)
|
||||
mark_as_advanced(GECODE_USE_QT)
|
||||
THIRD_PARTY(gecode GECODE gecode gecode_DESCRIPTION REQUIRED_VARS BRLCAD_LEVEL3 ALIASES ${gecode_ALIASES})
|
||||
if(BRLCAD_GECODE_BUILD)
|
||||
set(GECODE_LIBRARIES gecodesupport gecodekernel gecodesearch gecodeint
|
||||
gecodeset gecodefloat gecodeminimodel gecodedriver gecodeflatzinc)
|
||||
set(GECODE_LIBRARIES "${GECODE_LIBRARIES}" CACHE STRING "Gecode libraries in BRL-CAD" FORCE)
|
||||
set(GECODE_INCLUDE_DIR "${BRLCAD_BINARY_DIR}/src/other/gecode;${BRLCAD_SOURCE_DIR}/src/other/gecode" CACHE STRING "Gecode headers in BRL-CAD" FORCE)
|
||||
endif(BRLCAD_GECODE_BUILD)
|
||||
|
||||
# Clipper polygon clipping library - for now, we're going to use our copy
|
||||
if(BRLCAD_LEVEL2)
|
||||
add_subdirectory(clipper)
|
||||
|
||||
@@ -11,6 +11,7 @@ xmltools http://xmlsoft.org/ Verify DocBook inputs and generate DocBook outpu
|
||||
2. Header-only libraries
|
||||
|
||||
Eigen http://eigen.tuxfamily.org Linear algebra - used by NURBS code
|
||||
boost http://www.boost.org C++ utilties - used by libpc and obj converter
|
||||
|
||||
3. Installed libraries
|
||||
|
||||
|
||||
@@ -1,416 +0,0 @@
|
||||
#
|
||||
# Main authors:
|
||||
# Victor Zverovich <victor.zverovich@gmail.com>
|
||||
#
|
||||
# Copyright:
|
||||
# Victor Zverovich, 2013
|
||||
#
|
||||
# Last modified:
|
||||
# $Date$ by $Author$
|
||||
# $Revision$
|
||||
#
|
||||
# This file is part of Gecode, the generic constraint
|
||||
# development environment:
|
||||
# http://www.gecode.org
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
#
|
||||
# CMake build script for Gecode.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
|
||||
project(GECODE)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
if (GECODE_DISABLE_WARNINGS)
|
||||
if (MSVC)
|
||||
add_definitions(/wd4244 /wd4267 /wd4345 /wd4355 /wd4800)
|
||||
else ()
|
||||
foreach (flag -Wextra -Wall -pedantic)
|
||||
string(REPLACE ${flag} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
endforeach ()
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
add_definitions(-Wno-overloaded-virtual)
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
add_definitions(-Wno-constant-logical-operand -Wno-switch)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# The following part of config.h is hard to derive from configure.ac.
|
||||
file(READ gecode/support/config.hpp.in CONFIG)
|
||||
string(REGEX REPLACE "^/\\*([^*]|\\*[^/])*\\*/" "" CONFIG ${CONFIG})
|
||||
string(REGEX MATCHALL "[^\n]*\n" CONFIG
|
||||
"${CONFIG}
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#undef SIZEOF_INT
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
")
|
||||
|
||||
# Get version numbers and parts of config.h from configure.ac.
|
||||
file(READ configure.ac LINES)
|
||||
# Replace semicolons with "<semi>" to avoid CMake messing with them.
|
||||
string(REPLACE ";" "<semi>" LINES "${LINES}")
|
||||
# Split into lines keeping newlines to avoid foreach skipping empty ones.
|
||||
string(REGEX MATCHALL "[^\n]*\n" LINES "${LINES}")
|
||||
set(ah_command FALSE)
|
||||
foreach (line "${EXTRA_CONFIG}" ${LINES})
|
||||
string(REPLACE ";" "" line "${line}")
|
||||
if (ah_command)
|
||||
# Do nothing.
|
||||
elseif (line MATCHES "AC_INIT\\(([^,]*), *([^,]*), *([^)]*)\\)")
|
||||
set(PACKAGE ${CMAKE_MATCH_1})
|
||||
set(VERSION ${CMAKE_MATCH_2})
|
||||
set(PACKAGE_BUGREPORT ${CMAKE_MATCH_3})
|
||||
message(STATUS "Got VERSION=${VERSION} from configure.ac")
|
||||
elseif (line MATCHES "ac_gecode_flatzincversion=(.*)\n")
|
||||
set(GECODE_FLATZINC_VERSION "${CMAKE_MATCH_1}")
|
||||
elseif (line MATCHES "AH_BOTTOM\\(\\[(.*)")
|
||||
set(ah_command bottom)
|
||||
set(line "${CMAKE_MATCH_1}")
|
||||
elseif (line MATCHES "AH_VERBATIM[^,]+,(.*)")
|
||||
set(ah_command verbatim)
|
||||
set(line "${CMAKE_MATCH_1}")
|
||||
endif ()
|
||||
if (ah_command)
|
||||
set(saved_ah_command ${ah_command})
|
||||
if (line MATCHES "^\\[(.*)")
|
||||
set(line "${CMAKE_MATCH_1}")
|
||||
endif ()
|
||||
if (line MATCHES "\\]\\)")
|
||||
set(ah_command FALSE)
|
||||
string(REPLACE "])" "" line "${line}")
|
||||
endif ()
|
||||
# For some reason CMake may bundle several lines together. Split them too.
|
||||
string(REGEX MATCHALL "[^\n]*\n" sublines "${line}")
|
||||
set(config_add "")
|
||||
foreach (subline ${sublines})
|
||||
set(config_add ${config_add} "${subline}")
|
||||
endforeach ()
|
||||
if (saved_ah_command STREQUAL "verbatim")
|
||||
set(CONFIG ${config_add} ${CONFIG})
|
||||
else ()
|
||||
set(CONFIG ${CONFIG} "\n" ${config_add})
|
||||
endif ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
set(PACKAGE_NAME ${PACKAGE})
|
||||
string(TOLOWER ${PACKAGE} PACKAGE_TARNAME)
|
||||
set(PACKAGE_URL "")
|
||||
set(PACKAGE_VERSION ${VERSION})
|
||||
set(${PACKAGE}_VERSION ${VERSION})
|
||||
string(REPLACE "." "-" GECODE_LIBRARY_VERSION "${VERSION}")
|
||||
set(PACKAGE_STRING "${PACKAGE} ${VERSION}")
|
||||
if (VERSION MATCHES "(.*)\\.(.*)\\.(.*)")
|
||||
math(EXPR GECODE_VERSION_NUMBER
|
||||
"${CMAKE_MATCH_1} * 100000 + ${CMAKE_MATCH_2} * 100 + ${CMAKE_MATCH_3}")
|
||||
endif ()
|
||||
|
||||
set(GECODE_DLL_USERPREFIX "")
|
||||
set(GECODE_DLL_USERSUFFIX "")
|
||||
set(GECODE_HAS_INT_VARS "/**/")
|
||||
set(GECODE_HAS_SET_VARS "/**/")
|
||||
set(GECODE_HAS_FLOAT_VARS "/**/")
|
||||
set(GECODE_STATIC_LIBS 1)
|
||||
|
||||
check_cxx_compiler_flag(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_FLAG)
|
||||
if (HAVE_VISIBILITY_HIDDEN_FLAG)
|
||||
set(GECODE_GCC_HAS_CLASS_VISIBILITY "/**/")
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
set(GECODE_THREADS_WINDOWS 1)
|
||||
else ()
|
||||
set(GECODE_THREADS_PTHREADS 1)
|
||||
endif ()
|
||||
|
||||
# Don't use Qt if GECODE_USE_QT is set to FALSE.
|
||||
if (NOT DEFINED GECODE_USE_QT OR GECODE_USE_QT)
|
||||
find_package(Qt5 QUIET COMPONENTS Core Gui Widgets PrintSupport)
|
||||
if (Qt5_FOUND)
|
||||
set(GECODE_HAS_QT "/**/")
|
||||
set(GECODE_HAS_GIST "/**/")
|
||||
set(EXTRA_LIBS gist)
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
else()
|
||||
find_package(Qt4)
|
||||
if (QT4_FOUND)
|
||||
set(GECODE_HAS_QT "/**/")
|
||||
set(GECODE_HAS_GIST "/**/")
|
||||
set(EXTRA_LIBS gist)
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
include(${QT_USE_FILE})
|
||||
endif()
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
|
||||
check_symbol_exists(mmap sys/mman.h HAVE_MMAP)
|
||||
|
||||
# Checks for header files.
|
||||
include(CheckIncludeFiles)
|
||||
foreach (header inttypes.h memory.h stdint.h stdlib.h strings.h string.h
|
||||
sys/param.h sys/stat.h sys/time.h sys/types.h unistd.h)
|
||||
string(TOUPPER HAVE_${header} var)
|
||||
string(REGEX REPLACE "\\.|/" "_" var ${var})
|
||||
check_include_files(${header} ${var})
|
||||
endforeach ()
|
||||
check_include_files(stdio.h STDC_HEADERS)
|
||||
if (HAVE_SYS_TIME_H)
|
||||
set(GECODE_USE_GETTIMEOFDAY 1)
|
||||
else ()
|
||||
set(GECODE_USE_CLOCK 1)
|
||||
endif ()
|
||||
if (HAVE_UNISTD_H)
|
||||
set(GECODE_HAS_UNISTD_H 1)
|
||||
endif ()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("
|
||||
#include <ext/hash_map>
|
||||
int main() {}" HAVE_EXT_HASH_MAP)
|
||||
if (HAVE_EXT_HASH_MAP)
|
||||
set(GECODE_HAS_GNU_HASH_MAP "/**/")
|
||||
endif ()
|
||||
|
||||
include(CheckTypeSize)
|
||||
check_type_size(int SIZEOF_INT)
|
||||
|
||||
# Check for inline.
|
||||
include(CheckCSourceCompiles)
|
||||
check_c_source_compiles("
|
||||
inline __attribute__ ((__always_inline__)) void foo(void) {}
|
||||
int main() {}" HAVE_ALWAYS_INLINE)
|
||||
set(forceinline inline)
|
||||
if (HAVE_ALWAYS_INLINE)
|
||||
set(forceinline "inline __attribute__ ((__always_inline__))")
|
||||
endif ()
|
||||
|
||||
check_c_source_compiles("
|
||||
int main() { return __builtin_ffsl(0); }" HAVE_BUILTIN_FFSL)
|
||||
if (HAVE_BUILTIN_FFSL)
|
||||
set(GECODE_HAS_BUILTIN_FFSL "/**/")
|
||||
endif ()
|
||||
|
||||
# Process config.hpp using autoconf rules.
|
||||
list(LENGTH CONFIG length)
|
||||
math(EXPR length "${length} - 1")
|
||||
foreach (i RANGE ${length})
|
||||
list(GET CONFIG ${i} line)
|
||||
if (line MATCHES "^#( *)undef (.*)\n")
|
||||
set(space "${CMAKE_MATCH_1}")
|
||||
set(var ${CMAKE_MATCH_2})
|
||||
if (NOT DEFINED ${var} OR (var MATCHES "HAVE_.*" AND NOT ${var}))
|
||||
set(line "/* #${space}undef ${var} */\n")
|
||||
else ()
|
||||
if ("${${var}}" STREQUAL "/**/" OR "${var}" STREQUAL "GECODE_VERSION_NUMBER" OR
|
||||
"${var}" STREQUAL "forceinline" OR var MATCHES "SIZEOF_.*")
|
||||
set(value ${${var}})
|
||||
elseif (NOT (var MATCHES ^HAVE OR ${var} EQUAL 0 OR ${var} EQUAL 1))
|
||||
set(value \"${${var}}\")
|
||||
elseif (${var})
|
||||
set(value 1)
|
||||
else ()
|
||||
set(value 0)
|
||||
endif ()
|
||||
set(line "#${space}define ${var} ${value}\n")
|
||||
endif ()
|
||||
endif ()
|
||||
string(REPLACE "<semi>" ";" line "${line}")
|
||||
set(CONFIG_OUT "${CONFIG_OUT}${line}")
|
||||
endforeach ()
|
||||
file(WRITE ${GECODE_BINARY_DIR}/gecode/support/config.hpp.new
|
||||
"/* gecode/support/config.hpp. Generated from config.hpp.in by configure. */
|
||||
/* gecode/support/config.hpp.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Disable autolink because all the dependencies are handled by CMake. */
|
||||
#define GECODE_BUILD_SUPPORT
|
||||
#define GECODE_BUILD_KERNEL
|
||||
#define GECODE_BUILD_SEARCH
|
||||
#define GECODE_BUILD_INT
|
||||
#define GECODE_BUILD_SET
|
||||
#define GECODE_BUILD_FLOAT
|
||||
#define GECODE_BUILD_MINIMODEL
|
||||
#define GECODE_BUILD_FLATZINC
|
||||
#define GECODE_BUILD_DRIVER
|
||||
#define GECODE_BUILD_GIST
|
||||
|
||||
${CONFIG_OUT}")
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${GECODE_BINARY_DIR}/gecode/support/config.hpp.new
|
||||
${GECODE_BINARY_DIR}/gecode/support/config.hpp)
|
||||
|
||||
if(NOT DEFINED BIN_DIR)
|
||||
set(BIN_DIR bin)
|
||||
endif(NOT DEFINED BIN_DIR)
|
||||
|
||||
if(NOT DEFINED LIB_DIR)
|
||||
set(LIB_DIR lib)
|
||||
endif(NOT DEFINED LIB_DIR)
|
||||
|
||||
# Expands a value substituting variables and appends the result to ${var}.
|
||||
function (expand var value)
|
||||
if (value MATCHES "\\$\\(([^:]+)(.*)\\)")
|
||||
# Perform substitution.
|
||||
set(pattern ${CMAKE_MATCH_2})
|
||||
set(items ${${CMAKE_MATCH_1}})
|
||||
if (pattern MATCHES ":%=([^%]*)%([^%]*)")
|
||||
set(values )
|
||||
foreach (item ${items})
|
||||
set(values ${values} ${CMAKE_MATCH_1}${item}${CMAKE_MATCH_2})
|
||||
endforeach ()
|
||||
else ()
|
||||
set(values ${items})
|
||||
endif ()
|
||||
else ()
|
||||
set(values ${value})
|
||||
endif ()
|
||||
set(${var} ${${var}} ${values} PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Parse Makefile.in extracting variables.
|
||||
file(READ Makefile.in text)
|
||||
string(REPLACE "\\\n" "" text "${text}")
|
||||
string(REGEX REPLACE "#[^\n]*\n" "" text "${text}")
|
||||
string(REGEX MATCHALL "[^\n]+" lines "${text}")
|
||||
foreach (line ${lines})
|
||||
if (line MATCHES "([^ \t]+)[ \t]*=[ \t]*(.*)")
|
||||
set(var ${CMAKE_MATCH_1})
|
||||
set(${var} )
|
||||
string(REGEX MATCHALL "[^ \t]+" items "${CMAKE_MATCH_2}")
|
||||
foreach (item ${items})
|
||||
expand(${var} ${item})
|
||||
endforeach ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
foreach (lib support kernel search int set float
|
||||
minimodel driver flatzinc ${EXTRA_LIBS})
|
||||
if (lib STREQUAL "minimodel")
|
||||
set(libupper MM)
|
||||
else ()
|
||||
string(TOUPPER ${lib} libupper)
|
||||
endif ()
|
||||
if (${libupper}SRC)
|
||||
set(sources )
|
||||
foreach (src ${${libupper}SRC} ${${libupper}_GENSRC})
|
||||
if ((src STREQUAL "gecode/support/thread/pthreads.cpp" AND MSVC) OR
|
||||
src STREQUAL "gecode/float/rounding.cpp")
|
||||
# ignore empty source files to prevent linker warnings
|
||||
else ()
|
||||
set(sources ${sources} ${src})
|
||||
endif ()
|
||||
endforeach ()
|
||||
add_library(gecode${lib} ${sources} ${${libupper}HDR})
|
||||
install(TARGETS gecode${lib}
|
||||
RUNTIME DESTINATION ${BIN_DIR}
|
||||
LIBRARY DESTINATION ${LIB_DIR}
|
||||
ARCHIVE DESTINATION ${LIB_DIR})
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
find_package(Threads)
|
||||
target_link_libraries(gecodesupport ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries(gecodekernel gecodesupport)
|
||||
target_link_libraries(gecodesearch gecodekernel)
|
||||
target_link_libraries(gecodeint gecodekernel)
|
||||
target_link_libraries(gecodeset gecodeint)
|
||||
target_link_libraries(gecodefloat gecodeint)
|
||||
target_link_libraries(gecodeminimodel gecodeint gecodeset gecodesearch)
|
||||
target_link_libraries(gecodedriver gecodeint)
|
||||
target_link_libraries(gecodeflatzinc gecodeminimodel gecodedriver)
|
||||
|
||||
if (GECODE_HAS_QT)
|
||||
if (Qt5_FOUND)
|
||||
qt5_use_modules(gecodegist Widgets Gui PrintSupport)
|
||||
else()
|
||||
target_link_libraries(gecodegist ${QT_LIBRARIES})
|
||||
target_link_libraries(gecodeflatzinc gecodegist ${QT_LIBRARIES})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (FLOATSRC)
|
||||
target_link_libraries(gecodefloat gecodekernel)
|
||||
target_link_libraries(gecodeminimodel gecodefloat)
|
||||
endif ()
|
||||
@@ -1,25 +0,0 @@
|
||||
GECODE LICENSE AGREEMENT
|
||||
|
||||
This software and its documentation are copyrighted by the
|
||||
individual authors as listed in each file. The following
|
||||
terms apply to all files associated with the software unless
|
||||
explicitly disclaimed in individual files.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,361 +0,0 @@
|
||||
dnl This file was generated by Makefile.contribs.
|
||||
dnl Do not edit! Modifications will get lost!
|
||||
dnl Edit configure.ac.in instead.
|
||||
|
||||
dnl
|
||||
dnl Main authors:
|
||||
dnl Guido Tack <tack@gecode.org>
|
||||
dnl
|
||||
dnl Copyright:
|
||||
dnl Guido Tack, 2004, 2005
|
||||
dnl
|
||||
dnl Last modified:
|
||||
dnl $Date$
|
||||
dnl by $Author$
|
||||
dnl $Revision$
|
||||
dnl
|
||||
dnl This file is part of Gecode, the generic constraint
|
||||
dnl development environment:
|
||||
dnl http://www.gecode.org
|
||||
dnl
|
||||
dnl Permission is hereby granted, free of charge, to any person obtaining
|
||||
dnl a copy of this software and associated documentation files (the
|
||||
dnl "Software"), to deal in the Software without restriction, including
|
||||
dnl without limitation the rights to use, copy, modify, merge, publish,
|
||||
dnl distribute, sublicense, and/or sell copies of the Software, and to
|
||||
dnl permit persons to whom the Software is furnished to do so, subject to
|
||||
dnl the following conditions:
|
||||
dnl
|
||||
dnl The above copyright notice and this permission notice shall be
|
||||
dnl included in all copies or substantial portions of the Software.
|
||||
dnl
|
||||
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
dnl EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
dnl NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
dnl LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
dnl OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
dnl WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
dnl
|
||||
dnl
|
||||
|
||||
AC_REVISION([$Id$])
|
||||
AC_PREREQ(2.53)
|
||||
AC_INIT(GECODE, 4.3.0, users@gecode.org)
|
||||
AC_CONFIG_HEADERS([gecode/support/config.hpp])
|
||||
AC_CONFIG_SRCDIR(gecode/kernel.hh)
|
||||
|
||||
ac_gecode_soversion=37
|
||||
AC_SUBST(GECODE_SOVERSION, ${ac_gecode_soversion})
|
||||
ac_gecode_flatzincversion=1.6
|
||||
AC_SUBST(GECODE_FLATZINC_VERSION, ${ac_gecode_flatzincversion})
|
||||
|
||||
# checks for programs
|
||||
|
||||
: ${CXXFLAGS=""} dnl we do not want autoconf's default
|
||||
: ${CFLAGS=""} dnl we do not want autoconf's default
|
||||
: ${DLLFLAGS=""} dnl we do not want autoconf's default
|
||||
: ${GLDFLAGS=""} dnl we do not want autoconf's default
|
||||
|
||||
dnl include Gecode specific macros
|
||||
m4_include([gecode.m4])
|
||||
|
||||
dnl determine the operating system
|
||||
AC_GECODE_GET_OS
|
||||
|
||||
if test "${CXX}x" = "x" -a "${CC}x" = "x" -a "${host_os}" = "windows"; then
|
||||
CC=cl
|
||||
CXX=cl
|
||||
fi
|
||||
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC
|
||||
AC_LANG(C++)
|
||||
|
||||
AC_PROG_RANLIB
|
||||
|
||||
dnl check whether we have certain programs we need
|
||||
AC_CHECK_PROG(PROG_DIFF, diff, [ok])
|
||||
if test "${PROG_DIFF}x" = "x"; then
|
||||
AC_MSG_ERROR([In order to compile Gecode, you need the diff tool.])
|
||||
fi
|
||||
AC_CHECK_PROG(PROG_TAR, tar, [ok])
|
||||
if test "${PROG_TAR}x" = "x"; then
|
||||
AC_MSG_ERROR([In order to compile Gecode, you need the tar tool.])
|
||||
fi
|
||||
AC_CHECK_PROG(PROG_MAKE, make, [ok])
|
||||
if test "${PROG_MAKE}x" = "x"; then
|
||||
AC_MSG_ERROR([In order to compile Gecode, you need the make tool.])
|
||||
fi
|
||||
AC_CHECK_PROG(PROG_SED, sed, [ok])
|
||||
if test "${PROG_SED}x" = "x"; then
|
||||
AC_MSG_ERROR([In order to compile Gecode, you need the sed tool.])
|
||||
fi
|
||||
AC_CHECK_PROG(PROG_PERL, perl, [ok])
|
||||
if test "${PROG_PERL}x" = "x"; then
|
||||
AC_MSG_ERROR([In order to compile Gecode, you need perl.])
|
||||
fi
|
||||
|
||||
dnl determine which compiler we are using
|
||||
AC_CXX_COMPILER_VENDOR(ac_gecode_compiler_vendor)
|
||||
case $ac_gecode_compiler_vendor in
|
||||
gnu)
|
||||
AC_CHECK_GCC_VERSION(4,2)
|
||||
;;
|
||||
intel)
|
||||
;;
|
||||
microsoft)
|
||||
AC_CHECK_MSVC_VERSION(1400,2005)
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_GECODE_RESOURCE
|
||||
|
||||
dnl check whether we can use GNU hash_map
|
||||
AC_CHECK_HEADER([ext/hash_map],
|
||||
[AC_DEFINE([GECODE_HAS_GNU_HASH_MAP],[],
|
||||
[Whether GNU hash_map is available])])
|
||||
|
||||
dnl check whether we want to build universal binaries on Mac OS X
|
||||
AC_GECODE_UNIVERSAL
|
||||
|
||||
dnl check whether the user wants a prefix or suffixes for the libraries
|
||||
AC_GECODE_USER_SUFFIX
|
||||
|
||||
dnl check whether we want to build a framework bundle on Mac OS X
|
||||
AC_GECODE_FRAMEWORK
|
||||
|
||||
dnl check whether we want to build static libraries
|
||||
AC_GECODE_STATICLIBS
|
||||
|
||||
dnl check whether we want to have assertions and debugging options
|
||||
AC_GECODE_DEBUG
|
||||
|
||||
dnl check whether we want to have peak heap size tracking
|
||||
AC_GECODE_PEAKHEAP
|
||||
|
||||
dnl check whether to optimize for code size
|
||||
AC_GECODE_CODESIZE
|
||||
|
||||
dnl check whether we want to have support for finding memory leaks
|
||||
AC_GECODE_LEAK_DEBUG
|
||||
|
||||
dnl check whether we want audit code in our build
|
||||
AC_GECODE_AUDIT
|
||||
|
||||
dnl check whether we want to produce code suitable for profiling
|
||||
AC_GECODE_PROFILE
|
||||
|
||||
dnl check whether we want to produce code instrumented for gcov
|
||||
AC_GECODE_GCOV
|
||||
|
||||
dnl check platform specific behaviour of arithmetic
|
||||
AC_GECODE_CHECK_ARITH
|
||||
|
||||
dnl checking for thread support
|
||||
AC_GECODE_THREADS
|
||||
|
||||
dnl checking for timer to use
|
||||
AC_GECODE_TIMER
|
||||
|
||||
case $ac_gecode_compiler_vendor in
|
||||
gnu)
|
||||
dnl general compiler flags
|
||||
AC_GECODE_UNIX_PATHS
|
||||
AC_GECODE_GCC_GENERAL_SWITCHES
|
||||
dnl check whether we want to use visibility attributes with gcc
|
||||
AC_GECODE_GCC_VISIBILITY
|
||||
|
||||
if test "${enable_debug:-no}" = "no" -a "${enable_gcov:-no}" = "no"; then
|
||||
dnl compiler flags for an optimized build
|
||||
AC_GECODE_GCC_OPTIMIZED_SWITCHES
|
||||
dnl compiler flags for optimize float computings
|
||||
dnl AC_GECODE_CHECK_COMPILERFLAG([-ffast-math])
|
||||
dnl ffast-math implies:-fno-math-errno -funsafe-math-optimizations -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fcx-limited-range
|
||||
dnl but -funsafe-math-optimizations break IEEE float comptability, so we have to avoid it
|
||||
AC_GECODE_CHECK_COMPILERFLAG([-fno-math-errno])
|
||||
AC_GECODE_CHECK_COMPILERFLAG([-ffinite-math-only])
|
||||
AC_GECODE_CHECK_COMPILERFLAG([-fno-rounding-math])
|
||||
AC_GECODE_CHECK_COMPILERFLAG([-fno-signaling-nans])
|
||||
AC_GECODE_CHECK_COMPILERFLAG([-fcx-limited-range])
|
||||
AC_GECODE_CHECK_COMPILERFLAG([-mthreads])
|
||||
else
|
||||
if test "${enable_debug:-no}" = "yes"; then
|
||||
dnl compiler flags for a debug build
|
||||
AC_GECODE_GCC_DEBUG_SWITCHES
|
||||
fi
|
||||
fi
|
||||
AC_GECODE_CHECK_COMPILERFLAG([-Qunused-arguments])
|
||||
|
||||
;;
|
||||
intel)
|
||||
dnl flags for creating dlls
|
||||
case $host_os in
|
||||
windows*)
|
||||
AC_GECODE_MSVC_SWITCHES
|
||||
;;
|
||||
*)
|
||||
dnl check whether we want to use visibility attributes with gcc
|
||||
AC_GECODE_GCC_VISIBILITY
|
||||
dnl general compiler flags
|
||||
AC_GECODE_UNIX_PATHS
|
||||
AC_GECODE_GCC_GENERAL_SWITCHES
|
||||
|
||||
if test "${enable_debug:-no}" = "no"; then
|
||||
dnl compiler flags for an optimized build
|
||||
AC_GECODE_GCC_OPTIMIZED_SWITCHES
|
||||
else
|
||||
dnl compiler flags for a debug build
|
||||
AC_GECODE_GCC_DEBUG_SWITCHES
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
microsoft)
|
||||
AC_GECODE_MSVC_SWITCHES
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR(Gecode currently only supports the GNU and Microsoft compilers.)
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl find out what parts the user wants to build
|
||||
|
||||
AC_GECODE_DOC_SWITCHES
|
||||
|
||||
dnl ------------------------------------------------------------------
|
||||
dnl Enabling of non-variable contribs
|
||||
dnl @CONTRIBS@
|
||||
|
||||
dnl ------------------------------------------------------------------
|
||||
dnl Definition of variable types
|
||||
|
||||
dnl Include contributor's vtis
|
||||
dnl @VTIS@
|
||||
|
||||
AC_GECODE_VIS
|
||||
|
||||
AC_GECODE_VTI(float,
|
||||
[float variable library (implies --enable-int-vars)],
|
||||
yes,
|
||||
[\$(top_srcdir)/gecode/float/var-imp/float.vis],
|
||||
[enable_int_vars="yes";
|
||||
AC_SUBST(LINKFLOAT,[${LINKLIBDIR}${LINKPREFIX}${FLOAT}${DLL_ARCH}${LINKSUFFIX}])
|
||||
],
|
||||
[
|
||||
AC_SUBST(LINKFLOAT,[])
|
||||
]
|
||||
)
|
||||
|
||||
AC_GECODE_VTI(set,
|
||||
[finite set library (implies --enable-int-vars)],
|
||||
yes,
|
||||
[\$(top_srcdir)/gecode/set/var-imp/set.vis],
|
||||
[enable_int_vars="yes";
|
||||
AC_SUBST(LINKSET,[${LINKLIBDIR}${LINKPREFIX}${SET}${DLL_ARCH}${LINKSUFFIX}])
|
||||
],
|
||||
[
|
||||
AC_SUBST(LINKSET,[])
|
||||
]
|
||||
)
|
||||
|
||||
AC_GECODE_VTI(int, finite domain library, yes,
|
||||
[\$(top_srcdir)/gecode/int/var-imp/int.vis \$(top_srcdir)/gecode/int/var-imp/bool.vis],
|
||||
[
|
||||
AC_SUBST(LINKINT,[${LINKLIBDIR}${LINKPREFIX}${INT}${DLL_ARCH}${LINKSUFFIX}])
|
||||
],
|
||||
[
|
||||
AC_SUBST(LINKINT,[])
|
||||
])
|
||||
|
||||
dnl End of definition of variable types
|
||||
dnl ------------------------------------------------------------------
|
||||
|
||||
AC_GECODE_MPFR
|
||||
AC_GECODE_QT
|
||||
AC_GECODE_GIST
|
||||
AC_GECODE_FLEXBISON
|
||||
AC_FUNC_MMAP
|
||||
|
||||
AC_GECODE_ENABLE_MODULE(driver, yes,
|
||||
[build script commandline driver library],
|
||||
[enable_search="yes";
|
||||
enable_int="yes";
|
||||
])
|
||||
|
||||
AC_GECODE_ENABLE_MODULE(flatzinc, yes,
|
||||
[build FlatZinc interpreter],
|
||||
[enable_search="yes";
|
||||
enable_driver="yes";
|
||||
enable_minimodel="yes";
|
||||
])
|
||||
|
||||
AC_GECODE_ENABLE_MODULE(driver, yes,
|
||||
[build script commandline driver library],
|
||||
[enable_search="yes";
|
||||
enable_int="yes";
|
||||
])
|
||||
|
||||
AC_GECODE_ENABLE_MODULE(examples, yes,
|
||||
[build examples for the enabled variable types],
|
||||
[enable_search="yes";
|
||||
enable_driver="yes";
|
||||
enable_minimodel="yes";
|
||||
])
|
||||
|
||||
AC_GECODE_ENABLE_MODULE(minimodel, yes,
|
||||
[build modeling support library for the enabled variable types])
|
||||
|
||||
AC_GECODE_ENABLE_MODULE(search, yes,
|
||||
[build search engines])
|
||||
|
||||
dnl Configure contributions
|
||||
AC_CONFIG_SUBDIRS()
|
||||
dnl @SUBDIRS@
|
||||
|
||||
AC_SUBST(VERSION, ${PACKAGE_VERSION})
|
||||
AC_SUBST(DLLFLAGS, ${DLLFLAGS})
|
||||
AC_SUBST(GLDFLAGS, ${GLDFLAGS})
|
||||
AC_SUBST(ALLVIS, ${ac_gecode_vis})
|
||||
|
||||
VERSION_DASHES=`echo $PACKAGE_VERSION | sed -e s/\\\\./-/g`
|
||||
|
||||
PACKAGE_VERSION_NUMBER=`echo $PACKAGE_VERSION | awk -F. '{print $1 * 100000 + $2 * 100 + $3}'`
|
||||
|
||||
AC_DEFINE_UNQUOTED(GECODE_VERSION,
|
||||
"${PACKAGE_VERSION}",
|
||||
[Gecode version])
|
||||
AC_DEFINE_UNQUOTED(GECODE_LIBRARY_VERSION,
|
||||
"${VERSION_DASHES}",
|
||||
[Gecode version])
|
||||
AC_DEFINE_UNQUOTED(GECODE_VERSION_NUMBER,
|
||||
${PACKAGE_VERSION_NUMBER},
|
||||
[Gecode version])
|
||||
|
||||
AC_DEFINE_UNQUOTED(GECODE_FLATZINC_VERSION,
|
||||
"${GECODE_FLATZINC_VERSION}",
|
||||
[Supported version of FlatZinc]
|
||||
)
|
||||
|
||||
ac_gecode_library_architecture=-${VERSION_DASHES}${ac_gecode_library_architecture}
|
||||
if test "$ac_gecode_compiler_vendor" == "microsoft" \
|
||||
-o \( "$ac_gecode_compiler_vendor" == "intel" \
|
||||
-a "$host_os" == "windows" \) ; then
|
||||
AC_SUBST(DLL_ARCH,[${ac_gecode_library_architecture}])
|
||||
else
|
||||
AC_SUBST(DLL_ARCH,[""])
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
if test "${host_os}" = "windows"; then
|
||||
AC_SUBST(BATCHFILE, ".bat")
|
||||
AC_CONFIG_FILES([tools/flatzinc/mzn-gecode.bat:tools/flatzinc/mzn-gecode.bat.in],[chmod +x tools/flatzinc/mzn-gecode.bat])
|
||||
else
|
||||
AC_SUBST(BATCHFILE, "")
|
||||
AC_CONFIG_FILES([tools/flatzinc/mzn-gecode:tools/flatzinc/mzn-gecode.in],[chmod +x tools/flatzinc/mzn-gecode])
|
||||
fi
|
||||
AC_CONFIG_FILES([doxygen.conf:doxygen/doxygen.conf.in])
|
||||
AC_CONFIG_FILES([doxygen.hh:doxygen/doxygen.hh.in])
|
||||
AC_OUTPUT
|
||||
@@ -1,709 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Christian Schulte <schulte@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Christian Schulte, 2009
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GECODE_DRIVER_HH__
|
||||
#define __GECODE_DRIVER_HH__
|
||||
|
||||
#include <gecode/minimodel.hh>
|
||||
#include <gecode/search.hh>
|
||||
#ifdef GECODE_HAS_GIST
|
||||
#include <gecode/gist.hh>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Configure linking
|
||||
*
|
||||
*/
|
||||
#if !defined(GECODE_STATIC_LIBS) && \
|
||||
(defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
|
||||
|
||||
#ifdef GECODE_BUILD_DRIVER
|
||||
#define GECODE_DRIVER_EXPORT __declspec( dllexport )
|
||||
#else
|
||||
#define GECODE_DRIVER_EXPORT __declspec( dllimport )
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
|
||||
#define GECODE_DRIVER_EXPORT __attribute__ ((visibility("default")))
|
||||
#else
|
||||
#define GECODE_DRIVER_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Configure auto-linking
|
||||
#ifndef GECODE_BUILD_DRIVER
|
||||
#define GECODE_LIBRARY_NAME "Driver"
|
||||
#include <gecode/support/auto-link.hpp>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \namespace Gecode::Driver
|
||||
* \brief Script commandline driver
|
||||
*
|
||||
* The Gecode::Driver namespace contains support for passing common
|
||||
* commandline options and for scripts that use the commandline
|
||||
* options.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Gecode {
|
||||
|
||||
|
||||
/**
|
||||
* \defgroup TaskDriverCmd Commandline options for running scripts
|
||||
* \ingroup TaskDriver
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Different modes for executing scripts
|
||||
* \ingroup TaskDriverCmd
|
||||
*/
|
||||
enum ScriptMode {
|
||||
SM_SOLUTION, ///< Print solution and some statistics
|
||||
SM_TIME, ///< Measure average runtime
|
||||
SM_STAT, ///< Print statistics for script
|
||||
SM_GIST ///< Run script in Gist
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Different modes for restart-based search
|
||||
* \ingroup TaskDriverCmd
|
||||
*/
|
||||
enum RestartMode {
|
||||
RM_NONE, ///< No restarts
|
||||
RM_CONSTANT, ///< Restart with constant sequence
|
||||
RM_LINEAR, ///< Restart with linear sequence
|
||||
RM_LUBY, ///< Restart with Luby sequence
|
||||
RM_GEOMETRIC ///< Restart with geometric sequence
|
||||
};
|
||||
|
||||
class BaseOptions;
|
||||
|
||||
namespace Driver {
|
||||
/**
|
||||
* \brief Base class for options
|
||||
*
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT BaseOption {
|
||||
friend class Gecode::BaseOptions;
|
||||
protected:
|
||||
const char* opt; ///< String for option (including hyphen)
|
||||
const char* exp; ///< Short explanation
|
||||
BaseOption* next; ///< Next option
|
||||
/// Check for option and return its argument
|
||||
char* argument(int argc, char* argv[]) const;
|
||||
public:
|
||||
/// Initialize for option \a o and explanation \a e
|
||||
BaseOption(const char* o, const char* e);
|
||||
/// Parse option at first position and return number of parsed arguments
|
||||
virtual int parse(int argc, char* argv[]) = 0;
|
||||
/// Print help text
|
||||
virtual void help(void) = 0;
|
||||
/// Destructor
|
||||
virtual ~BaseOption(void);
|
||||
/// Create heap-allocated copy of string \a s
|
||||
static char* strdup(const char* s);
|
||||
/// Delete heap-allocated copy of string \a s
|
||||
static void strdel(const char* s);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief String-valued option
|
||||
*
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT StringValueOption : public BaseOption {
|
||||
protected:
|
||||
const char* cur; ///< Current value
|
||||
public:
|
||||
/// Initialize for option \a o and explanation \a e and default value \a v
|
||||
StringValueOption(const char* o, const char* e, const char* v=NULL);
|
||||
/// Set default value to \a v
|
||||
void value(const char* v);
|
||||
/// Return current option value
|
||||
const char* value(void) const;
|
||||
/// Parse option at first position and return number of parsed arguments
|
||||
virtual int parse(int argc, char* argv[]);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
/// Destructor
|
||||
virtual ~StringValueOption(void);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief String-valued option (integer value defined by strings)
|
||||
*
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT StringOption : public BaseOption {
|
||||
protected:
|
||||
/// Option value
|
||||
class Value {
|
||||
public:
|
||||
int val; ///< Value for an option value
|
||||
const char* opt; ///< String for option value
|
||||
const char* help; ///< Optional help text
|
||||
Value* next; ///< Next option value
|
||||
};
|
||||
int cur; ///< Current value
|
||||
Value* fst; ///< First option value
|
||||
Value* lst; ///< Last option value
|
||||
public:
|
||||
/// Initialize for option \a o and explanation \a e and default value \a v
|
||||
StringOption(const char* o, const char* e, int v=0);
|
||||
/// Set default value to \a v
|
||||
void value(int v);
|
||||
/// Return current option value
|
||||
int value(void) const;
|
||||
/// Add option value for value \a v, string \a o, and help text \a h
|
||||
void add(int v, const char* o, const char* h = NULL);
|
||||
/// Parse option at first position and return number of parsed arguments
|
||||
virtual int parse(int argc, char* argv[]);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
/// Destructor
|
||||
virtual ~StringOption(void);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Integer option
|
||||
*
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT IntOption : public BaseOption {
|
||||
protected:
|
||||
int cur; ///< Current value
|
||||
public:
|
||||
/// Initialize for option \a o and explanation \a e and default value \a v
|
||||
IntOption(const char* o, const char* e, int v=0);
|
||||
/// Set default value to \a v
|
||||
void value(int v);
|
||||
/// Return current option value
|
||||
int value(void) const;
|
||||
/// Parse option at first position and return number of parsed arguments
|
||||
virtual int parse(int argc, char* argv[]);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Unsigned integer option
|
||||
*
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT UnsignedIntOption : public BaseOption {
|
||||
protected:
|
||||
unsigned int cur; ///< Current value
|
||||
public:
|
||||
/// Initialize for option \a o and explanation \a e and default value \a v
|
||||
UnsignedIntOption(const char* o, const char* e, unsigned int v=0);
|
||||
/// Set default value to \a v
|
||||
void value(unsigned int v);
|
||||
/// Return current option value
|
||||
unsigned int value(void) const;
|
||||
/// Parse option at first position and return number of parsed arguments
|
||||
virtual int parse(int argc, char* argv[]);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Double option
|
||||
*
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT DoubleOption : public BaseOption {
|
||||
protected:
|
||||
double cur; ///< Current value
|
||||
public:
|
||||
/// Initialize for option \a o and explanation \a e and default value \a v
|
||||
DoubleOption(const char* o, const char* e, double v=0);
|
||||
/// Set default value to \a v
|
||||
void value(double v);
|
||||
/// Return current option value
|
||||
double value(void) const;
|
||||
/// Parse option at first position and return number of parsed arguments
|
||||
virtual int parse(int argc, char* argv[]);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Boolean option
|
||||
*
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT BoolOption : public BaseOption {
|
||||
protected:
|
||||
bool cur; ///< Current value
|
||||
public:
|
||||
/// Initialize for option \a o and explanation \a e and default value \a v
|
||||
BoolOption(const char* o, const char* e, bool v=false);
|
||||
/// Set default value to \a v
|
||||
void value(bool v);
|
||||
/// Return current option value
|
||||
bool value(void) const;
|
||||
/// Parse option at first position and return number of parsed arguments
|
||||
virtual int parse(int argc, char* argv[]);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Base class for script options
|
||||
* \ingroup TaskDriverCmd
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT BaseOptions {
|
||||
protected:
|
||||
Driver::BaseOption* fst; ///< First registered option
|
||||
Driver::BaseOption* lst; ///< Last registered option
|
||||
const char* _name; ///< Script name
|
||||
public:
|
||||
/// Initialize options for script with name \a s
|
||||
BaseOptions(const char* s);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
|
||||
/// Add new option \a o
|
||||
void add(Driver::BaseOption& o);
|
||||
/**
|
||||
* \brief Parse options from arguments \a argv (number is \a argc)
|
||||
*
|
||||
* The options are parsed from position one onwards until no more options
|
||||
* are detected. After parsing, the parsed arguments have been removed.
|
||||
*
|
||||
*/
|
||||
void parse(int& argc, char* argv[]);
|
||||
|
||||
/// Return name of script
|
||||
const char* name(void) const;
|
||||
/// Set name of script
|
||||
void name(const char*);
|
||||
|
||||
/// Destructor
|
||||
virtual ~BaseOptions(void);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief %Options for scripts
|
||||
* \ingroup TaskDriverCmd
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT Options : public BaseOptions {
|
||||
protected:
|
||||
/// \name Model options
|
||||
//@{
|
||||
Driver::StringOption _model; ///< General model options
|
||||
Driver::StringOption _symmetry; ///< General symmetry options
|
||||
Driver::StringOption _propagation; ///< Propagation options
|
||||
Driver::StringOption _icl; ///< Integer consistency level
|
||||
Driver::StringOption _branching; ///< Branching options
|
||||
Driver::DoubleOption _decay; ///< Decay option
|
||||
//@}
|
||||
|
||||
/// \name Search options
|
||||
//@{
|
||||
Driver::StringOption _search; ///< Search options
|
||||
Driver::UnsignedIntOption _solutions; ///< How many solutions
|
||||
Driver::DoubleOption _threads; ///< How many threads to use
|
||||
Driver::UnsignedIntOption _c_d; ///< Copy recomputation distance
|
||||
Driver::UnsignedIntOption _a_d; ///< Adaptive recomputation distance
|
||||
Driver::UnsignedIntOption _node; ///< Cutoff for number of nodes
|
||||
Driver::UnsignedIntOption _fail; ///< Cutoff for number of failures
|
||||
Driver::UnsignedIntOption _time; ///< Cutoff for time
|
||||
Driver::StringOption _restart; ///< Restart method option
|
||||
Driver::DoubleOption _r_base; ///< Restart base
|
||||
Driver::UnsignedIntOption _r_scale; ///< Restart scale factor
|
||||
Driver::BoolOption _nogoods; ///< Whether to use no-goods
|
||||
Driver::UnsignedIntOption _nogoods_limit; ///< Limit for no-good extraction
|
||||
Driver::BoolOption _interrupt; ///< Whether to catch SIGINT
|
||||
//@}
|
||||
|
||||
/// \name Execution options
|
||||
//@{
|
||||
Driver::StringOption _mode; ///< Script mode to run
|
||||
Driver::UnsignedIntOption _samples; ///< How many samples
|
||||
Driver::UnsignedIntOption _iterations; ///< How many iterations per sample
|
||||
Driver::BoolOption _print_last; ///< Print only last solution found
|
||||
Driver::StringValueOption _out_file; ///< Where to print solutions
|
||||
Driver::StringValueOption _log_file; ///< Where to print statistics
|
||||
//@}
|
||||
|
||||
public:
|
||||
/// Initialize options for script with name \a s
|
||||
Options(const char* s);
|
||||
|
||||
/// \name Model options
|
||||
//@{
|
||||
/// Set default model value
|
||||
void model(int v);
|
||||
/// Add model option value for value \a v, string \a o, and help \a h
|
||||
void model(int v, const char* o, const char* h = NULL);
|
||||
/// Return model value
|
||||
int model(void) const;
|
||||
|
||||
/// Set default symmetry value
|
||||
void symmetry(int v);
|
||||
/// Add symmetry option value for value \a v, string \a o, and help \a h
|
||||
void symmetry(int v, const char* o, const char* h = NULL);
|
||||
/// Return symmetry value
|
||||
int symmetry(void) const;
|
||||
|
||||
/// Set default propagation value
|
||||
void propagation(int v);
|
||||
/// Add propagation option value for value \a v, string \a o, and help \a h
|
||||
void propagation(int v, const char* o, const char* h = NULL);
|
||||
/// Return propagation value
|
||||
int propagation(void) const;
|
||||
|
||||
/// Set default integer consistency level
|
||||
void icl(IntConLevel i);
|
||||
/// Return integer consistency level
|
||||
IntConLevel icl(void) const;
|
||||
|
||||
/// Set default branching value
|
||||
void branching(int v);
|
||||
/// Add branching option value for value \a v, string \a o, and help \a h
|
||||
void branching(int v, const char* o, const char* h = NULL);
|
||||
/// Return branching value
|
||||
int branching(void) const;
|
||||
|
||||
/// Set default decay factor
|
||||
void decay(double d);
|
||||
/// Return decay factor
|
||||
double decay(void) const;
|
||||
//@}
|
||||
|
||||
/// \name Search options
|
||||
//@{
|
||||
/// Set default search value
|
||||
void search(int v);
|
||||
/// Add search option value for value \a v, string \a o, and help \a h
|
||||
void search(int v, const char* o, const char* h = NULL);
|
||||
/// Return search value
|
||||
int search(void) const;
|
||||
|
||||
/// Set default number of solutions to search for
|
||||
void solutions(unsigned int n);
|
||||
/// Return number of solutions to search for
|
||||
unsigned int solutions(void) const;
|
||||
|
||||
/// Set number of parallel threads
|
||||
void threads(double n);
|
||||
/// Return number of parallel threads
|
||||
double threads(void) const;
|
||||
|
||||
/// Set default copy recomputation distance
|
||||
void c_d(unsigned int d);
|
||||
/// Return copy recomputation distance
|
||||
unsigned int c_d(void) const;
|
||||
|
||||
/// Set default adaptive recomputation distance
|
||||
void a_d(unsigned int d);
|
||||
/// Return adaptive recomputation distance
|
||||
unsigned int a_d(void) const;
|
||||
|
||||
/// Set default node cutoff
|
||||
void node(unsigned int n);
|
||||
/// Return node cutoff
|
||||
unsigned int node(void) const;
|
||||
|
||||
/// Set default failure cutoff
|
||||
void fail(unsigned int n);
|
||||
/// Return failure cutoff
|
||||
unsigned int fail(void) const;
|
||||
|
||||
/// Set default time cutoff
|
||||
void time(unsigned int t);
|
||||
/// Return time cutoff
|
||||
unsigned int time(void) const;
|
||||
|
||||
/// Set default restart mode
|
||||
void restart(RestartMode r);
|
||||
/// Return restart mode
|
||||
RestartMode restart(void) const;
|
||||
|
||||
/// Set default restart base
|
||||
void restart_base(double base);
|
||||
/// Return restart base
|
||||
double restart_base(void) const;
|
||||
|
||||
/// Set default restart scale factor
|
||||
void restart_scale(unsigned int scale);
|
||||
/// Return restart scale factor
|
||||
unsigned int restart_scale(void) const;
|
||||
|
||||
/// Set default nogoods posting behavior
|
||||
void nogoods(bool b);
|
||||
/// Return whether nogoods are used
|
||||
bool nogoods(void) const;
|
||||
|
||||
/// Set default nogoods depth limit
|
||||
void nogoods_limit(unsigned int l);
|
||||
/// Return depth limit for nogoods
|
||||
unsigned int nogoods_limit(void) const;
|
||||
|
||||
/// Set default interrupt behavior
|
||||
void interrupt(bool b);
|
||||
/// Return interrupt behavior
|
||||
bool interrupt(void) const;
|
||||
//@}
|
||||
|
||||
/// \name Execution options
|
||||
//@{
|
||||
/// Set default mode
|
||||
void mode(ScriptMode em);
|
||||
/// Return mode
|
||||
ScriptMode mode(void) const;
|
||||
|
||||
/// Set default number of samples
|
||||
void samples(unsigned int s);
|
||||
/// Return number of samples
|
||||
unsigned int samples(void) const;
|
||||
|
||||
/// Set default number of iterations
|
||||
void iterations(unsigned int i);
|
||||
/// Return number of iterations
|
||||
unsigned int iterations(void) const;
|
||||
|
||||
/// Set whether to print only last solution found
|
||||
void print_last(bool p);
|
||||
/// Return whether to print only last solution found
|
||||
bool print_last(void) const;
|
||||
|
||||
/// Set default output file name for solutions
|
||||
void out_file(const char* f);
|
||||
/// Get file name for solutions
|
||||
const char* out_file(void) const;
|
||||
|
||||
/// Set default output file name for Gecode stats
|
||||
void log_file(const char* f);
|
||||
/// Get file name for Gecode stats
|
||||
const char* log_file(void) const;
|
||||
//@}
|
||||
|
||||
#ifdef GECODE_HAS_GIST
|
||||
/// Helper class storing Gist inspectors
|
||||
class _I {
|
||||
private:
|
||||
/// The double click inspectors
|
||||
Support::DynamicArray<Gist::Inspector*,Heap> _click;
|
||||
/// Number of double click inspectors
|
||||
unsigned int n_click;
|
||||
/// The solution inspectors
|
||||
Support::DynamicArray<Gist::Inspector*,Heap> _solution;
|
||||
/// Number of solution inspectors
|
||||
unsigned int n_solution;
|
||||
/// The move inspectors
|
||||
Support::DynamicArray<Gist::Inspector*,Heap> _move;
|
||||
/// Number of move inspectors
|
||||
unsigned int n_move;
|
||||
/// The comparators
|
||||
Support::DynamicArray<Gist::Comparator*,Heap> _compare;
|
||||
/// Number of comparators
|
||||
unsigned int n_compare;
|
||||
public:
|
||||
/// Constructor
|
||||
_I(void);
|
||||
/// Add inspector that reacts on node double clicks
|
||||
void click(Gist::Inspector* i);
|
||||
/// Add inspector that reacts on each new solution that is found
|
||||
void solution(Gist::Inspector* i);
|
||||
/// Add inspector that reacts on each move of the cursor
|
||||
void move(Gist::Inspector* i);
|
||||
/// Add comparator
|
||||
void compare(Gist::Comparator* i);
|
||||
|
||||
/// Return click inspector number \a i, or NULL if it does not exist
|
||||
Gist::Inspector* click(unsigned int i) const;
|
||||
/// Return solution inspector number \a i, or NULL if it does not exist
|
||||
Gist::Inspector* solution(unsigned int i) const;
|
||||
/// Return move inspector number \a i, or NULL if it does not exist
|
||||
Gist::Inspector* move(unsigned int i) const;
|
||||
/// Return comparator number \a i, or NULL if it does not exist
|
||||
Gist::Comparator* compare(unsigned int i) const;
|
||||
} inspect;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief %Options for scripts with additional size parameter
|
||||
* \ingroup TaskDriverCmd
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT SizeOptions : public Options {
|
||||
protected:
|
||||
unsigned int _size; ///< Size value
|
||||
public:
|
||||
/// Initialize options for script with name \a s
|
||||
SizeOptions(const char* s);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
/// Parse options from arguments \a argv (number is \a argc)
|
||||
void parse(int& argc, char* argv[]);
|
||||
|
||||
/// Set default size
|
||||
void size(unsigned int s);
|
||||
/// Return size
|
||||
unsigned int size(void) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief %Options for scripts with additional instance parameter
|
||||
* \ingroup TaskDriverCmd
|
||||
*/
|
||||
class GECODE_DRIVER_EXPORT InstanceOptions : public Options {
|
||||
protected:
|
||||
const char* _inst; ///< Instance string
|
||||
public:
|
||||
/// Initialize options for script with name \a s
|
||||
InstanceOptions(const char* s);
|
||||
/// Print help text
|
||||
virtual void help(void);
|
||||
/// Parse options from arguments \a argv (number is \a argc)
|
||||
void parse(int& argc, char* argv[]);
|
||||
|
||||
/// Set default instance name
|
||||
void instance(const char* s);
|
||||
/// Return instance name
|
||||
const char* instance(void) const;
|
||||
/// Destructor
|
||||
~InstanceOptions(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#include <gecode/driver/options.hpp>
|
||||
|
||||
namespace Gecode {
|
||||
|
||||
namespace Driver {
|
||||
/**
|
||||
* \brief Parametric base-class for scripts
|
||||
*
|
||||
* All scripts must inherit from this class
|
||||
* - adds printing and comparison for Gist to scripts
|
||||
* - run allows to execute scripts
|
||||
*/
|
||||
template<class BaseSpace>
|
||||
class ScriptBase : public BaseSpace {
|
||||
public:
|
||||
/// Default constructor
|
||||
ScriptBase(void) {}
|
||||
/// Constructor used for cloning
|
||||
ScriptBase(bool share, ScriptBase& e)
|
||||
: BaseSpace(share,e) {}
|
||||
/// Print a solution to \a os
|
||||
virtual void print(std::ostream& os) const { (void) os; }
|
||||
/// Compare with \a s
|
||||
virtual void compare(const Space&, std::ostream& os) const {
|
||||
(void) os;
|
||||
}
|
||||
/// Choose output stream according to \a name
|
||||
static std::ostream& select_ostream(const char* name, std::ofstream& ofs);
|
||||
/** Run script with search engine \a Engine and options \a opt
|
||||
*
|
||||
* In the solution and stat modes, search can be aborted by sending
|
||||
* SIGINT to the process (i.e., pressing Ctrl-C on the command
|
||||
* line).
|
||||
*
|
||||
* In case \a s is different from NULL, the search engine uses
|
||||
* \a s as root of the search tree.
|
||||
*/
|
||||
template<class Script, template<class> class Engine, class Options>
|
||||
static void run(const Options& opt, Script* s=NULL);
|
||||
private:
|
||||
template<class Script, template<class> class Engine, class Options,
|
||||
template<template<class> class,class> class Meta>
|
||||
static void runMeta(const Options& opt, Script* s);
|
||||
/// Catch wrong definitions of copy constructor
|
||||
explicit ScriptBase(ScriptBase& e);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* \defgroup TaskDriverScript Script classes
|
||||
* \ingroup TaskDriver
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Base-class for scripts
|
||||
* \ingroup TaskDriverScript
|
||||
*/
|
||||
typedef Driver::ScriptBase<Space> Script;
|
||||
/**
|
||||
* \brief Base-class for scripts for finding solution of lowest integer cost
|
||||
* \ingroup TaskDriverScript
|
||||
*/
|
||||
typedef Driver::ScriptBase<MinimizeSpace> MinimizeScript;
|
||||
/**
|
||||
* \brief Base-class for scripts for finding solution of highest integer cost
|
||||
* \ingroup TaskDriverScript
|
||||
*/
|
||||
typedef Driver::ScriptBase<MaximizeSpace> MaximizeScript;
|
||||
/**
|
||||
* \brief Base-class for scripts for finding solution of lowest integer cost
|
||||
* \ingroup TaskDriverScript
|
||||
*/
|
||||
typedef Driver::ScriptBase<IntMinimizeSpace> IntMinimizeScript;
|
||||
/**
|
||||
* \brief Base-class for scripts for finding solution of highest integer cost
|
||||
* \ingroup TaskDriverScript
|
||||
*/
|
||||
typedef Driver::ScriptBase<IntMaximizeSpace> IntMaximizeScript;
|
||||
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
|
||||
/**
|
||||
* \brief Base-class for scripts for finding solution of lowest float cost
|
||||
* \ingroup TaskDriverScript
|
||||
*/
|
||||
typedef Driver::ScriptBase<FloatMinimizeSpace> FloatMinimizeScript;
|
||||
/**
|
||||
* \brief Base-class for scripts for finding solution of highest float cost
|
||||
* \ingroup TaskDriverScript
|
||||
*/
|
||||
typedef Driver::ScriptBase<FloatMaximizeSpace> FloatMaximizeScript;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#include <gecode/driver/script.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
// STATISTICS: driver-any
|
||||
@@ -1,474 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Christian Schulte <schulte@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Christian Schulte, 2004
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gecode/driver.hh>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace Gecode {
|
||||
|
||||
namespace Driver {
|
||||
|
||||
/*
|
||||
* Option baseclass
|
||||
*
|
||||
*/
|
||||
char*
|
||||
BaseOption::strdup(const char* s) {
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
char* d = heap.alloc<char>(static_cast<unsigned long int>(strlen(s)+1));
|
||||
(void) strcpy(d,s);
|
||||
return d;
|
||||
}
|
||||
|
||||
void
|
||||
BaseOption::strdel(const char* s) {
|
||||
if (s == NULL)
|
||||
return;
|
||||
heap.rfree(const_cast<char*>(s));
|
||||
}
|
||||
|
||||
char*
|
||||
BaseOption::argument(int argc, char* argv[]) const {
|
||||
if ((argc < 2) || strcmp(argv[1],opt))
|
||||
return NULL;
|
||||
if (argc == 2) {
|
||||
std::cerr << "Missing argument for option \"" << opt << "\""
|
||||
<< std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return argv[2];
|
||||
}
|
||||
|
||||
BaseOption::BaseOption(const char* o, const char* e)
|
||||
: opt(strdup(o)), exp(strdup(e)) {}
|
||||
|
||||
BaseOption::~BaseOption(void) {
|
||||
strdel(opt);
|
||||
strdel(exp);
|
||||
}
|
||||
|
||||
|
||||
StringValueOption::StringValueOption(const char* o, const char* e,
|
||||
const char* v)
|
||||
: BaseOption(o,e), cur(strdup(v)) {}
|
||||
void
|
||||
StringValueOption::value(const char* v) {
|
||||
strdel(cur);
|
||||
cur = strdup(v);
|
||||
}
|
||||
int
|
||||
StringValueOption::parse(int argc, char* argv[]) {
|
||||
if (char* a = argument(argc,argv)) {
|
||||
cur = strdup(a);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void
|
||||
StringValueOption::help(void) {
|
||||
std::cerr << '\t' << opt << " (string) default: "
|
||||
<< ((cur == NULL) ? "NONE" : cur) << std::endl
|
||||
<< "\t\t" << exp << std::endl;
|
||||
}
|
||||
StringValueOption::~StringValueOption(void) {
|
||||
strdel(cur);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
StringOption::add(int v, const char* o, const char* h) {
|
||||
Value* n = new Value;
|
||||
n->val = v;
|
||||
n->opt = strdup(o);
|
||||
n->help = strdup(h);
|
||||
n->next = NULL;
|
||||
if (fst == NULL) {
|
||||
fst = n;
|
||||
} else {
|
||||
lst->next = n;
|
||||
}
|
||||
lst = n;
|
||||
}
|
||||
int
|
||||
StringOption::parse(int argc, char* argv[]) {
|
||||
if (char* a = argument(argc,argv)) {
|
||||
for (Value* v = fst; v != NULL; v = v->next)
|
||||
if (!strcmp(a,v->opt)) {
|
||||
cur = v->val;
|
||||
return 2;
|
||||
}
|
||||
std::cerr << "Wrong argument \"" << a
|
||||
<< "\" for option \"" << opt << "\""
|
||||
<< std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void
|
||||
StringOption::help(void) {
|
||||
if (fst == NULL)
|
||||
return;
|
||||
std::cerr << '\t' << opt << " (";
|
||||
const char* d = NULL;
|
||||
for (Value* v = fst; v != NULL; v = v->next) {
|
||||
std::cerr << v->opt << ((v->next != NULL) ? ", " : "");
|
||||
if (v->val == cur)
|
||||
d = v->opt;
|
||||
}
|
||||
std::cerr << ")";
|
||||
if (d != NULL)
|
||||
std::cerr << " default: " << d;
|
||||
std::cerr << std::endl << "\t\t" << exp << std::endl;
|
||||
for (Value* v = fst; v != NULL; v = v->next)
|
||||
if (v->help != NULL)
|
||||
std::cerr << "\t\t " << v->opt << ": " << v->help << std::endl;
|
||||
}
|
||||
|
||||
StringOption::~StringOption(void) {
|
||||
Value* v = fst;
|
||||
while (v != NULL) {
|
||||
strdel(v->opt);
|
||||
strdel(v->help);
|
||||
Value* n = v->next;
|
||||
delete v;
|
||||
v = n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
IntOption::parse(int argc, char* argv[]) {
|
||||
if (char* a = argument(argc,argv)) {
|
||||
cur = atoi(a);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
IntOption::help(void) {
|
||||
std::cerr << '\t' << opt << " (int) default: " << cur << std::endl
|
||||
<< "\t\t" << exp << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
UnsignedIntOption::parse(int argc, char* argv[]) {
|
||||
if (char* a = argument(argc,argv)) {
|
||||
cur = static_cast<unsigned int>(atoi(a));
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
UnsignedIntOption::help(void) {
|
||||
std::cerr << '\t' << opt << " (unsigned int) default: "
|
||||
<< cur << std::endl
|
||||
<< "\t\t" << exp << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DoubleOption::parse(int argc, char* argv[]) {
|
||||
if (char* a = argument(argc,argv)) {
|
||||
cur = atof(a);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
DoubleOption::help(void) {
|
||||
using namespace std;
|
||||
cerr << '\t' << opt << " (double) default: " << cur << endl
|
||||
<< "\t\t" << exp << endl;
|
||||
}
|
||||
|
||||
int
|
||||
BoolOption::parse(int argc, char* argv[]) {
|
||||
if ((argc < 2) || strcmp(argv[1],opt))
|
||||
return 0;
|
||||
if (argc == 2) {
|
||||
// Option without argument
|
||||
cur = true;
|
||||
return 1;
|
||||
} else if (!strcmp(argv[2],"true") || !strcmp(argv[2],"1")) {
|
||||
cur = true;
|
||||
return 2;
|
||||
} else if (!strcmp(argv[2],"false") || !strcmp(argv[2],"0")) {
|
||||
cur = false;
|
||||
return 2;
|
||||
} else {
|
||||
// Option without argument
|
||||
cur = true;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
BoolOption::help(void) {
|
||||
using namespace std;
|
||||
cerr << '\t' << opt << " (optional: false, 0, true, 1) default: "
|
||||
<< (cur ? "true" : "false") << endl
|
||||
<< "\t\t" << exp << endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
BaseOptions::add(Driver::BaseOption& o) {
|
||||
o.next = NULL;
|
||||
if (fst == NULL) {
|
||||
fst=&o;
|
||||
} else {
|
||||
lst->next=&o;
|
||||
}
|
||||
lst=&o;
|
||||
}
|
||||
BaseOptions::BaseOptions(const char* n)
|
||||
: fst(NULL), lst(NULL),
|
||||
_name(Driver::BaseOption::strdup(n)) {}
|
||||
|
||||
void
|
||||
BaseOptions::name(const char* n) {
|
||||
Driver::BaseOption::strdel(_name);
|
||||
_name = Driver::BaseOption::strdup(n);
|
||||
}
|
||||
|
||||
void
|
||||
BaseOptions::help(void) {
|
||||
std::cerr << "Gecode configuration information:" << std::endl
|
||||
<< " - Version: " << GECODE_VERSION << std::endl
|
||||
<< " - Variable types: ";
|
||||
#ifdef GECODE_HAS_INT_VARS
|
||||
std::cerr << "BoolVar IntVar ";
|
||||
#endif
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
std::cerr << "SetVar ";
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
std::cerr << "FloatVar "
|
||||
<< std::endl
|
||||
<< " - Trigonometric and transcendental float constraints: ";
|
||||
#ifdef GECODE_HAS_MPFR
|
||||
std::cerr << "enabled";
|
||||
#else
|
||||
std::cerr << "disabled";
|
||||
#endif
|
||||
#endif
|
||||
std::cerr << std::endl;
|
||||
std::cerr << " - Thread support: ";
|
||||
#ifdef GECODE_HAS_THREADS
|
||||
if (Support::Thread::npu() == 1)
|
||||
std::cerr << "enabled (1 processing unit)";
|
||||
else
|
||||
std::cerr << "enabled (" << Support::Thread::npu()
|
||||
<< " processing units)";
|
||||
#else
|
||||
std::cerr << "disabled";
|
||||
#endif
|
||||
std::cerr << std::endl
|
||||
<< " - Gist support: ";
|
||||
#ifdef GECODE_HAS_GIST
|
||||
std::cerr << "enabled";
|
||||
#else
|
||||
std::cerr << "disabled";
|
||||
#endif
|
||||
std::cerr << std::endl << std::endl
|
||||
<< "Options for " << name() << ":" << std::endl
|
||||
<< "\t-help, --help, -?" << std::endl
|
||||
<< "\t\tprint this help message" << std::endl;
|
||||
for (Driver::BaseOption* o = fst; o != NULL; o = o->next)
|
||||
o->help();
|
||||
}
|
||||
|
||||
void
|
||||
BaseOptions::parse(int& argc, char* argv[]) {
|
||||
int c = argc;
|
||||
char** v = argv;
|
||||
next:
|
||||
for (Driver::BaseOption* o = fst; o != NULL; o = o->next)
|
||||
if (int a = o->parse(c,v)) {
|
||||
c -= a; v += a;
|
||||
goto next;
|
||||
}
|
||||
if (c >= 2) {
|
||||
if (!strcmp(v[1],"-help") || !strcmp(v[1],"--help") ||
|
||||
!strcmp(v[1],"-?")) {
|
||||
help();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
// Copy remaining arguments
|
||||
argc = c;
|
||||
for (int i=1; i<argc; i++)
|
||||
argv[i] = v[i];
|
||||
return;
|
||||
}
|
||||
|
||||
BaseOptions::~BaseOptions(void) {
|
||||
Driver::BaseOption::strdel(_name);
|
||||
}
|
||||
|
||||
|
||||
Options::Options(const char* n)
|
||||
: BaseOptions(n),
|
||||
|
||||
_model("-model","model variants"),
|
||||
_symmetry("-symmetry","symmetry variants"),
|
||||
_propagation("-propagation","propagation variants"),
|
||||
_icl("-icl","integer consistency level",ICL_DEF),
|
||||
_branching("-branching","branching variants"),
|
||||
_decay("-decay","decay factor",1.0),
|
||||
|
||||
_search("-search","search engine variants"),
|
||||
_solutions("-solutions","number of solutions (0 = all)",1),
|
||||
_threads("-threads","number of threads (0 = #processing units)",
|
||||
Search::Config::threads),
|
||||
_c_d("-c-d","recomputation commit distance",Search::Config::c_d),
|
||||
_a_d("-a-d","recomputation adaptation distance",Search::Config::a_d),
|
||||
_node("-node","node cutoff (0 = none, solution mode)"),
|
||||
_fail("-fail","failure cutoff (0 = none, solution mode)"),
|
||||
_time("-time","time (in ms) cutoff (0 = none, solution mode)"),
|
||||
_restart("-restart","restart sequence type",RM_NONE),
|
||||
_r_base("-restart-base","base for geometric restart sequence",1.5),
|
||||
_r_scale("-restart-scale","scale factor for restart sequence",250),
|
||||
_nogoods("-nogoods","whether to use no-goods from restarts",false),
|
||||
_nogoods_limit("-nogoods-limit","depth limit for no-good extraction",
|
||||
Search::Config::nogoods_limit),
|
||||
_interrupt("-interrupt","whether to catch Ctrl-C (true) or not (false)",
|
||||
true),
|
||||
|
||||
_mode("-mode","how to execute script",SM_SOLUTION),
|
||||
_samples("-samples","how many samples (time mode)",1),
|
||||
_iterations("-iterations","iterations per sample (time mode)",1),
|
||||
_print_last("-print-last",
|
||||
"whether to only print the last solution (solution mode)",
|
||||
false),
|
||||
_out_file("-file-sol", "where to print solutions "
|
||||
"(supports stdout, stdlog, stderr)","stdout"),
|
||||
_log_file("-file-stat", "where to print statistics "
|
||||
"(supports stdout, stdlog, stderr)","stdout")
|
||||
{
|
||||
|
||||
_icl.add(ICL_DEF, "def"); _icl.add(ICL_VAL, "val");
|
||||
_icl.add(ICL_BND, "bnd"); _icl.add(ICL_DOM, "dom");
|
||||
|
||||
_mode.add(SM_SOLUTION, "solution");
|
||||
_mode.add(SM_TIME, "time");
|
||||
_mode.add(SM_STAT, "stat");
|
||||
_mode.add(SM_GIST, "gist");
|
||||
|
||||
_restart.add(RM_NONE,"none");
|
||||
_restart.add(RM_CONSTANT,"constant");
|
||||
_restart.add(RM_LINEAR,"linear");
|
||||
_restart.add(RM_LUBY,"luby");
|
||||
_restart.add(RM_GEOMETRIC,"geometric");
|
||||
|
||||
add(_model); add(_symmetry); add(_propagation); add(_icl);
|
||||
add(_branching); add(_decay);
|
||||
add(_search); add(_solutions); add(_threads); add(_c_d); add(_a_d);
|
||||
add(_node); add(_fail); add(_time); add(_interrupt);
|
||||
add(_restart); add(_r_base); add(_r_scale);
|
||||
add(_nogoods); add(_nogoods_limit);
|
||||
add(_mode); add(_iterations); add(_samples); add(_print_last);
|
||||
add(_out_file); add(_log_file);
|
||||
}
|
||||
|
||||
|
||||
SizeOptions::SizeOptions(const char* e)
|
||||
: Options(e), _size(0) {}
|
||||
|
||||
void
|
||||
SizeOptions::help(void) {
|
||||
Options::help();
|
||||
std::cerr << "\t(unsigned int) default: " << size() << std::endl
|
||||
<< "\t\twhich version/size for script" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
SizeOptions::parse(int& argc, char* argv[]) {
|
||||
Options::parse(argc,argv);
|
||||
if (argc < 2)
|
||||
return;
|
||||
size(static_cast<unsigned int>(atoi(argv[1])));
|
||||
}
|
||||
|
||||
|
||||
|
||||
InstanceOptions::InstanceOptions(const char* e)
|
||||
: Options(e), _inst(NULL) {}
|
||||
|
||||
void
|
||||
InstanceOptions::instance(const char* s) {
|
||||
Driver::BaseOption::strdel(_inst);
|
||||
_inst = Driver::BaseOption::strdup(s);
|
||||
}
|
||||
|
||||
void
|
||||
InstanceOptions::help(void) {
|
||||
Options::help();
|
||||
std::cerr << "\t(string) default: " << instance() << std::endl
|
||||
<< "\t\twhich instance for script" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
InstanceOptions::parse(int& argc, char* argv[]) {
|
||||
Options::parse(argc,argv);
|
||||
if (argc < 2)
|
||||
return;
|
||||
instance(argv[1]);
|
||||
}
|
||||
|
||||
InstanceOptions::~InstanceOptions(void) {
|
||||
Driver::BaseOption::strdel(_inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// STATISTICS: driver-any
|
||||
@@ -1,486 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Christian Schulte <schulte@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Christian Schulte, 2004
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace Gecode {
|
||||
|
||||
namespace Driver {
|
||||
|
||||
/*
|
||||
* String option
|
||||
*
|
||||
*/
|
||||
inline const char*
|
||||
StringValueOption::value(void) const {
|
||||
return cur;
|
||||
}
|
||||
|
||||
/*
|
||||
* String option
|
||||
*
|
||||
*/
|
||||
inline
|
||||
StringOption::StringOption(const char* o, const char* e, int v)
|
||||
: BaseOption(o,e), cur(v), fst(NULL), lst(NULL) {}
|
||||
inline void
|
||||
StringOption::value(int v) {
|
||||
cur = v;
|
||||
}
|
||||
inline int
|
||||
StringOption::value(void) const {
|
||||
return cur;
|
||||
}
|
||||
|
||||
/*
|
||||
* Integer option
|
||||
*
|
||||
*/
|
||||
inline
|
||||
IntOption::IntOption(const char* o, const char* e, int v)
|
||||
: BaseOption(o,e), cur(v) {}
|
||||
inline void
|
||||
IntOption::value(int v) {
|
||||
cur = v;
|
||||
}
|
||||
inline int
|
||||
IntOption::value(void) const {
|
||||
return cur;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unsigned integer option
|
||||
*
|
||||
*/
|
||||
inline
|
||||
UnsignedIntOption::UnsignedIntOption(const char* o, const char* e,
|
||||
unsigned int v)
|
||||
: BaseOption(o,e), cur(v) {}
|
||||
inline void
|
||||
UnsignedIntOption::value(unsigned int v) {
|
||||
cur = v;
|
||||
}
|
||||
inline unsigned int
|
||||
UnsignedIntOption::value(void) const {
|
||||
return cur;
|
||||
}
|
||||
|
||||
/*
|
||||
* Double option
|
||||
*
|
||||
*/
|
||||
inline
|
||||
DoubleOption::DoubleOption(const char* o, const char* e,
|
||||
double v)
|
||||
: BaseOption(o,e), cur(v) {}
|
||||
inline void
|
||||
DoubleOption::value(double v) {
|
||||
cur = v;
|
||||
}
|
||||
inline double
|
||||
DoubleOption::value(void) const {
|
||||
return cur;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bool option
|
||||
*
|
||||
*/
|
||||
inline
|
||||
BoolOption::BoolOption(const char* o, const char* e, bool v)
|
||||
: BaseOption(o,e), cur(v) {}
|
||||
inline void
|
||||
BoolOption::value(bool v) {
|
||||
cur = v;
|
||||
}
|
||||
inline bool
|
||||
BoolOption::value(void) const {
|
||||
return cur;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Options
|
||||
*
|
||||
*/
|
||||
inline const char*
|
||||
BaseOptions::name(void) const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Model options
|
||||
*
|
||||
*/
|
||||
inline void
|
||||
Options::model(int v) {
|
||||
_model.value(v);
|
||||
}
|
||||
inline void
|
||||
Options::model(int v, const char* o, const char* h) {
|
||||
_model.add(v,o,h);
|
||||
}
|
||||
inline int
|
||||
Options::model(void) const {
|
||||
return _model.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::symmetry(int v) {
|
||||
_symmetry.value(v);
|
||||
}
|
||||
inline void
|
||||
Options::symmetry(int v, const char* o, const char* h) {
|
||||
_symmetry.add(v,o,h);
|
||||
}
|
||||
inline int
|
||||
Options::symmetry(void) const {
|
||||
return _symmetry.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::propagation(int v) {
|
||||
_propagation.value(v);
|
||||
}
|
||||
inline void
|
||||
Options::propagation(int v, const char* o, const char* h) {
|
||||
_propagation.add(v,o,h);
|
||||
}
|
||||
inline int
|
||||
Options::propagation(void) const {
|
||||
return _propagation.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::icl(IntConLevel i) {
|
||||
_icl.value(i);
|
||||
}
|
||||
inline IntConLevel
|
||||
Options::icl(void) const {
|
||||
return static_cast<IntConLevel>(_icl.value());
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::branching(int v) {
|
||||
_branching.value(v);
|
||||
}
|
||||
inline void
|
||||
Options::branching(int v, const char* o, const char* h) {
|
||||
_branching.add(v,o,h);
|
||||
}
|
||||
inline int
|
||||
Options::branching(void) const {
|
||||
return _branching.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::decay(double d) {
|
||||
_decay.value(d);
|
||||
}
|
||||
inline double
|
||||
Options::decay(void) const {
|
||||
return _decay.value();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Search options
|
||||
*
|
||||
*/
|
||||
inline void
|
||||
Options::search(int v) {
|
||||
_search.value(v);
|
||||
}
|
||||
inline void
|
||||
Options::search(int v, const char* o, const char* h) {
|
||||
_search.add(v,o,h);
|
||||
}
|
||||
inline int
|
||||
Options::search(void) const {
|
||||
return _search.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::solutions(unsigned int n) {
|
||||
_solutions.value(n);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::solutions(void) const {
|
||||
return _solutions.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::threads(double n) {
|
||||
_threads.value(n);
|
||||
}
|
||||
inline double
|
||||
Options::threads(void) const {
|
||||
return _threads.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::c_d(unsigned int d) {
|
||||
_c_d.value(d);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::c_d(void) const {
|
||||
return _c_d.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::a_d(unsigned int d) {
|
||||
_a_d.value(d);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::a_d(void) const {
|
||||
return _a_d.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::node(unsigned int n) {
|
||||
_node.value(n);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::node(void) const {
|
||||
return _node.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::fail(unsigned int n) {
|
||||
_fail.value(n);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::fail(void) const {
|
||||
return _fail.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::time(unsigned int t) {
|
||||
_time.value(t);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::time(void) const {
|
||||
return _time.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::restart(RestartMode rm) {
|
||||
_restart.value(rm);
|
||||
}
|
||||
inline RestartMode
|
||||
Options::restart(void) const {
|
||||
return static_cast<RestartMode>(_restart.value());
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::restart_base(double n) {
|
||||
_r_base.value(n);
|
||||
}
|
||||
inline double
|
||||
Options::restart_base(void) const {
|
||||
return _r_base.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::restart_scale(unsigned int n) {
|
||||
_r_scale.value(n);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::restart_scale(void) const {
|
||||
return _r_scale.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::nogoods(bool b) {
|
||||
_nogoods.value(b);
|
||||
}
|
||||
inline bool
|
||||
Options::nogoods(void) const {
|
||||
return _nogoods.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::nogoods_limit(unsigned int l) {
|
||||
_nogoods_limit.value(l);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::nogoods_limit(void) const {
|
||||
return _nogoods_limit.value();
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void
|
||||
Options::interrupt(bool b) {
|
||||
_interrupt.value(b);
|
||||
}
|
||||
inline bool
|
||||
Options::interrupt(void) const {
|
||||
return _interrupt.value();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Execution options
|
||||
*
|
||||
*/
|
||||
inline void
|
||||
Options::mode(ScriptMode sm) {
|
||||
_mode.value(sm);
|
||||
}
|
||||
inline ScriptMode
|
||||
Options::mode(void) const {
|
||||
return static_cast<ScriptMode>(_mode.value());
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::samples(unsigned int s) {
|
||||
_samples.value(s);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::samples(void) const {
|
||||
return _samples.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::iterations(unsigned int i) {
|
||||
_iterations.value(i);
|
||||
}
|
||||
inline unsigned int
|
||||
Options::iterations(void) const {
|
||||
return _iterations.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::print_last(bool p) {
|
||||
_print_last.value(p);
|
||||
}
|
||||
inline bool
|
||||
Options::print_last(void) const {
|
||||
return _print_last.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::out_file(const char *f) {
|
||||
_out_file.value(f);
|
||||
}
|
||||
|
||||
inline const char*
|
||||
Options::out_file(void) const {
|
||||
return _out_file.value();
|
||||
}
|
||||
|
||||
inline void
|
||||
Options::log_file(const char* f) {
|
||||
_log_file.value(f);
|
||||
}
|
||||
|
||||
inline const char*
|
||||
Options::log_file(void) const {
|
||||
return _log_file.value();
|
||||
}
|
||||
|
||||
#ifdef GECODE_HAS_GIST
|
||||
forceinline
|
||||
Options::_I::_I(void) : _click(heap,1), n_click(0),
|
||||
_solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
|
||||
_compare(heap,1), n_compare(0) {}
|
||||
|
||||
forceinline void
|
||||
Options::_I::click(Gist::Inspector* i) {
|
||||
_click[static_cast<int>(n_click++)] = i;
|
||||
}
|
||||
forceinline void
|
||||
Options::_I::solution(Gist::Inspector* i) {
|
||||
_solution[static_cast<int>(n_solution++)] = i;
|
||||
}
|
||||
forceinline void
|
||||
Options::_I::move(Gist::Inspector* i) {
|
||||
_move[static_cast<int>(n_move++)] = i;
|
||||
}
|
||||
forceinline void
|
||||
Options::_I::compare(Gist::Comparator* i) {
|
||||
_compare[static_cast<int>(n_compare++)] = i;
|
||||
}
|
||||
forceinline Gist::Inspector*
|
||||
Options::_I::click(unsigned int i) const {
|
||||
return (i < n_click) ? _click[i] : NULL;
|
||||
}
|
||||
forceinline Gist::Inspector*
|
||||
Options::_I::solution(unsigned int i) const {
|
||||
return (i < n_solution) ? _solution[i] : NULL;
|
||||
}
|
||||
forceinline Gist::Inspector*
|
||||
Options::_I::move(unsigned int i) const {
|
||||
return (i < n_move) ? _move[i] : NULL;
|
||||
}
|
||||
forceinline Gist::Comparator*
|
||||
Options::_I::compare(unsigned int i) const {
|
||||
return (i < n_compare) ? _compare[i] : NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Options with additional size argument
|
||||
*
|
||||
*/
|
||||
inline void
|
||||
SizeOptions::size(unsigned int s) {
|
||||
_size = s;
|
||||
}
|
||||
inline unsigned int
|
||||
SizeOptions::size(void) const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Options with additional string argument
|
||||
*
|
||||
*/
|
||||
inline const char*
|
||||
InstanceOptions::instance(void) const {
|
||||
return _inst;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// STATISTICS: driver-any
|
||||
@@ -1,104 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Christian Schulte <schulte@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Christian Schulte, 2004
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gecode/driver.hh>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace Gecode { namespace Driver {
|
||||
|
||||
void
|
||||
stop(Support::Timer& timer, std::ostream& os) {
|
||||
double t = timer.stop();
|
||||
unsigned int sec = static_cast<unsigned int>(floor(t / 1000.0));
|
||||
unsigned int o_msec = static_cast<unsigned int>
|
||||
(t - 1000.0*static_cast<double>(sec));
|
||||
unsigned int min = sec / 60;
|
||||
unsigned int o_sec = sec - 60 * min;
|
||||
unsigned int hour = min / 60;
|
||||
unsigned int o_min = min - 60 * hour;
|
||||
unsigned int day = hour / 24;
|
||||
unsigned int o_hour = hour - 24 * day;
|
||||
if (day)
|
||||
os << day << " days, ";
|
||||
if (o_hour)
|
||||
os << o_hour << ":";
|
||||
if (o_hour || o_min) {
|
||||
if (o_hour) {
|
||||
os.width(2); os.fill('0');
|
||||
}
|
||||
os << o_min << ":";
|
||||
os.width(2); os.fill('0');
|
||||
}
|
||||
os << o_sec << ".";
|
||||
os.width(3); os.fill('0');
|
||||
os << o_msec
|
||||
<< " ("
|
||||
<< std::showpoint << std::fixed
|
||||
<< std::setprecision(3) << t << " ms)";
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
am(double t[], int n) {
|
||||
if (n < 1)
|
||||
return 0.0;
|
||||
double s = 0;
|
||||
for (int i=n; i--; )
|
||||
s += t[i];
|
||||
return s / n;
|
||||
}
|
||||
|
||||
double
|
||||
dev(double t[], int n) {
|
||||
if (n < 2)
|
||||
return 0.0;
|
||||
double m = am(t,n);
|
||||
double s = 0.0;
|
||||
for (int i=n; i--; ) {
|
||||
double d = t[i]-m;
|
||||
s += d*d;
|
||||
}
|
||||
return ::sqrt(s / (n-1)) / m;
|
||||
}
|
||||
|
||||
bool CombinedStop::sigint;
|
||||
|
||||
}}
|
||||
|
||||
// STATISTICS: driver-any
|
||||
@@ -1,501 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Christian Schulte <schulte@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Christian Schulte, 2004
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef GECODE_THREADS_WINDOWS
|
||||
#include <csignal>
|
||||
#endif
|
||||
|
||||
namespace Gecode { namespace Driver {
|
||||
|
||||
/**
|
||||
* \brief Stop object based on nodes, failures, and time
|
||||
*
|
||||
*/
|
||||
class CombinedStop : public Search::Stop {
|
||||
private:
|
||||
Search::NodeStop* ns; ///< Used node stop object
|
||||
Search::FailStop* fs; ///< Used fail stop object
|
||||
Search::TimeStop* ts; ///< Used time stop object
|
||||
GECODE_DRIVER_EXPORT
|
||||
static bool sigint; ///< Whether search was interrupted using Ctrl-C
|
||||
/// Initialize stop object
|
||||
CombinedStop(unsigned int node, unsigned int fail, unsigned int time)
|
||||
: ns((node > 0) ? new Search::NodeStop(node) : NULL),
|
||||
fs((fail > 0) ? new Search::FailStop(fail) : NULL),
|
||||
ts((time > 0) ? new Search::TimeStop(time) : NULL) {
|
||||
sigint = false;
|
||||
}
|
||||
public:
|
||||
/// Reason why search has been stopped
|
||||
enum {
|
||||
SR_NODE = 1 << 0, ///< Node limit reached
|
||||
SR_FAIL = 1 << 1, ///< Fail limit reached
|
||||
SR_TIME = 1 << 2, ///< Time limit reached
|
||||
SR_INT = 1 << 3 ///< Interrupted by user
|
||||
};
|
||||
/// Test whether search must be stopped
|
||||
virtual bool stop(const Search::Statistics& s, const Search::Options& o) {
|
||||
return
|
||||
sigint ||
|
||||
((ns != NULL) && ns->stop(s,o)) ||
|
||||
((fs != NULL) && fs->stop(s,o)) ||
|
||||
((ts != NULL) && ts->stop(s,o));
|
||||
}
|
||||
/// Report reason why search has been stopped
|
||||
int reason(const Search::Statistics& s, const Search::Options& o) {
|
||||
return
|
||||
(((ns != NULL) && ns->stop(s,o)) ? SR_NODE : 0) |
|
||||
(((fs != NULL) && fs->stop(s,o)) ? SR_FAIL : 0) |
|
||||
(((ts != NULL) && ts->stop(s,o)) ? SR_TIME : 0) |
|
||||
(sigint ? SR_INT : 0);
|
||||
}
|
||||
/// Create appropriate stop-object
|
||||
static Search::Stop*
|
||||
create(unsigned int node, unsigned int fail, unsigned int time,
|
||||
bool intr) {
|
||||
if ( (!intr) && (node == 0) && (fail == 0) && (time == 0))
|
||||
return NULL;
|
||||
else
|
||||
return new CombinedStop(node,fail,time);
|
||||
}
|
||||
#ifdef GECODE_THREADS_WINDOWS
|
||||
/// Handler for catching Ctrl-C
|
||||
static BOOL interrupt(DWORD t) {
|
||||
if (t == CTRL_C_EVENT) {
|
||||
sigint = true;
|
||||
installCtrlHandler(false,true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
/// Handler for catching Ctrl-C
|
||||
static void
|
||||
interrupt(int) {
|
||||
sigint = true;
|
||||
installCtrlHandler(false,true);
|
||||
}
|
||||
#endif
|
||||
/// Install handler for catching Ctrl-C
|
||||
static void installCtrlHandler(bool install, bool force=false) {
|
||||
if (force || !sigint) {
|
||||
#ifdef GECODE_THREADS_WINDOWS
|
||||
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) interrupt, install);
|
||||
#else
|
||||
std::signal(SIGINT, install ? interrupt : SIG_DFL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/// Destructor
|
||||
~CombinedStop(void) {
|
||||
delete ns; delete fs; delete ts;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Get time since start of timer and print user friendly time
|
||||
* information.
|
||||
*/
|
||||
GECODE_DRIVER_EXPORT void
|
||||
stop(Support::Timer& t, std::ostream& os);
|
||||
|
||||
/**
|
||||
* \brief Compute arithmetic mean of \a n elements in \a t
|
||||
*/
|
||||
GECODE_DRIVER_EXPORT double
|
||||
am(double t[], int n);
|
||||
|
||||
/**
|
||||
* \brief Compute deviation of \a n elements in \a t
|
||||
*/
|
||||
GECODE_DRIVER_EXPORT double
|
||||
dev(double t[], int n);
|
||||
|
||||
/// Create cutoff object from options
|
||||
template<class Options>
|
||||
inline Search::Cutoff*
|
||||
createCutoff(const Options& o) {
|
||||
switch (o.restart()) {
|
||||
case RM_NONE:
|
||||
return NULL;
|
||||
case RM_CONSTANT:
|
||||
return Search::Cutoff::constant(o.restart_scale());
|
||||
case RM_LINEAR:
|
||||
return Search::Cutoff::linear(o.restart_scale());
|
||||
case RM_LUBY:
|
||||
return Search::Cutoff::luby(o.restart_scale());
|
||||
case RM_GEOMETRIC:
|
||||
return Search::Cutoff::geometric(o.restart_scale(),o.restart_base());
|
||||
default: GECODE_NEVER;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef GECODE_HAS_GIST
|
||||
|
||||
/**
|
||||
* \brief Traits class for search engines
|
||||
*/
|
||||
template<class Engine>
|
||||
class GistEngine {
|
||||
public:
|
||||
static void explore(Space* root, const Gist::Options& opt) {
|
||||
(void) Gist::dfs(root, opt);
|
||||
}
|
||||
};
|
||||
|
||||
/// Specialization for DFS
|
||||
template<typename S>
|
||||
class GistEngine<DFS<S> > {
|
||||
public:
|
||||
static void explore(S* root, const Gist::Options& opt) {
|
||||
(void) Gist::dfs(root, opt);
|
||||
}
|
||||
};
|
||||
|
||||
/// Specialization for BAB
|
||||
template<typename S>
|
||||
class GistEngine<BAB<S> > {
|
||||
public:
|
||||
static void explore(S* root, const Gist::Options& opt) {
|
||||
(void) Gist::bab(root, opt);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template<class Space>
|
||||
std::ostream&
|
||||
ScriptBase<Space>::select_ostream(const char* name, std::ofstream& ofs) {
|
||||
if (strcmp(name, "stdout") == 0) {
|
||||
return std::cout;
|
||||
} else if (strcmp(name, "stdlog") == 0) {
|
||||
return std::clog;
|
||||
} else if (strcmp(name, "stderr") == 0) {
|
||||
return std::cerr;
|
||||
} else {
|
||||
ofs.open(name);
|
||||
return ofs;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Wrapper class to add engine template argument
|
||||
*/
|
||||
template<template<class> class E, class T>
|
||||
class EngineToMeta : public E<T> {
|
||||
public:
|
||||
EngineToMeta(T* s, const Search::Options& o) : E<T>(s,o) {}
|
||||
};
|
||||
|
||||
template<class Space>
|
||||
template<class Script, template<class> class Engine, class Options>
|
||||
void
|
||||
ScriptBase<Space>::run(const Options& o, Script* s) {
|
||||
if (o.restart()==RM_NONE) {
|
||||
runMeta<Script,Engine,Options,EngineToMeta>(o,s);
|
||||
} else {
|
||||
runMeta<Script,Engine,Options,RBS>(o,s);
|
||||
}
|
||||
}
|
||||
|
||||
template<class Space>
|
||||
template<class Script, template<class> class Engine, class Options,
|
||||
template<template<class> class,class> class Meta>
|
||||
void
|
||||
ScriptBase<Space>::runMeta(const Options& o, Script* s) {
|
||||
using namespace std;
|
||||
|
||||
ofstream sol_file, log_file;
|
||||
|
||||
ostream& s_out = select_ostream(o.out_file(), sol_file);
|
||||
ostream& l_out = select_ostream(o.log_file(), log_file);
|
||||
|
||||
try {
|
||||
switch (o.mode()) {
|
||||
case SM_GIST:
|
||||
#ifdef GECODE_HAS_GIST
|
||||
{
|
||||
Gist::Print<Script> pi(o.name());
|
||||
Gist::VarComparator<Script> vc(o.name());
|
||||
Gist::Options opt;
|
||||
opt.inspect.click(&pi);
|
||||
opt.inspect.compare(&vc);
|
||||
opt.clone = false;
|
||||
opt.c_d = o.c_d();
|
||||
opt.a_d = o.a_d();
|
||||
for (int i=0; o.inspect.click(i) != NULL; i++)
|
||||
opt.inspect.click(o.inspect.click(i));
|
||||
for (int i=0; o.inspect.solution(i) != NULL; i++)
|
||||
opt.inspect.solution(o.inspect.solution(i));
|
||||
for (int i=0; o.inspect.move(i) != NULL; i++)
|
||||
opt.inspect.move(o.inspect.move(i));
|
||||
for (int i=0; o.inspect.compare(i) != NULL; i++)
|
||||
opt.inspect.compare(o.inspect.compare(i));
|
||||
if (s == NULL)
|
||||
s = new Script(o);
|
||||
(void) GistEngine<Engine<Script> >::explore(s, opt);
|
||||
}
|
||||
break;
|
||||
// If Gist is not available, fall through
|
||||
#endif
|
||||
case SM_SOLUTION:
|
||||
{
|
||||
l_out << o.name() << endl;
|
||||
Support::Timer t;
|
||||
int i = o.solutions();
|
||||
t.start();
|
||||
if (s == NULL)
|
||||
s = new Script(o);
|
||||
unsigned int n_p = s->propagators();
|
||||
unsigned int n_b = s->branchers();
|
||||
Search::Options so;
|
||||
so.threads = o.threads();
|
||||
so.c_d = o.c_d();
|
||||
so.a_d = o.a_d();
|
||||
so.stop = CombinedStop::create(o.node(),o.fail(), o.time(),
|
||||
o.interrupt());
|
||||
so.cutoff = createCutoff(o);
|
||||
so.clone = false;
|
||||
so.nogoods_limit = o.nogoods() ? o.nogoods_limit() : 0U;
|
||||
if (o.interrupt())
|
||||
CombinedStop::installCtrlHandler(true);
|
||||
{
|
||||
Meta<Engine,Script> e(s,so);
|
||||
if (o.print_last()) {
|
||||
Script* px = NULL;
|
||||
do {
|
||||
Script* ex = e.next();
|
||||
if (ex == NULL) {
|
||||
if (px != NULL) {
|
||||
px->print(s_out);
|
||||
delete px;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
delete px;
|
||||
px = ex;
|
||||
}
|
||||
} while (--i != 0);
|
||||
} else {
|
||||
do {
|
||||
Script* ex = e.next();
|
||||
if (ex == NULL)
|
||||
break;
|
||||
ex->print(s_out);
|
||||
delete ex;
|
||||
} while (--i != 0);
|
||||
}
|
||||
if (o.interrupt())
|
||||
CombinedStop::installCtrlHandler(false);
|
||||
Search::Statistics stat = e.statistics();
|
||||
s_out << endl;
|
||||
if (e.stopped()) {
|
||||
l_out << "Search engine stopped..." << endl
|
||||
<< "\treason: ";
|
||||
int r = static_cast<CombinedStop*>(so.stop)->reason(stat,so);
|
||||
if (r & CombinedStop::SR_INT)
|
||||
l_out << "user interrupt " << endl;
|
||||
else {
|
||||
if (r & CombinedStop::SR_NODE)
|
||||
l_out << "node ";
|
||||
if (r & CombinedStop::SR_FAIL)
|
||||
l_out << "fail ";
|
||||
if (r & CombinedStop::SR_TIME)
|
||||
l_out << "time ";
|
||||
l_out << "limit reached" << endl << endl;
|
||||
}
|
||||
}
|
||||
l_out << "Initial" << endl
|
||||
<< "\tpropagators: " << n_p << endl
|
||||
<< "\tbranchers: " << n_b << endl
|
||||
<< endl
|
||||
<< "Summary" << endl
|
||||
<< "\truntime: ";
|
||||
stop(t, l_out);
|
||||
l_out << endl
|
||||
<< "\tsolutions: "
|
||||
<< ::abs(static_cast<int>(o.solutions()) - i) << endl
|
||||
<< "\tpropagations: " << stat.propagate << endl
|
||||
<< "\tnodes: " << stat.node << endl
|
||||
<< "\tfailures: " << stat.fail << endl
|
||||
<< "\trestarts: " << stat.restart << endl
|
||||
<< "\tno-goods: " << stat.nogood << endl
|
||||
<< "\tpeak depth: " << stat.depth << endl
|
||||
#ifdef GECODE_PEAKHEAP
|
||||
<< "\tpeak memory: "
|
||||
<< static_cast<int>((heap.peak()+1023) / 1024) << " KB"
|
||||
<< endl
|
||||
#endif
|
||||
<< endl;
|
||||
}
|
||||
delete so.stop;
|
||||
}
|
||||
break;
|
||||
case SM_STAT:
|
||||
{
|
||||
l_out << o.name() << endl;
|
||||
Support::Timer t;
|
||||
int i = o.solutions();
|
||||
t.start();
|
||||
if (s == NULL)
|
||||
s = new Script(o);
|
||||
unsigned int n_p = s->propagators();
|
||||
unsigned int n_b = s->branchers();
|
||||
Search::Options so;
|
||||
so.clone = false;
|
||||
so.threads = o.threads();
|
||||
so.c_d = o.c_d();
|
||||
so.a_d = o.a_d();
|
||||
so.stop = CombinedStop::create(o.node(),o.fail(), o.time(),
|
||||
o.interrupt());
|
||||
so.cutoff = createCutoff(o);
|
||||
so.nogoods_limit = o.nogoods() ? o.nogoods_limit() : 0U;
|
||||
if (o.interrupt())
|
||||
CombinedStop::installCtrlHandler(true);
|
||||
{
|
||||
Meta<Engine,Script> e(s,so);
|
||||
do {
|
||||
Script* ex = e.next();
|
||||
if (ex == NULL)
|
||||
break;
|
||||
delete ex;
|
||||
} while (--i != 0);
|
||||
if (o.interrupt())
|
||||
CombinedStop::installCtrlHandler(false);
|
||||
Search::Statistics stat = e.statistics();
|
||||
l_out << endl
|
||||
<< "\tpropagators: " << n_p << endl
|
||||
<< "\tbranchers: " << n_b << endl
|
||||
<< "\truntime: ";
|
||||
stop(t, l_out);
|
||||
l_out << endl
|
||||
<< "\tsolutions: "
|
||||
<< ::abs(static_cast<int>(o.solutions()) - i) << endl
|
||||
<< "\tpropagations: " << stat.propagate << endl
|
||||
<< "\tnodes: " << stat.node << endl
|
||||
<< "\tfailures: " << stat.fail << endl
|
||||
<< "\trestarts: " << stat.restart << endl
|
||||
<< "\tno-goods: " << stat.nogood << endl
|
||||
<< "\tpeak depth: " << stat.depth << endl
|
||||
#ifdef GECODE_PEAKHEAP
|
||||
<< "\tpeak memory: "
|
||||
<< static_cast<int>((heap.peak()+1023) / 1024) << " KB"
|
||||
<< endl
|
||||
#endif
|
||||
<< endl;
|
||||
}
|
||||
delete so.stop;
|
||||
}
|
||||
break;
|
||||
case SM_TIME:
|
||||
{
|
||||
l_out << o.name() << endl;
|
||||
Support::Timer t;
|
||||
double* ts = new double[o.samples()];
|
||||
bool stopped = false;
|
||||
for (unsigned int s = o.samples(); !stopped && s--; ) {
|
||||
t.start();
|
||||
for (unsigned int k = o.iterations(); !stopped && k--; ) {
|
||||
unsigned int i = o.solutions();
|
||||
Script* s = new Script(o);
|
||||
Search::Options so;
|
||||
so.clone = false;
|
||||
so.threads = o.threads();
|
||||
so.c_d = o.c_d();
|
||||
so.a_d = o.a_d();
|
||||
so.stop = CombinedStop::create(o.node(),o.fail(), o.time(),
|
||||
false);
|
||||
so.cutoff = createCutoff(o);
|
||||
so.nogoods_limit = o.nogoods() ? o.nogoods_limit() : 0U;
|
||||
{
|
||||
Meta<Engine,Script> e(s,so);
|
||||
do {
|
||||
Script* ex = e.next();
|
||||
if (ex == NULL)
|
||||
break;
|
||||
delete ex;
|
||||
} while (--i != 0);
|
||||
if (e.stopped())
|
||||
stopped = true;
|
||||
}
|
||||
delete so.stop;
|
||||
}
|
||||
ts[s] = t.stop() / o.iterations();
|
||||
}
|
||||
if (stopped) {
|
||||
l_out << "\tSTOPPED" << endl;
|
||||
} else {
|
||||
double m = am(ts,o.samples());
|
||||
double d = dev(ts,o.samples()) * 100.0;
|
||||
l_out << "\truntime: "
|
||||
<< setw(20) << right
|
||||
<< showpoint << fixed
|
||||
<< setprecision(6) << m << "ms"
|
||||
<< setprecision(2) << " (" << d << "% deviation)"
|
||||
<< endl;
|
||||
}
|
||||
delete [] ts;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (Exception& e) {
|
||||
cerr << "Exception: " << e.what() << "." << endl
|
||||
<< "Stopping..." << endl;
|
||||
if (sol_file.is_open())
|
||||
sol_file.close();
|
||||
if (log_file.is_open())
|
||||
log_file.close();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (sol_file.is_open())
|
||||
sol_file.close();
|
||||
if (log_file.is_open())
|
||||
log_file.close();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
// STATISTICS: driver-any
|
||||
@@ -1,594 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Contributing authors:
|
||||
* Gabriel Hjort Blindell <gabriel.hjort.blindell@gmail.com>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2007-2012
|
||||
* Gabriel Hjort Blindell, 2012
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GECODE_FLATZINC_HH__
|
||||
#define __GECODE_FLATZINC_HH__
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <gecode/kernel.hh>
|
||||
#include <gecode/int.hh>
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
#include <gecode/set.hh>
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
#include <gecode/float.hh>
|
||||
#endif
|
||||
#include <map>
|
||||
|
||||
/*
|
||||
* Support for DLLs under Windows
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(GECODE_STATIC_LIBS) && \
|
||||
(defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
|
||||
|
||||
#ifdef GECODE_BUILD_FLATZINC
|
||||
#define GECODE_FLATZINC_EXPORT __declspec( dllexport )
|
||||
#else
|
||||
#define GECODE_FLATZINC_EXPORT __declspec( dllimport )
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
|
||||
|
||||
#define GECODE_FLATZINC_EXPORT __attribute__ ((visibility("default")))
|
||||
|
||||
#else
|
||||
|
||||
#define GECODE_FLATZINC_EXPORT
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Configure auto-linking
|
||||
#ifndef GECODE_BUILD_FLATZINC
|
||||
#define GECODE_LIBRARY_NAME "FlatZinc"
|
||||
#include <gecode/support/auto-link.hpp>
|
||||
#endif
|
||||
|
||||
#include <gecode/driver.hh>
|
||||
|
||||
#include <gecode/flatzinc/conexpr.hh>
|
||||
#include <gecode/flatzinc/ast.hh>
|
||||
#include <gecode/flatzinc/varspec.hh>
|
||||
|
||||
/**
|
||||
* \namespace Gecode::FlatZinc
|
||||
* \brief Interpreter for the %FlatZinc language
|
||||
*
|
||||
* The Gecode::FlatZinc namespace contains all functionality required
|
||||
* to parse and solve constraint models written in the %FlatZinc language.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Gecode { namespace FlatZinc {
|
||||
|
||||
/**
|
||||
* \brief Output support class for %FlatZinc interpreter
|
||||
*
|
||||
*/
|
||||
class GECODE_FLATZINC_EXPORT Printer {
|
||||
private:
|
||||
AST::Array* _output;
|
||||
void printElem(std::ostream& out,
|
||||
AST::Node* ai,
|
||||
const Gecode::IntVarArray& iv,
|
||||
const Gecode::BoolVarArray& bv
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
,
|
||||
const Gecode::SetVarArray& sv
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
,
|
||||
const Gecode::FloatVarArray& fv
|
||||
#endif
|
||||
) const;
|
||||
void printElemDiff(std::ostream& out,
|
||||
AST::Node* ai,
|
||||
const Gecode::IntVarArray& iv1,
|
||||
const Gecode::IntVarArray& iv2,
|
||||
const Gecode::BoolVarArray& bv1,
|
||||
const Gecode::BoolVarArray& bv2
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
,
|
||||
const Gecode::SetVarArray& sv1,
|
||||
const Gecode::SetVarArray& sv2
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
,
|
||||
const Gecode::FloatVarArray& fv1,
|
||||
const Gecode::FloatVarArray& fv2
|
||||
#endif
|
||||
) const;
|
||||
public:
|
||||
Printer(void) : _output(NULL) {}
|
||||
void init(AST::Array* output);
|
||||
|
||||
void print(std::ostream& out,
|
||||
const Gecode::IntVarArray& iv,
|
||||
const Gecode::BoolVarArray& bv
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
,
|
||||
const Gecode::SetVarArray& sv
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
,
|
||||
const Gecode::FloatVarArray& fv
|
||||
#endif
|
||||
) const;
|
||||
|
||||
void printDiff(std::ostream& out,
|
||||
const Gecode::IntVarArray& iv1, const Gecode::IntVarArray& iv2,
|
||||
const Gecode::BoolVarArray& bv1, const Gecode::BoolVarArray& bv2
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
,
|
||||
const Gecode::SetVarArray& sv1, const Gecode::SetVarArray& sv2
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
,
|
||||
const Gecode::FloatVarArray& fv1,
|
||||
const Gecode::FloatVarArray& fv2
|
||||
#endif
|
||||
) const;
|
||||
|
||||
|
||||
~Printer(void);
|
||||
|
||||
void shrinkElement(AST::Node* node,
|
||||
std::map<int,int>& iv, std::map<int,int>& bv,
|
||||
std::map<int,int>& sv, std::map<int,int>& fv);
|
||||
|
||||
void shrinkArrays(Space& home,
|
||||
int& optVar, bool optVarIsInt,
|
||||
Gecode::IntVarArray& iv,
|
||||
Gecode::BoolVarArray& bv
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
,
|
||||
Gecode::SetVarArray& sv
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
,
|
||||
Gecode::FloatVarArray& fv
|
||||
#endif
|
||||
);
|
||||
|
||||
private:
|
||||
Printer(const Printer&);
|
||||
Printer& operator=(const Printer&);
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief %Options for running %FlatZinc models
|
||||
*
|
||||
*/
|
||||
class FlatZincOptions : public Gecode::BaseOptions {
|
||||
protected:
|
||||
/// \name Search options
|
||||
//@{
|
||||
Gecode::Driver::UnsignedIntOption _solutions; ///< How many solutions
|
||||
Gecode::Driver::BoolOption _allSolutions; ///< Return all solutions
|
||||
Gecode::Driver::DoubleOption _threads; ///< How many threads to use
|
||||
Gecode::Driver::BoolOption _free; ///< Use free search
|
||||
Gecode::Driver::DoubleOption _decay; ///< Decay option
|
||||
Gecode::Driver::UnsignedIntOption _c_d; ///< Copy recomputation distance
|
||||
Gecode::Driver::UnsignedIntOption _a_d; ///< Adaptive recomputation distance
|
||||
Gecode::Driver::UnsignedIntOption _node; ///< Cutoff for number of nodes
|
||||
Gecode::Driver::UnsignedIntOption _fail; ///< Cutoff for number of failures
|
||||
Gecode::Driver::UnsignedIntOption _time; ///< Cutoff for time
|
||||
Gecode::Driver::IntOption _seed; ///< Random seed
|
||||
Gecode::Driver::StringOption _restart; ///< Restart method option
|
||||
Gecode::Driver::DoubleOption _r_base; ///< Restart base
|
||||
Gecode::Driver::UnsignedIntOption _r_scale; ///< Restart scale factor
|
||||
Gecode::Driver::BoolOption _nogoods; ///< Whether to use no-goods
|
||||
Gecode::Driver::UnsignedIntOption _nogoods_limit; ///< Depth limit for extracting no-goods
|
||||
Gecode::Driver::BoolOption _interrupt; ///< Whether to catch SIGINT
|
||||
//@}
|
||||
|
||||
/// \name Execution options
|
||||
//@{
|
||||
Gecode::Driver::StringOption _mode; ///< Script mode to run
|
||||
Gecode::Driver::BoolOption _stat; ///< Emit statistics
|
||||
Gecode::Driver::StringValueOption _output; ///< Output file
|
||||
//@}
|
||||
public:
|
||||
/// Constructor
|
||||
FlatZincOptions(const char* s)
|
||||
: Gecode::BaseOptions(s),
|
||||
_solutions("-n","number of solutions (0 = all)",1),
|
||||
_allSolutions("-a", "return all solutions (equal to -solutions 0)"),
|
||||
_threads("-p","number of threads (0 = #processing units)",
|
||||
Gecode::Search::Config::threads),
|
||||
_free("-f", "free search, no need to follow search-specification"),
|
||||
_decay("-decay","decay factor",0.99),
|
||||
_c_d("-c-d","recomputation commit distance",Gecode::Search::Config::c_d),
|
||||
_a_d("-a-d","recomputation adaption distance",Gecode::Search::Config::a_d),
|
||||
_node("-node","node cutoff (0 = none, solution mode)"),
|
||||
_fail("-fail","failure cutoff (0 = none, solution mode)"),
|
||||
_time("-time","time (in ms) cutoff (0 = none, solution mode)"),
|
||||
_seed("-r","random seed",0),
|
||||
_restart("-restart","restart sequence type",RM_NONE),
|
||||
_r_base("-restart-base","base for geometric restart sequence",1.5),
|
||||
_r_scale("-restart-scale","scale factor for restart sequence",250),
|
||||
_nogoods("-nogoods","whether to use no-goods from restarts",false),
|
||||
_nogoods_limit("-nogoods-limit","depth limit for no-good extraction",
|
||||
Search::Config::nogoods_limit),
|
||||
_interrupt("-interrupt","whether to catch Ctrl-C (true) or not (false)",
|
||||
true),
|
||||
_mode("-mode","how to execute script",Gecode::SM_SOLUTION),
|
||||
_stat("-s","emit statistics"),
|
||||
_output("-o","file to send output to") {
|
||||
|
||||
_mode.add(Gecode::SM_SOLUTION, "solution");
|
||||
_mode.add(Gecode::SM_STAT, "stat");
|
||||
_mode.add(Gecode::SM_GIST, "gist");
|
||||
_restart.add(RM_NONE,"none");
|
||||
_restart.add(RM_CONSTANT,"constant");
|
||||
_restart.add(RM_LINEAR,"linear");
|
||||
_restart.add(RM_LUBY,"luby");
|
||||
_restart.add(RM_GEOMETRIC,"geometric");
|
||||
|
||||
add(_solutions); add(_threads); add(_c_d); add(_a_d);
|
||||
add(_allSolutions);
|
||||
add(_free);
|
||||
add(_decay);
|
||||
add(_node); add(_fail); add(_time); add(_interrupt);
|
||||
add(_seed);
|
||||
add(_restart); add(_r_base); add(_r_scale);
|
||||
add(_nogoods); add(_nogoods_limit);
|
||||
add(_mode); add(_stat);
|
||||
add(_output);
|
||||
}
|
||||
|
||||
void parse(int& argc, char* argv[]) {
|
||||
Gecode::BaseOptions::parse(argc,argv);
|
||||
if (_allSolutions.value()) {
|
||||
_solutions.value(0);
|
||||
}
|
||||
if (_stat.value())
|
||||
_mode.value(Gecode::SM_STAT);
|
||||
}
|
||||
|
||||
virtual void help(void) {
|
||||
std::cerr << "Gecode FlatZinc interpreter" << std::endl
|
||||
<< " - Supported FlatZinc version: " << GECODE_FLATZINC_VERSION
|
||||
<< std::endl << std::endl;
|
||||
Gecode::BaseOptions::help();
|
||||
}
|
||||
|
||||
unsigned int solutions(void) const { return _solutions.value(); }
|
||||
bool allSolutions(void) const { return _allSolutions.value(); }
|
||||
double threads(void) const { return _threads.value(); }
|
||||
bool free(void) const { return _free.value(); }
|
||||
unsigned int c_d(void) const { return _c_d.value(); }
|
||||
unsigned int a_d(void) const { return _a_d.value(); }
|
||||
unsigned int node(void) const { return _node.value(); }
|
||||
unsigned int fail(void) const { return _fail.value(); }
|
||||
unsigned int time(void) const { return _time.value(); }
|
||||
int seed(void) const { return _seed.value(); }
|
||||
const char* output(void) const { return _output.value(); }
|
||||
Gecode::ScriptMode mode(void) const {
|
||||
return static_cast<Gecode::ScriptMode>(_mode.value());
|
||||
}
|
||||
|
||||
double decay(void) const { return _decay.value(); }
|
||||
RestartMode restart(void) const {
|
||||
return static_cast<RestartMode>(_restart.value());
|
||||
}
|
||||
double restart_base(void) const { return _r_base.value(); }
|
||||
unsigned int restart_scale(void) const { return _r_scale.value(); }
|
||||
bool nogoods(void) const { return _nogoods.value(); }
|
||||
unsigned int nogoods_limit(void) const { return _nogoods_limit.value(); }
|
||||
bool interrupt(void) const { return _interrupt.value(); }
|
||||
|
||||
};
|
||||
|
||||
class BranchInformation : public SharedHandle {
|
||||
public:
|
||||
/// Constructor
|
||||
BranchInformation(void);
|
||||
/// Copy constructor
|
||||
BranchInformation(const BranchInformation& bi);
|
||||
/// Initialise for use
|
||||
void init(void);
|
||||
/// Add new brancher information
|
||||
void add(const BrancherHandle& bh,
|
||||
const std::string& rel0,
|
||||
const std::string& rel1,
|
||||
const std::vector<std::string>& n);
|
||||
/// Output branch information
|
||||
void print(const BrancherHandle& bh,
|
||||
int a, int i, int n, std::ostream& o) const;
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
/// Output branch information
|
||||
void print(const BrancherHandle& bh,
|
||||
int a, int i, const FloatNumBranch& nl, std::ostream& o) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief A space that can be initialized with a %FlatZinc model
|
||||
*
|
||||
*/
|
||||
class GECODE_FLATZINC_EXPORT FlatZincSpace : public Space {
|
||||
public:
|
||||
enum Meth {
|
||||
SAT, //< Solve as satisfaction problem
|
||||
MIN, //< Solve as minimization problem
|
||||
MAX //< Solve as maximization problem
|
||||
};
|
||||
protected:
|
||||
/// Number of integer variables
|
||||
int intVarCount;
|
||||
/// Number of Boolean variables
|
||||
int boolVarCount;
|
||||
/// Number of float variables
|
||||
int floatVarCount;
|
||||
/// Number of set variables
|
||||
int setVarCount;
|
||||
|
||||
/// Index of the variable to optimize
|
||||
int _optVar;
|
||||
/// Whether variable to optimize is integer (or float)
|
||||
bool _optVarIsInt;
|
||||
|
||||
/// Whether to solve as satisfaction or optimization problem
|
||||
Meth _method;
|
||||
|
||||
/// Annotations on the solve item
|
||||
AST::Array* _solveAnnotations;
|
||||
|
||||
/// Copy constructor
|
||||
FlatZincSpace(bool share, FlatZincSpace&);
|
||||
private:
|
||||
/// Run the search engine
|
||||
template<template<class> class Engine>
|
||||
void
|
||||
runEngine(std::ostream& out, const Printer& p,
|
||||
const FlatZincOptions& opt, Gecode::Support::Timer& t_total);
|
||||
/// Run the meta search engine
|
||||
template<template<class> class Engine,
|
||||
template<template<class> class,class> class Meta>
|
||||
void
|
||||
runMeta(std::ostream& out, const Printer& p,
|
||||
const FlatZincOptions& opt, Gecode::Support::Timer& t_total);
|
||||
void
|
||||
branchWithPlugin(AST::Node* ann);
|
||||
public:
|
||||
/// The integer variables
|
||||
Gecode::IntVarArray iv;
|
||||
/// The introduced integer variables
|
||||
Gecode::IntVarArray iv_aux;
|
||||
/// Indicates whether an integer variable is introduced by mzn2fzn
|
||||
std::vector<bool> iv_introduced;
|
||||
/// Indicates whether an integer variable aliases a Boolean variable
|
||||
int* iv_boolalias;
|
||||
/// The Boolean variables
|
||||
Gecode::BoolVarArray bv;
|
||||
/// The introduced Boolean variables
|
||||
Gecode::BoolVarArray bv_aux;
|
||||
/// Indicates whether a Boolean variable is introduced by mzn2fzn
|
||||
std::vector<bool> bv_introduced;
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
/// The set variables
|
||||
Gecode::SetVarArray sv;
|
||||
/// The introduced set variables
|
||||
Gecode::SetVarArray sv_aux;
|
||||
/// Indicates whether a set variable is introduced by mzn2fzn
|
||||
std::vector<bool> sv_introduced;
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
/// The float variables
|
||||
Gecode::FloatVarArray fv;
|
||||
/// The introduced float variables
|
||||
Gecode::FloatVarArray fv_aux;
|
||||
/// Indicates whether a float variable is introduced by mzn2fzn
|
||||
std::vector<bool> fv_introduced;
|
||||
#endif
|
||||
/// Whether the introduced variables still need to be copied
|
||||
bool needAuxVars;
|
||||
/// Construct empty space
|
||||
FlatZincSpace(void);
|
||||
|
||||
/// Destructor
|
||||
~FlatZincSpace(void);
|
||||
|
||||
/// Initialize space with given number of variables
|
||||
void init(int intVars, int boolVars, int setVars, int floatVars);
|
||||
|
||||
/// Create new integer variable from specification
|
||||
void newIntVar(IntVarSpec* vs);
|
||||
/// Link integer variable \a iv to Boolean variable \a bv
|
||||
void aliasBool2Int(int iv, int bv);
|
||||
/// Return linked Boolean variable for integer variable \a iv
|
||||
int aliasBool2Int(int iv);
|
||||
/// Create new Boolean variable from specification
|
||||
void newBoolVar(BoolVarSpec* vs);
|
||||
/// Create new set variable from specification
|
||||
void newSetVar(SetVarSpec* vs);
|
||||
/// Create new float variable from specification
|
||||
void newFloatVar(FloatVarSpec* vs);
|
||||
|
||||
/// Post a constraint specified by \a ce
|
||||
void postConstraints(std::vector<ConExpr*>& ces);
|
||||
|
||||
/// Post the solve item
|
||||
void solve(AST::Array* annotation);
|
||||
/// Post that integer variable \a var should be minimized
|
||||
void minimize(int var, bool isInt, AST::Array* annotation);
|
||||
/// Post that integer variable \a var should be maximized
|
||||
void maximize(int var, bool isInt, AST::Array* annotation);
|
||||
|
||||
/// Run the search
|
||||
void run(std::ostream& out, const Printer& p,
|
||||
const FlatZincOptions& opt, Gecode::Support::Timer& t_total);
|
||||
|
||||
/// Produce output on \a out using \a p
|
||||
void print(std::ostream& out, const Printer& p) const;
|
||||
|
||||
/// Compare this space with space \a s and print the differences on
|
||||
/// \a out
|
||||
void compare(const Space& s, std::ostream& out) const;
|
||||
/// Compare this space with space \a s and print the differences on
|
||||
/// \a out using \a p
|
||||
void compare(const FlatZincSpace& s, std::ostream& out,
|
||||
const Printer& p) const;
|
||||
|
||||
/**
|
||||
* \brief Remove all variables not needed for output
|
||||
*
|
||||
* After calling this function, no new constraints can be posted through
|
||||
* FlatZinc variable references, and the createBranchers method must
|
||||
* not be called again.
|
||||
*
|
||||
*/
|
||||
void shrinkArrays(Printer& p);
|
||||
|
||||
/// Return whether to solve a satisfaction or optimization problem
|
||||
Meth method(void) const;
|
||||
|
||||
/// Return index of variable used for optimization
|
||||
int optVar(void) const;
|
||||
/// Return whether variable used for optimization is integer (or float)
|
||||
bool optVarIsInt(void) const;
|
||||
|
||||
/**
|
||||
* \brief Create branchers corresponding to the solve item annotations
|
||||
*
|
||||
* If \a ignoreUnknown is true, unknown solve item annotations will be
|
||||
* ignored, otherwise a warning is written to \a err.
|
||||
*
|
||||
* The seed for random branchers is given by the \a seed parameter.
|
||||
*
|
||||
*/
|
||||
void createBranchers(AST::Node* ann,
|
||||
int seed, double decay,
|
||||
bool ignoreUnknown,
|
||||
std::ostream& err = std::cerr);
|
||||
|
||||
/// Return the solve item annotations
|
||||
AST::Array* solveAnnotations(void) const;
|
||||
|
||||
/// Information for printing branches
|
||||
BranchInformation branchInfo;
|
||||
|
||||
/// Implement optimization
|
||||
virtual void constrain(const Space& s);
|
||||
/// Copy function
|
||||
virtual Gecode::Space* copy(bool share);
|
||||
|
||||
/// \name AST to variable and value conversion
|
||||
//@{
|
||||
/// Convert \a arg (array of integers) to IntArgs
|
||||
IntArgs arg2intargs(AST::Node* arg, int offset = 0);
|
||||
/// Convert \a arg (array of Booleans) to IntArgs
|
||||
IntArgs arg2boolargs(AST::Node* arg, int offset = 0);
|
||||
/// Convert \a n to IntSet
|
||||
IntSet arg2intset(AST::Node* n);
|
||||
/// Convert \a arg to IntSetArgs
|
||||
IntSetArgs arg2intsetargs(AST::Node* arg, int offset = 0);
|
||||
/// Convert \a arg to IntVarArgs
|
||||
IntVarArgs arg2intvarargs(AST::Node* arg, int offset = 0);
|
||||
/// Convert \a arg to BoolVarArgs
|
||||
BoolVarArgs arg2boolvarargs(AST::Node* arg, int offset = 0, int siv=-1);
|
||||
/// Convert \a n to BoolVar
|
||||
BoolVar arg2BoolVar(AST::Node* n);
|
||||
/// Convert \a n to IntVar
|
||||
IntVar arg2IntVar(AST::Node* n);
|
||||
/// Check if \a b is array of Booleans (or has a single integer)
|
||||
bool isBoolArray(AST::Node* b, int& singleInt);
|
||||
#ifdef GECODE_HAS_SET_VARS
|
||||
/// Convert \a n to SetVar
|
||||
SetVar arg2SetVar(AST::Node* n);
|
||||
/// Convert \a n to SetVarArgs
|
||||
SetVarArgs arg2setvarargs(AST::Node* arg, int offset = 0, int doffset = 0,
|
||||
const IntSet& od=IntSet::empty);
|
||||
#endif
|
||||
#ifdef GECODE_HAS_FLOAT_VARS
|
||||
/// Convert \a n to FloatValArgs
|
||||
FloatValArgs arg2floatargs(AST::Node* arg, int offset = 0);
|
||||
/// Convert \a n to FloatVar
|
||||
FloatVar arg2FloatVar(AST::Node* n);
|
||||
/// Convert \a n to FloatVarArgs
|
||||
FloatVarArgs arg2floatvarargs(AST::Node* arg, int offset = 0);
|
||||
#endif
|
||||
/// Convert \a ann to IntConLevel
|
||||
IntConLevel ann2icl(AST::Node* ann);
|
||||
//@}
|
||||
};
|
||||
|
||||
/// %Exception class for %FlatZinc errors
|
||||
class GECODE_VTABLE_EXPORT Error {
|
||||
private:
|
||||
const std::string msg;
|
||||
public:
|
||||
Error(const std::string& where, const std::string& what)
|
||||
: msg(where+": "+what) {}
|
||||
const std::string& toString(void) const { return msg; }
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Parse FlatZinc file \a fileName into \a fzs and return it.
|
||||
*
|
||||
* Creates a new empty FlatZincSpace if \a fzs is NULL.
|
||||
*/
|
||||
GECODE_FLATZINC_EXPORT
|
||||
FlatZincSpace* parse(const std::string& fileName,
|
||||
Printer& p, std::ostream& err = std::cerr,
|
||||
FlatZincSpace* fzs=NULL);
|
||||
|
||||
/**
|
||||
* \brief Parse FlatZinc from \a is into \a fzs and return it.
|
||||
*
|
||||
* Creates a new empty FlatZincSpace if \a fzs is NULL.
|
||||
*/
|
||||
GECODE_FLATZINC_EXPORT
|
||||
FlatZincSpace* parse(std::istream& is,
|
||||
Printer& p, std::ostream& err = std::cerr,
|
||||
FlatZincSpace* fzs=NULL);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
// STATISTICS: flatzinc-any
|
||||
@@ -1,63 +0,0 @@
|
||||
Version 1.7 (?)
|
||||
* Fixed bug in grammar for annotation expressions
|
||||
* Added cumulative-constraint
|
||||
* Added MiniZinc Challenge-style options
|
||||
* More detailed statistics
|
||||
* Exit with error code when interpretation of FlatZinc fails
|
||||
* Fixed handling of arrays of par sets
|
||||
* Fixed array_set_element constraint
|
||||
* Added specializations for sum_pred and nvalue and fixed exactly_int
|
||||
* Fixed output for problems that have no solution
|
||||
Version 1.6 (2009-05-21)
|
||||
* Adapted to changes in FlatZinc:
|
||||
- removed output items
|
||||
- added handling of output annotations
|
||||
- output in alphabetical order, and separate output for different solutions
|
||||
- support nested annotations, in particular the new search annotations
|
||||
- parse (and ignore) predicate declarations
|
||||
- split globals definitions into individual files
|
||||
* Replaced pkg-config based configuration with configure options
|
||||
for finding the Gecode installation
|
||||
* Do not require Gist (and detect it automatically)
|
||||
* Support for parallel (multi-threaded) search
|
||||
|
||||
Version 1.5 (released 2009-03-24)
|
||||
* The command line option -mode gist now behaves as advertised
|
||||
|
||||
Version 1.4 (released 2009-03-13)
|
||||
* Updated to compile with Gecode 3.0.0
|
||||
* Fixed conditional output items
|
||||
* Print variables as required by the upcoming FlatZinc specification
|
||||
|
||||
Version 1.3 (released 2008-08-26)
|
||||
* Can be compiled without support for set variables (if not present in
|
||||
Gecode)
|
||||
* Updated to new FlatZinc specification:
|
||||
- arrays start at index 1 now
|
||||
- var declarations can have initializers
|
||||
- conditional output using show_cond
|
||||
* Added array_bool_clause, regular, sort, inverse constraints
|
||||
* Fixed constraints introduced by sharing, e.g.
|
||||
var 0..3: x = 3; var 0..2: y = x;
|
||||
will result in failure
|
||||
* Fixed bug that caused initializers for array of var set to fail
|
||||
* Fixed int_div and int_mod
|
||||
* Use mmap where available to map input files directly to memory
|
||||
* Use specialized Boolean linear propagators in globals library
|
||||
|
||||
Version 1.2.1 (released 2008-03-06)
|
||||
* Small fixes in the build system (support for static libraries,
|
||||
better support for Mac OS X universal binaries)
|
||||
|
||||
Version 1.2 (released 2008-02-29)
|
||||
* Updated to compile with Gecode 2.1.0
|
||||
|
||||
Version 1.1 (released 2008-02-13)
|
||||
* Added support for constant declarations (like int: a=3;)
|
||||
* New constraints required by FlatZinc specification (mostly int_lin_*)
|
||||
* More verbose error reports
|
||||
* Accept carriage return (Windows end-of-line)
|
||||
* Fixed bug in output of Boolean variables
|
||||
|
||||
Version 1.0 (released 2007-11-15)
|
||||
* initial release
|
||||
@@ -1,534 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2007
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GECODE_FLATZINC_AST_HH__
|
||||
#define __GECODE_FLATZINC_AST_HH__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
/**
|
||||
* \namespace Gecode::FlatZinc::AST
|
||||
* \brief Abstract syntax trees for the %FlatZinc interpreter
|
||||
*/
|
||||
|
||||
namespace Gecode { namespace FlatZinc { namespace AST {
|
||||
|
||||
class Call;
|
||||
class Array;
|
||||
class Atom;
|
||||
class SetLit;
|
||||
|
||||
/// %Exception signaling type error
|
||||
class GECODE_VTABLE_EXPORT TypeError {
|
||||
private:
|
||||
std::string _what;
|
||||
public:
|
||||
TypeError() : _what("") {}
|
||||
TypeError(std::string what) : _what(what) {}
|
||||
std::string what(void) const { return _what; }
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief A node in a %FlatZinc abstract syntax tree
|
||||
*/
|
||||
class GECODE_VTABLE_EXPORT Node {
|
||||
public:
|
||||
/// Destructor
|
||||
virtual ~Node(void);
|
||||
|
||||
/// Append \a n to an array node
|
||||
void append(Node* n);
|
||||
|
||||
/// Test if node has atom with \a id
|
||||
bool hasAtom(const std::string& id);
|
||||
/// Test if node is int, if yes set \a i to the value
|
||||
bool isInt(int& i);
|
||||
/// Test if node is float, if yes set \a d to the value
|
||||
bool isFloat(double& i);
|
||||
/// Test if node is function call with \a id
|
||||
bool isCall(const std::string& id);
|
||||
/// Return function call
|
||||
Call* getCall(void);
|
||||
/// Test if node is function call or array containing function call \a id
|
||||
bool hasCall(const std::string& id);
|
||||
/// Return function call \a id
|
||||
Call* getCall(const std::string& id);
|
||||
/// Cast this node to an array node
|
||||
Array* getArray(void);
|
||||
/// Cast this node to an Atom node
|
||||
Atom* getAtom(void);
|
||||
/// Return name of variable represented by this node
|
||||
std::string getVarName(void);
|
||||
/// Cast this node to an integer variable node
|
||||
int getIntVar(void);
|
||||
/// Cast this node to a Boolean variable node
|
||||
int getBoolVar(void);
|
||||
/// Cast this node to a Float variable node
|
||||
int getFloatVar(void);
|
||||
/// Cast this node to a set variable node
|
||||
int getSetVar(void);
|
||||
|
||||
/// Cast this node to an integer node
|
||||
int getInt(void);
|
||||
/// Cast this node to a Boolean node
|
||||
bool getBool(void);
|
||||
/// Cast this node to a Float node
|
||||
double getFloat(void);
|
||||
/// Cast this node to a set literal node
|
||||
SetLit *getSet(void);
|
||||
|
||||
/// Cast this node to a string node
|
||||
std::string getString(void);
|
||||
|
||||
/// Test if node is an integer variable node
|
||||
bool isIntVar(void);
|
||||
/// Test if node is a Boolean variable node
|
||||
bool isBoolVar(void);
|
||||
/// Test if node is a set variable node
|
||||
bool isSetVar(void);
|
||||
/// Test if node is a float variable node
|
||||
bool isFloatVar(void);
|
||||
/// Test if node is an integer node
|
||||
bool isInt(void);
|
||||
/// Test if node is a float node
|
||||
bool isFloat(void);
|
||||
/// Test if node is a Boolean node
|
||||
bool isBool(void);
|
||||
/// Test if node is a string node
|
||||
bool isString(void);
|
||||
/// Test if node is an array node
|
||||
bool isArray(void);
|
||||
/// Test if node is a set literal node
|
||||
bool isSet(void);
|
||||
/// Test if node is an atom node
|
||||
bool isAtom(void);
|
||||
|
||||
/// Output string representation
|
||||
virtual void print(std::ostream&) = 0;
|
||||
};
|
||||
|
||||
/// Boolean literal node
|
||||
class GECODE_VTABLE_EXPORT BoolLit : public Node {
|
||||
public:
|
||||
bool b;
|
||||
BoolLit(bool b0) : b(b0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "b(" << (b ? "true" : "false") << ")";
|
||||
}
|
||||
};
|
||||
/// Integer literal node
|
||||
class GECODE_VTABLE_EXPORT IntLit : public Node {
|
||||
public:
|
||||
int i;
|
||||
IntLit(int i0) : i(i0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "i("<<i<<")";
|
||||
}
|
||||
};
|
||||
/// Float literal node
|
||||
class GECODE_VTABLE_EXPORT FloatLit : public Node {
|
||||
public:
|
||||
double d;
|
||||
FloatLit(double d0) : d(d0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "f("<<d<<")";
|
||||
}
|
||||
};
|
||||
/// %Set literal node
|
||||
class GECODE_VTABLE_EXPORT SetLit : public Node {
|
||||
public:
|
||||
bool interval;
|
||||
int min; int max;
|
||||
std::vector<int> s;
|
||||
SetLit(void) {}
|
||||
SetLit(int min0, int max0) : interval(true), min(min0), max(max0) {}
|
||||
SetLit(const std::vector<int>& s0) : interval(false), s(s0) {}
|
||||
bool empty(void) const {
|
||||
return ( (interval && min>max) || (!interval && s.size() == 0));
|
||||
}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "s()";
|
||||
}
|
||||
};
|
||||
|
||||
/// Variable node base class
|
||||
class GECODE_VTABLE_EXPORT Var : public Node {
|
||||
public:
|
||||
int i; //< Index
|
||||
std::string n; //< Name
|
||||
/// Constructor
|
||||
Var(int i0, const std::string& n0) : i(i0), n(n0) {}
|
||||
};
|
||||
/// Boolean variable node
|
||||
class GECODE_VTABLE_EXPORT BoolVar : public Var {
|
||||
public:
|
||||
/// Constructor
|
||||
BoolVar(int i0, const std::string& n0="") : Var(i0,n0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "xb("<<i<<")";
|
||||
}
|
||||
};
|
||||
/// Integer variable node
|
||||
class GECODE_VTABLE_EXPORT IntVar : public Var {
|
||||
public:
|
||||
IntVar(int i0, const std::string& n0="") : Var(i0,n0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "xi("<<i<<")";
|
||||
}
|
||||
};
|
||||
/// Float variable node
|
||||
class GECODE_VTABLE_EXPORT FloatVar : public Var {
|
||||
public:
|
||||
FloatVar(int i0, const std::string& n0="") : Var(i0,n0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "xf("<<i<<")";
|
||||
}
|
||||
};
|
||||
/// %Set variable node
|
||||
class GECODE_VTABLE_EXPORT SetVar : public Var {
|
||||
public:
|
||||
SetVar(int i0, const std::string& n0="") : Var(i0,n0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "xs("<<i<<")";
|
||||
}
|
||||
};
|
||||
|
||||
/// %Array node
|
||||
class GECODE_VTABLE_EXPORT Array : public Node {
|
||||
public:
|
||||
std::vector<Node*> a;
|
||||
Array(const std::vector<Node*>& a0)
|
||||
: a(a0) {}
|
||||
Array(Node* n)
|
||||
: a(1) { a[0] = n; }
|
||||
Array(int n=0) : a(n) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "[";
|
||||
for (unsigned int i=0; i<a.size(); i++) {
|
||||
a[i]->print(os);
|
||||
if (i<a.size()-1)
|
||||
os << ", ";
|
||||
}
|
||||
os << "]";
|
||||
}
|
||||
~Array(void) {
|
||||
for (int i=a.size(); i--;)
|
||||
delete a[i];
|
||||
}
|
||||
};
|
||||
|
||||
/// %Node representing a function call
|
||||
class GECODE_VTABLE_EXPORT Call : public Node {
|
||||
public:
|
||||
std::string id;
|
||||
Node* args;
|
||||
Call(const std::string& id0, Node* args0)
|
||||
: id(id0), args(args0) {}
|
||||
~Call(void) { delete args; }
|
||||
virtual void print(std::ostream& os) {
|
||||
os << id << "("; args->print(os); os << ")";
|
||||
}
|
||||
Array* getArgs(unsigned int n) {
|
||||
Array *a = args->getArray();
|
||||
if (a->a.size() != n)
|
||||
throw TypeError("arity mismatch");
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
/// %Node representing an array access
|
||||
class GECODE_VTABLE_EXPORT ArrayAccess : public Node {
|
||||
public:
|
||||
Node* a;
|
||||
Node* idx;
|
||||
ArrayAccess(Node* a0, Node* idx0)
|
||||
: a(a0), idx(idx0) {}
|
||||
~ArrayAccess(void) { delete a; delete idx; }
|
||||
virtual void print(std::ostream& os) {
|
||||
a->print(os);
|
||||
os << "[";
|
||||
idx->print(os);
|
||||
os << "]";
|
||||
}
|
||||
};
|
||||
|
||||
/// %Node representing an atom
|
||||
class GECODE_VTABLE_EXPORT Atom : public Node {
|
||||
public:
|
||||
std::string id;
|
||||
Atom(const std::string& id0) : id(id0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << id;
|
||||
}
|
||||
};
|
||||
|
||||
/// %String node
|
||||
class GECODE_VTABLE_EXPORT String : public Node {
|
||||
public:
|
||||
std::string s;
|
||||
String(const std::string& s0) : s(s0) {}
|
||||
virtual void print(std::ostream& os) {
|
||||
os << "s(\"" << s << "\")";
|
||||
}
|
||||
};
|
||||
|
||||
inline
|
||||
Node::~Node(void) {}
|
||||
|
||||
inline void
|
||||
Node::append(Node* newNode) {
|
||||
Array* a = dynamic_cast<Array*>(this);
|
||||
if (!a)
|
||||
throw TypeError("array expected");
|
||||
a->a.push_back(newNode);
|
||||
}
|
||||
|
||||
inline bool
|
||||
Node::hasAtom(const std::string& id) {
|
||||
if (Array* a = dynamic_cast<Array*>(this)) {
|
||||
for (int i=a->a.size(); i--;)
|
||||
if (Atom* at = dynamic_cast<Atom*>(a->a[i]))
|
||||
if (at->id == id)
|
||||
return true;
|
||||
} else if (Atom* a = dynamic_cast<Atom*>(this)) {
|
||||
return a->id == id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool
|
||||
Node::isCall(const std::string& id) {
|
||||
if (Call* a = dynamic_cast<Call*>(this)) {
|
||||
if (a->id == id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline Call*
|
||||
Node::getCall(void) {
|
||||
if (Call* a = dynamic_cast<Call*>(this))
|
||||
return a;
|
||||
throw TypeError("call expected");
|
||||
}
|
||||
|
||||
inline bool
|
||||
Node::hasCall(const std::string& id) {
|
||||
if (Array* a = dynamic_cast<Array*>(this)) {
|
||||
for (int i=a->a.size(); i--;)
|
||||
if (Call* at = dynamic_cast<Call*>(a->a[i]))
|
||||
if (at->id == id) {
|
||||
return true;
|
||||
}
|
||||
} else if (Call* a = dynamic_cast<Call*>(this)) {
|
||||
return a->id == id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool
|
||||
Node::isInt(int& i) {
|
||||
if (IntLit* il = dynamic_cast<IntLit*>(this)) {
|
||||
i = il->i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool
|
||||
Node::isFloat(double& d) {
|
||||
if (FloatLit* fl = dynamic_cast<FloatLit*>(this)) {
|
||||
d = fl->d;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline Call*
|
||||
Node::getCall(const std::string& id) {
|
||||
if (Array* a = dynamic_cast<Array*>(this)) {
|
||||
for (int i=a->a.size(); i--;)
|
||||
if (Call* at = dynamic_cast<Call*>(a->a[i]))
|
||||
if (at->id == id)
|
||||
return at;
|
||||
} else if (Call* a = dynamic_cast<Call*>(this)) {
|
||||
if (a->id == id)
|
||||
return a;
|
||||
}
|
||||
throw TypeError("call expected");
|
||||
}
|
||||
|
||||
inline Array*
|
||||
Node::getArray(void) {
|
||||
if (Array* a = dynamic_cast<Array*>(this))
|
||||
return a;
|
||||
throw TypeError("array expected");
|
||||
}
|
||||
|
||||
inline Atom*
|
||||
Node::getAtom(void) {
|
||||
if (Atom* a = dynamic_cast<Atom*>(this))
|
||||
return a;
|
||||
throw TypeError("atom expected");
|
||||
}
|
||||
|
||||
inline std::string
|
||||
Node::getVarName(void) {
|
||||
if (Var* a = dynamic_cast<Var*>(this))
|
||||
return a->n;
|
||||
throw TypeError("variable expected");
|
||||
}
|
||||
inline int
|
||||
Node::getIntVar(void) {
|
||||
if (IntVar* a = dynamic_cast<IntVar*>(this))
|
||||
return a->i;
|
||||
throw TypeError("integer variable expected");
|
||||
}
|
||||
inline int
|
||||
Node::getBoolVar(void) {
|
||||
if (BoolVar* a = dynamic_cast<BoolVar*>(this))
|
||||
return a->i;
|
||||
throw TypeError("bool variable expected");
|
||||
}
|
||||
inline int
|
||||
Node::getFloatVar(void) {
|
||||
if (FloatVar* a = dynamic_cast<FloatVar*>(this))
|
||||
return a->i;
|
||||
throw TypeError("integer variable expected");
|
||||
}
|
||||
inline int
|
||||
Node::getSetVar(void) {
|
||||
if (SetVar* a = dynamic_cast<SetVar*>(this))
|
||||
return a->i;
|
||||
throw TypeError("set variable expected");
|
||||
}
|
||||
inline int
|
||||
Node::getInt(void) {
|
||||
if (IntLit* a = dynamic_cast<IntLit*>(this))
|
||||
return a->i;
|
||||
throw TypeError("integer literal expected");
|
||||
}
|
||||
inline bool
|
||||
Node::getBool(void) {
|
||||
if (BoolLit* a = dynamic_cast<BoolLit*>(this))
|
||||
return a->b;
|
||||
throw TypeError("bool literal expected");
|
||||
}
|
||||
inline double
|
||||
Node::getFloat(void) {
|
||||
if (FloatLit* a = dynamic_cast<FloatLit*>(this))
|
||||
return a->d;
|
||||
throw TypeError("float literal expected");
|
||||
}
|
||||
inline SetLit*
|
||||
Node::getSet(void) {
|
||||
if (SetLit* a = dynamic_cast<SetLit*>(this))
|
||||
return a;
|
||||
throw TypeError("set literal expected");
|
||||
}
|
||||
inline std::string
|
||||
Node::getString(void) {
|
||||
if (String* a = dynamic_cast<String*>(this))
|
||||
return a->s;
|
||||
throw TypeError("string literal expected");
|
||||
}
|
||||
inline bool
|
||||
Node::isIntVar(void) {
|
||||
return (dynamic_cast<IntVar*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isBoolVar(void) {
|
||||
return (dynamic_cast<BoolVar*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isSetVar(void) {
|
||||
return (dynamic_cast<SetVar*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isFloatVar(void) {
|
||||
return (dynamic_cast<FloatVar*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isInt(void) {
|
||||
return (dynamic_cast<IntLit*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isBool(void) {
|
||||
return (dynamic_cast<BoolLit*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isFloat(void) {
|
||||
return (dynamic_cast<FloatLit*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isSet(void) {
|
||||
return (dynamic_cast<SetLit*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isString(void) {
|
||||
return (dynamic_cast<String*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isArray(void) {
|
||||
return (dynamic_cast<Array*>(this) != NULL);
|
||||
}
|
||||
inline bool
|
||||
Node::isAtom(void) {
|
||||
return (dynamic_cast<Atom*>(this) != NULL);
|
||||
}
|
||||
|
||||
inline Node*
|
||||
extractSingleton(Node* n) {
|
||||
if (Array* a = dynamic_cast<Array*>(n)) {
|
||||
if (a->a.size() == 1) {
|
||||
Node *ret = a->a[0];
|
||||
a->a[0] = NULL;
|
||||
delete a;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
// STATISTICS: flatzinc-any
|
||||
@@ -1,85 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2007
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GECODE_FLATZINC_CONEXPR_HH__
|
||||
#define __GECODE_FLATZINC_CONEXPR_HH__
|
||||
|
||||
#include <string>
|
||||
#include <gecode/flatzinc/ast.hh>
|
||||
|
||||
namespace Gecode { namespace FlatZinc {
|
||||
|
||||
/// Abstract representation of a constraint
|
||||
class ConExpr {
|
||||
public:
|
||||
/// Identifier for the constraint
|
||||
std::string id;
|
||||
/// Constraint arguments
|
||||
AST::Array* args;
|
||||
/// Constraint annotations
|
||||
AST::Array* ann;
|
||||
/// Constructor
|
||||
ConExpr(const std::string& id0, AST::Array* args0, AST::Array* ann0);
|
||||
/// Return argument \a i
|
||||
AST::Node* operator[](int i) const;
|
||||
/// Return number of arguments
|
||||
int size(void) const;
|
||||
/// Destructor
|
||||
~ConExpr(void);
|
||||
};
|
||||
|
||||
forceinline
|
||||
ConExpr::ConExpr(const std::string& id0, AST::Array* args0, AST::Array* ann0)
|
||||
: id(id0), args(args0), ann(ann0) {}
|
||||
|
||||
forceinline AST::Node*
|
||||
ConExpr::operator[](int i) const { return args->a[i]; }
|
||||
|
||||
forceinline int
|
||||
ConExpr::size(void) const { return args->a.size(); }
|
||||
|
||||
forceinline
|
||||
ConExpr::~ConExpr(void) {
|
||||
delete args;
|
||||
delete ann;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
// STATISTICS: flatzinc-any
|
||||
@@ -1,49 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2010
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "myplugin.hh"
|
||||
|
||||
void MyPlugin::branch(Gecode::FlatZinc::FlatZincSpace& s,
|
||||
Gecode::FlatZinc::AST::Call* c) {
|
||||
std::cerr << "MyPlugin::branch ";
|
||||
c->print(std::cerr);
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(myplugin, MyPlugin)
|
||||
@@ -1,47 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2010
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gecode/flatzinc.hh>
|
||||
#include <gecode/flatzinc/plugin.hh>
|
||||
|
||||
class MyPlugin : public QObject, public Gecode::FlatZinc::BranchPlugin {
|
||||
public:
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(Gecode::FlatZinc::BranchPlugin)
|
||||
virtual void branch(Gecode::FlatZinc::FlatZincSpace& s,
|
||||
Gecode::FlatZinc::AST::Call* c);
|
||||
};
|
||||
@@ -1,51 +0,0 @@
|
||||
#
|
||||
# Main authors:
|
||||
# Guido Tack <tack@gecode.org>
|
||||
#
|
||||
# Copyright:
|
||||
# Guido Tack, 2010
|
||||
#
|
||||
# Last modified:
|
||||
# $Date$ by $Author$
|
||||
# $Revision$
|
||||
#
|
||||
# This file is part of Gecode, the generic constraint
|
||||
# development environment:
|
||||
# http://www.gecode.org
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
#
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin release x86_64
|
||||
INCLUDEPATH += ../../..
|
||||
HEADERS = myplugin.hh
|
||||
SOURCES = myplugin.cpp
|
||||
TARGET = myplugin
|
||||
win32:DESTDIR = ./
|
||||
LIBS += -L../../..
|
||||
macx {
|
||||
LIBS += -framework gecode
|
||||
}
|
||||
unix {
|
||||
!macx {
|
||||
LIBS += -lgecodekernel -lgecodesupport -lgecodeint -lgecodescheduling -lgecodegraph -lgecodeminimodel -lgecodedriver -lgecodesearch -lgecodeflatzinc
|
||||
}}
|
||||
@@ -1 +0,0 @@
|
||||
solve ::gecode_search(myplugin(1,2,3)) satisfy;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,137 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2007
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
%option reentrant
|
||||
%option bison-bridge
|
||||
%option noyywrap
|
||||
%option yylineno
|
||||
|
||||
%{
|
||||
#if defined __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#elif defined _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
#endif
|
||||
|
||||
void yyerror(void*, const char*);
|
||||
#define yyerror(s) yyerror(yyextra, s)
|
||||
|
||||
#include <gecode/flatzinc/parser.hh>
|
||||
|
||||
const char* stringbuf;
|
||||
int stringbuflen;
|
||||
int stringbufpos;
|
||||
|
||||
int yy_input_proc(char* buf, int size, yyscan_t yyscanner);
|
||||
#define YY_INPUT(buf, result, max_size) \
|
||||
result = yy_input_proc(buf, max_size, yyscanner);
|
||||
%}
|
||||
|
||||
%%
|
||||
|
||||
\n { /*yylineno++;*/ /* ignore EOL */ }
|
||||
[ \t\r] { /* ignore whitespace */ }
|
||||
%.* { /* ignore comments */ }
|
||||
|
||||
"true" { yylval->iValue = 1; return FZ_BOOL_LIT; }
|
||||
"false" { yylval->iValue = 0; return FZ_BOOL_LIT; }
|
||||
-?[0-9]+ { yylval->iValue = atoi(yytext); return FZ_INT_LIT; }
|
||||
-?0x[0-9A-Fa-f]+ { yylval->iValue = atoi(yytext); return FZ_INT_LIT; }
|
||||
-?0o[0-7]+ { yylval->iValue = atoi(yytext); return FZ_INT_LIT; }
|
||||
-?[0-9]+\.[0-9]+ { yylval->dValue = strtod(yytext,NULL);
|
||||
return FZ_FLOAT_LIT; }
|
||||
-?[0-9]+\.[0-9]+[Ee][+-]?[0-9]+ { yylval->dValue = strtod(yytext,NULL);
|
||||
return FZ_FLOAT_LIT; }
|
||||
-?[0-9]+[Ee][+-]?[0-9]+ { yylval->dValue = strtod(yytext,NULL);
|
||||
return FZ_FLOAT_LIT; }
|
||||
[=:;{}(),\[\]\.] { return *yytext; }
|
||||
\.\. { return FZ_DOTDOT; }
|
||||
:: { return FZ_COLONCOLON; }
|
||||
"annotation" { return FZ_ANNOTATION; }
|
||||
"any" { return FZ_ANY; }
|
||||
"array" { return FZ_ARRAY; }
|
||||
"bool" { return FZ_BOOL; }
|
||||
"case" { return FZ_CASE; }
|
||||
"constraint" { return FZ_CONSTRAINT; }
|
||||
"default" { return FZ_DEFAULT; }
|
||||
"else" { return FZ_ELSE; }
|
||||
"elseif" { return FZ_ELSEIF; }
|
||||
"endif" { return FZ_ENDIF; }
|
||||
"enum" { return FZ_ENUM; }
|
||||
"float" { return FZ_FLOAT; }
|
||||
"function" { return FZ_FUNCTION; }
|
||||
"if" { return FZ_IF; }
|
||||
"include" { return FZ_INCLUDE; }
|
||||
"int" { return FZ_INT; }
|
||||
"let" { return FZ_LET; }
|
||||
"maximize" { yylval->bValue = false; return FZ_MAXIMIZE; }
|
||||
"minimize" { yylval->bValue = true; return FZ_MINIMIZE; }
|
||||
"of" { return FZ_OF; }
|
||||
"satisfy" { return FZ_SATISFY; }
|
||||
"output" { return FZ_OUTPUT; }
|
||||
"par" { yylval->bValue = false; return FZ_PAR; }
|
||||
"predicate" { return FZ_PREDICATE; }
|
||||
"record" { return FZ_RECORD; }
|
||||
"set" { return FZ_SET; }
|
||||
"show_cond" { return FZ_SHOWCOND; }
|
||||
"show" { return FZ_SHOW; }
|
||||
"solve" { return FZ_SOLVE; }
|
||||
"string" { return FZ_STRING; }
|
||||
"test" { return FZ_TEST; }
|
||||
"then" { return FZ_THEN; }
|
||||
"tuple" { return FZ_TUPLE; }
|
||||
"type" { return FZ_TYPE; }
|
||||
"var" { yylval->bValue = true; return FZ_VAR; }
|
||||
"variant_record" { return FZ_VARIANT_RECORD; }
|
||||
"where" { return FZ_WHERE; }
|
||||
[A-Za-z][A-Za-z0-9_]* { yylval->sValue = strdup(yytext); return FZ_ID; }
|
||||
_[_]*[A-Za-z][A-Za-z0-9_]* { yylval->sValue = strdup(yytext); return FZ_U_ID; }
|
||||
\"[^"\n]*\" {
|
||||
yylval->sValue = strdup(yytext+1);
|
||||
yylval->sValue[strlen(yytext)-2] = 0;
|
||||
return FZ_STRING_LIT; }
|
||||
. { yyerror("Unknown character"); }
|
||||
%%
|
||||
int yy_input_proc(char* buf, int size, yyscan_t yyscanner) {
|
||||
Gecode::FlatZinc::ParserState* parm =
|
||||
static_cast<Gecode::FlatZinc::ParserState*>(yyget_extra(yyscanner));
|
||||
return parm->fillBuffer(buf, size);
|
||||
// work around warning that yyunput is unused
|
||||
yyunput (0,buf,yyscanner);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate all_different_int(array[int] of var int: x);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate all_equal_int(array[int] of var int: x);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate among(var int: n, array[int] of var int: x, set of int: v);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate at_least_int(int: n, array[int] of var int: x, int: v);
|
||||
@@ -1,38 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate at_least_set(int: n, array[int] of var set of int: x, set of int: v) =
|
||||
bool_sum_ge([x[i] == v | i in index_set(x)], n);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate at_most_int(int: n, array[int] of var int: x, int: v);
|
||||
@@ -1,38 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate at_most_set(int: n, array[int] of var set of int: x, set of int: v) =
|
||||
bool_sum_le([x[i] == v | i in index_set(x)], n);
|
||||
@@ -1,46 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2010
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
include "bin_packing_capa.mzn";
|
||||
|
||||
predicate bin_packing(int: c,
|
||||
array[int] of var int: bin,
|
||||
array[int] of int: w) =
|
||||
let {
|
||||
set of int: idx = lb_array(bin)..ub_array(bin),
|
||||
array[idx] of int: capa = array1d(idx, [c|i in idx])
|
||||
} in
|
||||
bin_packing_capa(capa,bin,w);
|
||||
@@ -1,47 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2010
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
include "bin_packing_load.mzn";
|
||||
|
||||
predicate bin_packing_capa(array[int] of int: c,
|
||||
array[int] of var int: bin,
|
||||
array[int] of int: w) =
|
||||
let {
|
||||
array[min(index_set(c))..max(index_set(c))] of var 0..ub_array(c): l
|
||||
} in (
|
||||
forall( i in index_set(l) ) ( l[i] <= c[i] )
|
||||
/\ bin_packing_load(l,bin,w)
|
||||
);
|
||||
@@ -1,45 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2010
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate gecode_bin_packing_load(array[int] of var int: l,
|
||||
array[int] of var int: bin,
|
||||
array[int] of int: w,
|
||||
int: minIndex);
|
||||
|
||||
predicate bin_packing_load(array[int] of var int: l,
|
||||
array[int] of var int: bin,
|
||||
array[int] of int: w) =
|
||||
gecode_bin_packing_load(l,bin,w,min(index_set(l)));
|
||||
@@ -1,44 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate gecode_circuit(int: offset, array[int] of var int: x);
|
||||
|
||||
predicate circuit(array[int] of var int: x) =
|
||||
if min(index_set(x)) >= 0 then
|
||||
gecode_circuit(min(index_set(x)),x)
|
||||
else
|
||||
gecode_circuit(0,[x[i]-min(index_set(x)) | i in index_set(x)])
|
||||
endif;
|
||||
@@ -1,40 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate count(array[int] of var int: x, var int: y, var int: c);
|
||||
|
||||
predicate count_reif(array[int] of var int: x, var int: y, var int: c,
|
||||
var bool: b);
|
||||
@@ -1,53 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
% Mikael lagerkvist <lagerkvist@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
% Mikael Lagerkvist, 2009
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate cumulative(array[int] of var int: s,
|
||||
array[int] of var int: d,
|
||||
array[int] of var int: r, var int: b) =
|
||||
assert(index_set(s) == index_set(d) /\ index_set(s) == index_set(r),
|
||||
"cumulative: the 3 array arguments must have identical index sets",
|
||||
assert(lb_array(d) >= 0 /\ lb_array(r) >= 0,
|
||||
"cumulative: durations and resource usages must be non-negative",
|
||||
cumulatives(s, d, r, b)
|
||||
)
|
||||
);
|
||||
|
||||
% Specialized cumulatives propagator is only for fixed bounds
|
||||
predicate cumulatives(array[int] of var int: s,
|
||||
array[int] of var int: d,
|
||||
array[int] of var int: r, var int: b);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate decreasing_bool(array[int] of var bool: x);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate decreasing_int(array[int] of var int: x);
|
||||
@@ -1,44 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
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);
|
||||
|
||||
predicate diffn(array[int] of var int: x,
|
||||
array[int] of var int: y,
|
||||
array[int] of var int: dx,
|
||||
array[int] of var int: dy) =
|
||||
gecode_nooverlap(x,dx,y,dy);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate disjoint(var set of int: s1, var set of int: s2);
|
||||
@@ -1,46 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate distribute(array[int] of var int: card,
|
||||
array[int] of var int: value,
|
||||
array[int] of var int: base) =
|
||||
assert(index_set(card) == index_set(value),
|
||||
"distribute: card and value arrays must have identical index sets",
|
||||
forall (i in index_set(card)) (
|
||||
bool_sum_eq([value[i] == base[j] | j in index_set(base)],
|
||||
card[i])
|
||||
)
|
||||
);
|
||||
@@ -1,40 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
include "count.mzn";
|
||||
|
||||
predicate exactly_int(int: n, array[int] of var int: x, int: v) =
|
||||
count(x, v, n);
|
||||
@@ -1,38 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate exactly_set(int: n, array[int] of var set of int: x, set of int: v) =
|
||||
bool_sum_eq([x[i] == v | i in index_set(x)], n);
|
||||
@@ -1,103 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
% This file contains predicate definitions for additional constraints available
|
||||
% in the Gecode FlatZinc interpreter.
|
||||
|
||||
% Additional search annotations
|
||||
annotation afc_min;
|
||||
annotation afc_size_min;
|
||||
annotation afc_max;
|
||||
annotation afc_size_max;
|
||||
annotation activity_min;
|
||||
annotation activity_size_min;
|
||||
annotation activity_max;
|
||||
annotation activity_size_max;
|
||||
annotation random;
|
||||
annotation int_assign(array[int] of var int: x, ann:a);
|
||||
|
||||
annotation int_default_search(ann: varsel, ann: valsel);
|
||||
annotation bool_default_search(ann: varsel, ann: valsel);
|
||||
annotation set_default_search(ann: varsel, ann: valsel);
|
||||
annotation float_default_search(ann: varsel, ann: valsel);
|
||||
|
||||
% i in z <-> forall (j in x) (i in y[j])
|
||||
predicate gecode_array_set_element_intersect(var set of int: x,
|
||||
array[int] of var set of int: y, var set of int: z);
|
||||
|
||||
% (i in z <-> exists (j in x) (i in y[j])) /\ (i in x /\ j in x /\ i!=j -> disjoint(y[i],y[j]))
|
||||
predicate gecode_array_set_element_partition(var set of int: x,
|
||||
array[int] of var set of int: y, var set of int: z);
|
||||
|
||||
% z subset u /\ ( i in z <-> forall (j in x) (i in y[j]) )
|
||||
predicate gecode_array_set_element_intersect_in(var set of int: x,
|
||||
array[int] of var set of int: y,
|
||||
var set of int: z, set of int: u);
|
||||
|
||||
% Every subsequence of x of length l has at least m and at most occurrences
|
||||
% of the values in S
|
||||
predicate gecode_among_seq_int(array[int] of var int: x, set of int: S,
|
||||
int: l, int: m, int: n);
|
||||
|
||||
% Every subsequence of x of length l has at least m and at most occurrences
|
||||
% of the value b
|
||||
predicate gecode_among_seq_bool(array[int] of var bool: x, bool: b,
|
||||
int: l, int: m, int: n);
|
||||
|
||||
% Overloading for among_seq
|
||||
predicate among_seq(array[int] of var int: x, set of int: S,
|
||||
int: l, int: m, int: n) = gecode_among_seq_int(x,S,l,m,n);
|
||||
predicate among_seq(array[int] of var bool: x, bool: b,
|
||||
int: l, int: m, int: n) = gecode_among_seq_bool(x,b,l,m,n);
|
||||
|
||||
% Circuit constraints
|
||||
predicate gecode_circuit_cost_array(array[int] of int: c,
|
||||
array[int] of var int: x, array[int] of var int: y, var int: z);
|
||||
predicate gecode_circuit_cost(array[int] of int: c, array[int] of var int: x,
|
||||
var int: z);
|
||||
|
||||
predicate circuit_cost_array(array[int] of int: c,
|
||||
array[int] of var int: x, array[int] of var int: y, var int: z) =
|
||||
gecode_circuit_cost_array(c,[x[i]-min(index_set(x)) | i in index_set(x)],
|
||||
y,z);
|
||||
predicate circuit_cost(array[int] of int: c, array[int] of var int: x,
|
||||
var int: z) =
|
||||
gecode_circuit_cost(c, [x[i]-min(index_set(x)) | i in index_set(x)], z);
|
||||
|
||||
% Scheduling constraints
|
||||
predicate gecode_schedule_unary(array[int] of var int: x, array[int] of int: p);
|
||||
predicate gecode_schedule_unary_optional(array[int] of var int: x,
|
||||
array[int] of int: p, array[int] of var bool: m);
|
||||
@@ -1,43 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate global_cardinality(array[int] of var int: x,
|
||||
array[int] of int: cover,
|
||||
array[int] of var int: counts);
|
||||
|
||||
predicate global_cardinality_old(array[int] of var int: x,
|
||||
array[int] of var int: c) =
|
||||
global_cardinality(x,[i|i in index_set(c)],c);
|
||||
@@ -1,39 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate global_cardinality_closed(array[int] of var int: x,
|
||||
array[int] of int: cover,
|
||||
array[int] of var int: counts);
|
||||
@@ -1,40 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
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);
|
||||
@@ -1,40 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
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);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate increasing_bool(array[int] of var bool: x);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate increasing_int(array[int] of var int: x);
|
||||
@@ -1,49 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate gecode_int_set_channel(array[int] of var int: x, int: xoff,
|
||||
array[int] of var set of int: y, int: yoff);
|
||||
|
||||
predicate int_set_channel(array[int] of var int: x,
|
||||
array[int] of var set of int: y) =
|
||||
if (min(index_set(x)) < 0 \/ min(index_set(y)) < 0) then
|
||||
forall(i in index_set(x)) (x[i] in index_set(y)) /\
|
||||
forall(j in index_set(y)) (y[j] subset index_set(x)) /\
|
||||
forall(i in index_set(x), j in index_set(y))
|
||||
(x[i]=j <-> i in y[j])
|
||||
else
|
||||
gecode_int_set_channel(x,min(index_set(x)),y,min(index_set(y)))
|
||||
endif;
|
||||
@@ -1,42 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate inverse_offsets(array[int] of var int: f, int: foff,
|
||||
array[int] of var int: invf, int: invfoff);
|
||||
|
||||
predicate inverse(array[int] of var int: f,
|
||||
array[int] of var int: invf) =
|
||||
inverse_offsets(f, min(index_set(invf)), invf, min(index_set(f)));
|
||||
@@ -1,53 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
predicate gecode_inverse_set(array[int] of var set of int: f,
|
||||
array[int] of var set of int: invf, int: xoff, int: yoff);
|
||||
|
||||
predicate inverse_set(array[int] of var set of int: f,
|
||||
array[int] of var set of int: invf) =
|
||||
forall(i in index_set(f)) (
|
||||
f[i] subset index_set(invf)
|
||||
) /\
|
||||
forall(j in index_set(invf)) (
|
||||
invf[j] subset index_set(f)
|
||||
) /\
|
||||
if (min(index_set(f)) >= 0 /\ min(index_set(invf)) >= 0) then
|
||||
gecode_inverse_set(f,invf,min(index_set(f)),min(index_set(invf)))
|
||||
else
|
||||
forall(i in index_set(f), j in index_set(invf)) (
|
||||
(j in f[i] <-> i in invf[j])
|
||||
)
|
||||
endif;
|
||||
@@ -1,42 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate array_bool_lt(array[int] of var bool: x,
|
||||
array[int] of var bool: y);
|
||||
|
||||
predicate lex_less_bool(array[int] of var bool: x,
|
||||
array[int] of var bool: y) =
|
||||
array_bool_lt(x,y);
|
||||
@@ -1,42 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate array_int_lt(array[int] of var int: x,
|
||||
array[int] of var int: y);
|
||||
|
||||
predicate lex_less_int(array[int] of var int: x,
|
||||
array[int] of var int: y) =
|
||||
array_int_lt(x,y);
|
||||
@@ -1,42 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate array_bool_lq(array[int] of var bool: x,
|
||||
array[int] of var bool: y);
|
||||
|
||||
predicate lex_lesseq_bool(array[int] of var bool: x,
|
||||
array[int] of var bool: y) =
|
||||
array_bool_lq(x,y);
|
||||
@@ -1,42 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate array_int_lq(array[int] of var int: x,
|
||||
array[int] of var int: y);
|
||||
|
||||
predicate lex_lesseq_int(array[int] of var int: x,
|
||||
array[int] of var int: y) =
|
||||
array_int_lq(x,y);
|
||||
@@ -1,47 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate gecode_link_set_to_booleans(var set of int: s, array[int] of var bool: b, int: idx);
|
||||
|
||||
predicate link_set_to_booleans(var set of int: s, array[int] of var bool: b) =
|
||||
assert(ub(s) subset index_set(b),
|
||||
"link_set_to_booleans: the index set of b must be a superset of the possible values of s",
|
||||
if min(index_set(b)) < 0 then
|
||||
forall(i in index_set(b)) ( b[i] <-> i in s )
|
||||
else
|
||||
gecode_link_set_to_booleans(s,b,min(index_set(b)))
|
||||
endif
|
||||
);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate maximum_int(var int: m, array[int] of var int: x);
|
||||
@@ -1,41 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate member_bool(array[int] of var bool: x, var bool: y);
|
||||
predicate gecode_member_bool_reif(array[int] of var bool: x, var bool: y,
|
||||
var bool: b);
|
||||
predicate member_bool_reif(array[int] of var bool: x, var bool: y,
|
||||
var bool: b) = gecode_member_bool_reif(x,y,b);
|
||||
@@ -1,41 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate member_int(array[int] of var int: x, var int: y);
|
||||
predicate gecode_member_int_reif(array[int] of var int: x, var int: y,
|
||||
var bool: b);
|
||||
predicate member_int_reif(array[int] of var int: x, var int: y,
|
||||
var bool: b) = gecode_member_int_reif(x,y,b);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate minimum_int(var int: m, array[int] of var int: x);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate nvalue(var int: n, array[int] of var int: x);
|
||||
@@ -1,42 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate array_set_partition(array[int] of var set of int: S,
|
||||
set of int: universe);
|
||||
|
||||
predicate partition_set(array[int] of var set of int: S,
|
||||
set of int: universe) =
|
||||
array_set_partition(S, universe);
|
||||
@@ -1,51 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
predicate gecode_range(array[int] of var int: x, int: xoff,
|
||||
var set of int: s, var set of int: t);
|
||||
|
||||
predicate range(array[int] of var int: x, var set of int: s,
|
||||
var set of int: t) =
|
||||
assert(ub(s) subset index_set(x),
|
||||
"range: upper bound of 's' must be a subset of the index set of 'x'",
|
||||
if (min(index_set(x)) >= 0) then
|
||||
gecode_range(x,min(index_set(x)),s,t)
|
||||
else
|
||||
forall(i in ub(s)) (i in s -> x[i] in t) /\
|
||||
forall(i in ub(t)) (
|
||||
i in t -> exists(j in ub(s)) ( j in s /\ x[j] == i )
|
||||
)
|
||||
endif
|
||||
);
|
||||
@@ -1,75 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
% Sums over Boolean variables
|
||||
predicate bool_lin_eq(array[int] of int: a, array[int] of var bool: x,
|
||||
var int: c);
|
||||
predicate bool_lin_ne(array[int] of int: a, array[int] of var bool: x,
|
||||
var int: c);
|
||||
predicate bool_lin_le(array[int] of int: a, array[int] of var bool: x,
|
||||
var int: c);
|
||||
predicate bool_lin_lt(array[int] of int: a, array[int] of var bool: x,
|
||||
var int: c);
|
||||
predicate bool_lin_ge(array[int] of int: a, array[int] of var bool: x,
|
||||
var int: c);
|
||||
predicate bool_lin_gt(array[int] of int: a, array[int] of var bool: x,
|
||||
var int: c);
|
||||
|
||||
predicate bool_sum_eq(array[int] of var bool: x, var int: c) =
|
||||
bool_lin_eq([1 | i in index_set(x)],x,c);
|
||||
predicate bool_sum_ne(array[int] of var bool: x, var int: c) =
|
||||
bool_lin_ne([1 | i in index_set(x)],x,c);
|
||||
predicate bool_sum_le(array[int] of var bool: x, var int: c) =
|
||||
bool_lin_le([1 | i in index_set(x)],x,c);
|
||||
predicate bool_sum_lt(array[int] of var bool: x, var int: c) =
|
||||
bool_lin_lt([1 | i in index_set(x)],x,c);
|
||||
predicate bool_sum_ge(array[int] of var bool: x, var int: c) =
|
||||
bool_lin_ge([1 | i in index_set(x)],x,c);
|
||||
predicate bool_sum_gt(array[int] of var bool: x, var int: c) =
|
||||
bool_lin_gt([1 | i in index_set(x)],x,c);
|
||||
|
||||
predicate float_sinh(var float: a, var float: b) =
|
||||
b == (exp(a)-exp(-a))/2.0;
|
||||
|
||||
predicate float_cosh(var float: a, var float: b) =
|
||||
b == (exp(a)+exp(-a))/2.0;
|
||||
|
||||
predicate float_tanh(var float: a, var float: b) =
|
||||
let { var float: e2a = exp(2.0*a) } in
|
||||
b == (e2a-1.0)/(e2a+1.0);
|
||||
|
||||
predicate float_ne_reif(var float: a, var float: b, var bool: c) =
|
||||
not c <-> a==b;
|
||||
@@ -1,38 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate regular(array[int] of var int: x, int: Q, int: S,
|
||||
array[int,int] of int: d, int: q0, set of int: F);
|
||||
@@ -1,63 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
include "int_set_channel.mzn";
|
||||
|
||||
% i in z <-> exists (j in x) (i in y[j])
|
||||
predicate gecode_array_set_element_union(var set of int: x,
|
||||
array[int] of var set of int: y, var set of int: z);
|
||||
|
||||
predicate roots(array[int] of var int: x, var set of int: s,
|
||||
var set of int: t) =
|
||||
assert(ub(s) subset index_set(x),
|
||||
"roots: upper bound of 's' must be a subset of the index set of 'x'",
|
||||
if (min(index_set(x)) < 0 \/ min(ub(t)) < 1) then
|
||||
% All values in 's' must map to a value in 't'.
|
||||
forall(i in ub(s)) (
|
||||
i in s -> x[i] in t
|
||||
) /\
|
||||
% All values in 't' must be mapped from a value in 's'.
|
||||
forall(i in ub(t)) (
|
||||
i in t -> forall(j in index_set(x)) (x[j] == i -> j in s)
|
||||
)
|
||||
else let {
|
||||
array[1..max(ub(t))] of var set of 0..max(index_set(x)): y,
|
||||
} in
|
||||
int_set_channel(x,y)
|
||||
/\
|
||||
gecode_array_set_element_union(t,y,s)
|
||||
endif
|
||||
);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate sort(array[int] of var int: x, array[int] of var int: y);
|
||||
@@ -1,42 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate gecode_set_weights(array[int] of int: csi,array[int] of int: cs,
|
||||
var set of int: x, var int: y);
|
||||
|
||||
predicate sum_pred(var int: i, array[int] of set of int: sets,
|
||||
array[int] of int: cs, var int: s) =
|
||||
gecode_set_weights([j|j in index_set(cs)],cs,sets[i],s);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate table_bool(array[int] of var bool: x, array[int, int] of bool: t);
|
||||
@@ -1,37 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate table_int(array[int] of var int: x, array[int, int] of int: t);
|
||||
@@ -1,40 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate gecode_precede(array[int] of var int: x, int: s, int: t);
|
||||
|
||||
predicate value_precede_int(int: s, int: t, array[int] of var int: x) =
|
||||
gecode_precede(x,s,t);
|
||||
@@ -1,40 +0,0 @@
|
||||
%
|
||||
% Main authors:
|
||||
% Guido Tack <tack@gecode.org>
|
||||
%
|
||||
% Copyright:
|
||||
% Guido Tack, 2007
|
||||
%
|
||||
% Last modified:
|
||||
% $Date$ by $Author$
|
||||
% $Revision$
|
||||
%
|
||||
% This file is part of Gecode, the generic constraint
|
||||
% development environment:
|
||||
% http://www.gecode.org
|
||||
%
|
||||
% Permission is hereby granted, free of charge, to any person obtaining
|
||||
% a copy of this software and associated documentation files (the
|
||||
% "Software"), to deal in the Software without restriction, including
|
||||
% without limitation the rights to use, copy, modify, merge, publish,
|
||||
% distribute, sublicense, and/or sell copies of the Software, and to
|
||||
% permit persons to whom the Software is furnished to do so, subject to
|
||||
% the following conditions:
|
||||
%
|
||||
% The above copyright notice and this permission notice shall be
|
||||
% included in all copies or substantial portions of the Software.
|
||||
%
|
||||
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
%
|
||||
%
|
||||
|
||||
predicate gecode_precede_set(array[int] of var set of int: x, int: s, int: t);
|
||||
|
||||
predicate value_precede_set(int: s, int: t, array[int] of var set of int: x) =
|
||||
gecode_precede_set(x,s,t);
|
||||
@@ -1,71 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2007
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __FLATZINC_OPTION_HH__
|
||||
#define __FLATZINC_OPTION_HH__
|
||||
|
||||
namespace Gecode { namespace FlatZinc {
|
||||
|
||||
/// Optional value
|
||||
template<class Val>
|
||||
struct Option {
|
||||
private:
|
||||
bool _some;
|
||||
Val _v;
|
||||
public:
|
||||
bool operator()(void) const { return _some; }
|
||||
const Val& some(void) const { return _v; }
|
||||
Val& some(void) { return _v; }
|
||||
static Option<Val> none(void) {
|
||||
Option<Val> o;
|
||||
o._some = false;
|
||||
new (&o._v) Val();
|
||||
return o;
|
||||
}
|
||||
static Option<Val> some(const Val& v) {
|
||||
Option<Val> o;
|
||||
o._some = true;
|
||||
o._v = v;
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
// STATISTICS: flatzinc-any
|
||||
@@ -1,262 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2007
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __FLATZINC_PARSER_HH__
|
||||
#define __FLATZINC_PARSER_HH__
|
||||
|
||||
#include <gecode/flatzinc.hh>
|
||||
|
||||
// This is a workaround for a bug in flex that only shows up
|
||||
// with the Microsoft C++ compiler
|
||||
#if defined(_MSC_VER)
|
||||
#define YY_NO_UNISTD_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" int isatty(int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// The Microsoft C++ compiler marks certain functions as deprecated,
|
||||
// so let's take the alternative definitions
|
||||
#if defined(_MSC_VER)
|
||||
#define strdup _strdup
|
||||
#define fileno _fileno
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <gecode/flatzinc/option.hh>
|
||||
#include <gecode/flatzinc/varspec.hh>
|
||||
#include <gecode/flatzinc/conexpr.hh>
|
||||
#include <gecode/flatzinc/ast.hh>
|
||||
#include <gecode/flatzinc/parser.tab.hh>
|
||||
#include <gecode/flatzinc/symboltable.hh>
|
||||
|
||||
namespace Gecode { namespace FlatZinc {
|
||||
|
||||
typedef std::pair<std::string,Option<std::vector<int>* > > intvartype;
|
||||
|
||||
class VarSpec;
|
||||
typedef std::pair<std::string, VarSpec*> varspec;
|
||||
|
||||
/// Strict weak ordering for output items
|
||||
class OutputOrder {
|
||||
public:
|
||||
/// Return if \a x is less than \a y, based on first component
|
||||
bool operator ()(const std::pair<std::string,AST::Node*>& x,
|
||||
const std::pair<std::string,AST::Node*>& y) {
|
||||
return x.first < y.first;
|
||||
}
|
||||
};
|
||||
|
||||
/// Types of symbols
|
||||
enum SymbolType {
|
||||
ST_INTVAR, //< Integer variable
|
||||
ST_BOOLVAR, //< Boolean variable
|
||||
ST_FLOATVAR, //< Float variable
|
||||
ST_SETVAR, //< Set variable
|
||||
ST_INTVARARRAY, //< Integer variable array
|
||||
ST_BOOLVARARRAY, //< Boolean variable array
|
||||
ST_SETVARARRAY, //< Set variable array
|
||||
ST_FLOATVARARRAY, //< Float variable array
|
||||
ST_INTVALARRAY, //< Integer array
|
||||
ST_BOOLVALARRAY, //< Boolean array
|
||||
ST_SETVALARRAY, //< Set array
|
||||
ST_FLOATVALARRAY, //< Float array
|
||||
ST_INT, //< Integer
|
||||
ST_BOOL, //< Boolean
|
||||
ST_SET, //< Set
|
||||
ST_FLOAT //< Float
|
||||
};
|
||||
|
||||
/// Entries in the symbol table
|
||||
class SymbolEntry {
|
||||
public:
|
||||
SymbolType t; //< Type of entry
|
||||
int i; //< Value of entry or array start index
|
||||
/// Default constructor
|
||||
SymbolEntry(void) {}
|
||||
/// Constructor
|
||||
SymbolEntry(SymbolType t0, int i0) : t(t0), i(i0) {}
|
||||
};
|
||||
|
||||
/// Construct integer variable entry
|
||||
forceinline SymbolEntry se_iv(int i) {
|
||||
return SymbolEntry(ST_INTVAR, i);
|
||||
}
|
||||
/// Construct Boolean variable entry
|
||||
forceinline SymbolEntry se_bv(int i) {
|
||||
return SymbolEntry(ST_BOOLVAR, i);
|
||||
}
|
||||
/// Construct float variable entry
|
||||
forceinline SymbolEntry se_fv(int i) {
|
||||
return SymbolEntry(ST_FLOATVAR, i);
|
||||
}
|
||||
/// Construct set variable entry
|
||||
forceinline SymbolEntry se_sv(int i) {
|
||||
return SymbolEntry(ST_SETVAR, i);
|
||||
}
|
||||
|
||||
/// Construct integer variable array entry
|
||||
forceinline SymbolEntry se_iva(int i) {
|
||||
return SymbolEntry(ST_INTVARARRAY, i);
|
||||
}
|
||||
/// Construct Boolean variable array entry
|
||||
forceinline SymbolEntry se_bva(int i) {
|
||||
return SymbolEntry(ST_BOOLVARARRAY, i);
|
||||
}
|
||||
/// Construct float variable array entry
|
||||
forceinline SymbolEntry se_fva(int i) {
|
||||
return SymbolEntry(ST_FLOATVARARRAY, i);
|
||||
}
|
||||
/// Construct set variable array entry
|
||||
forceinline SymbolEntry se_sva(int i) {
|
||||
return SymbolEntry(ST_SETVARARRAY, i);
|
||||
}
|
||||
|
||||
/// Construct integer entry
|
||||
forceinline SymbolEntry se_i(int i) {
|
||||
return SymbolEntry(ST_INT, i);
|
||||
}
|
||||
/// Construct Boolean entry
|
||||
forceinline SymbolEntry se_b(bool b) {
|
||||
return SymbolEntry(ST_BOOL, b);
|
||||
}
|
||||
/// Construct set entry
|
||||
forceinline SymbolEntry se_s(int i) {
|
||||
return SymbolEntry(ST_SET, i);
|
||||
}
|
||||
/// Construct float entry
|
||||
forceinline SymbolEntry se_f(int i) {
|
||||
return SymbolEntry(ST_FLOAT, i);
|
||||
}
|
||||
|
||||
/// Construct integer array entry
|
||||
forceinline SymbolEntry se_ia(int i) {
|
||||
return SymbolEntry(ST_INTVALARRAY, i);
|
||||
}
|
||||
/// Construct Boolean array entry
|
||||
forceinline SymbolEntry se_ba(int i) {
|
||||
return SymbolEntry(ST_BOOLVALARRAY, i);
|
||||
}
|
||||
/// Construct set array entry
|
||||
forceinline SymbolEntry se_sa(int i) {
|
||||
return SymbolEntry(ST_SETVALARRAY, i);
|
||||
}
|
||||
/// Construct float array entry
|
||||
forceinline SymbolEntry se_fa(int i) {
|
||||
return SymbolEntry(ST_FLOATVALARRAY, i);
|
||||
}
|
||||
|
||||
/// %State of the %FlatZinc parser
|
||||
class ParserState {
|
||||
public:
|
||||
ParserState(const std::string& b, std::ostream& err0,
|
||||
Gecode::FlatZinc::FlatZincSpace* fg0)
|
||||
: buf(b.c_str()), pos(0), length(b.size()), fg(fg0),
|
||||
hadError(false), err(err0) {}
|
||||
|
||||
ParserState(char* buf0, int length0, std::ostream& err0,
|
||||
Gecode::FlatZinc::FlatZincSpace* fg0)
|
||||
: buf(buf0), pos(0), length(length0), fg(fg0),
|
||||
hadError(false), err(err0) {}
|
||||
|
||||
void* yyscanner;
|
||||
const char* buf;
|
||||
unsigned int pos, length;
|
||||
Gecode::FlatZinc::FlatZincSpace* fg;
|
||||
std::vector<std::pair<std::string,AST::Node*> > _output;
|
||||
|
||||
SymbolTable<SymbolEntry> symbols;
|
||||
|
||||
std::vector<varspec> intvars;
|
||||
std::vector<varspec> boolvars;
|
||||
std::vector<varspec> setvars;
|
||||
std::vector<varspec> floatvars;
|
||||
std::vector<int> arrays;
|
||||
std::vector<AST::SetLit> setvals;
|
||||
std::vector<double> floatvals;
|
||||
std::vector<ConExpr*> constraints;
|
||||
|
||||
std::vector<ConExpr*> domainConstraints;
|
||||
|
||||
bool hadError;
|
||||
std::ostream& err;
|
||||
|
||||
int fillBuffer(char* lexBuf, unsigned int lexBufSize) {
|
||||
if (pos >= length)
|
||||
return 0;
|
||||
int num = std::min(length - pos, lexBufSize);
|
||||
memcpy(lexBuf,buf+pos,num);
|
||||
pos += num;
|
||||
return num;
|
||||
}
|
||||
|
||||
void output(std::string x, AST::Node* n) {
|
||||
_output.push_back(std::pair<std::string,AST::Node*>(x,n));
|
||||
}
|
||||
|
||||
AST::Array* getOutput(void) {
|
||||
OutputOrder oo;
|
||||
std::sort(_output.begin(),_output.end(),oo);
|
||||
AST::Array* a = new AST::Array();
|
||||
for (unsigned int i=0; i<_output.size(); i++) {
|
||||
a->a.push_back(new AST::String(_output[i].first+" = "));
|
||||
if (_output[i].second->isArray()) {
|
||||
AST::Array* oa = _output[i].second->getArray();
|
||||
for (unsigned int j=0; j<oa->a.size(); j++) {
|
||||
a->a.push_back(oa->a[j]);
|
||||
oa->a[j] = NULL;
|
||||
}
|
||||
delete _output[i].second;
|
||||
} else {
|
||||
a->a.push_back(_output[i].second);
|
||||
}
|
||||
a->a.push_back(new AST::String(";\n"));
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
// STATISTICS: flatzinc-any
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,141 +0,0 @@
|
||||
/* A Bison parser, made by GNU Bison 2.7.12-4996. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
#ifndef YY_YY_GECODE_FLATZINC_PARSER_TAB_HPP_INCLUDED
|
||||
# define YY_YY_GECODE_FLATZINC_PARSER_TAB_HPP_INCLUDED
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 1
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int yydebug;
|
||||
#endif
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
FZ_INT_LIT = 258,
|
||||
FZ_BOOL_LIT = 259,
|
||||
FZ_FLOAT_LIT = 260,
|
||||
FZ_ID = 261,
|
||||
FZ_U_ID = 262,
|
||||
FZ_STRING_LIT = 263,
|
||||
FZ_VAR = 264,
|
||||
FZ_PAR = 265,
|
||||
FZ_ANNOTATION = 266,
|
||||
FZ_ANY = 267,
|
||||
FZ_ARRAY = 268,
|
||||
FZ_BOOL = 269,
|
||||
FZ_CASE = 270,
|
||||
FZ_COLONCOLON = 271,
|
||||
FZ_CONSTRAINT = 272,
|
||||
FZ_DEFAULT = 273,
|
||||
FZ_DOTDOT = 274,
|
||||
FZ_ELSE = 275,
|
||||
FZ_ELSEIF = 276,
|
||||
FZ_ENDIF = 277,
|
||||
FZ_ENUM = 278,
|
||||
FZ_FLOAT = 279,
|
||||
FZ_FUNCTION = 280,
|
||||
FZ_IF = 281,
|
||||
FZ_INCLUDE = 282,
|
||||
FZ_INT = 283,
|
||||
FZ_LET = 284,
|
||||
FZ_MAXIMIZE = 285,
|
||||
FZ_MINIMIZE = 286,
|
||||
FZ_OF = 287,
|
||||
FZ_SATISFY = 288,
|
||||
FZ_OUTPUT = 289,
|
||||
FZ_PREDICATE = 290,
|
||||
FZ_RECORD = 291,
|
||||
FZ_SET = 292,
|
||||
FZ_SHOW = 293,
|
||||
FZ_SHOWCOND = 294,
|
||||
FZ_SOLVE = 295,
|
||||
FZ_STRING = 296,
|
||||
FZ_TEST = 297,
|
||||
FZ_THEN = 298,
|
||||
FZ_TUPLE = 299,
|
||||
FZ_TYPE = 300,
|
||||
FZ_VARIANT_RECORD = 301,
|
||||
FZ_WHERE = 302
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
/* Line 2053 of yacc.c */
|
||||
#line 455 "gecode/flatzinc/parser.yxx"
|
||||
int iValue; char* sValue; bool bValue; double dValue;
|
||||
std::vector<int>* setValue;
|
||||
Gecode::FlatZinc::AST::SetLit* setLit;
|
||||
std::vector<double>* floatSetValue;
|
||||
std::vector<Gecode::FlatZinc::AST::SetLit>* setValueList;
|
||||
Gecode::FlatZinc::Option<Gecode::FlatZinc::AST::SetLit* > oSet;
|
||||
Gecode::FlatZinc::Option<std::pair<double,double>* > oPFloat;
|
||||
Gecode::FlatZinc::VarSpec* varSpec;
|
||||
Gecode::FlatZinc::Option<Gecode::FlatZinc::AST::Node*> oArg;
|
||||
std::vector<Gecode::FlatZinc::VarSpec*>* varSpecVec;
|
||||
Gecode::FlatZinc::Option<std::vector<Gecode::FlatZinc::VarSpec*>* > oVarSpecVec;
|
||||
Gecode::FlatZinc::AST::Node* arg;
|
||||
Gecode::FlatZinc::AST::Array* argVec;
|
||||
|
||||
|
||||
/* Line 2053 of yacc.c */
|
||||
#line 120 "gecode/flatzinc/parser.tab.hpp"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef YYPARSE_PARAM
|
||||
#if defined __STDC__ || defined __cplusplus
|
||||
int yyparse (void *YYPARSE_PARAM);
|
||||
#else
|
||||
int yyparse ();
|
||||
#endif
|
||||
#else /* ! YYPARSE_PARAM */
|
||||
#if defined __STDC__ || defined __cplusplus
|
||||
int yyparse (void *parm);
|
||||
#else
|
||||
int yyparse ();
|
||||
#endif
|
||||
#endif /* ! YYPARSE_PARAM */
|
||||
|
||||
#endif /* !YY_YY_GECODE_FLATZINC_PARSER_TAB_HPP_INCLUDED */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,83 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2010
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GECODE_FLATZINC_PLUGIN_HH__
|
||||
#define __GECODE_FLATZINC_PLUGIN_HH__
|
||||
|
||||
#ifdef GECODE_HAS_QT
|
||||
#include <QtCore>
|
||||
#include <QPluginLoader>
|
||||
#include <QLibrary>
|
||||
|
||||
namespace Gecode { namespace FlatZinc {
|
||||
/**
|
||||
* \brief Interface for branch plugins
|
||||
*
|
||||
* This interface has to be implemented as a Qt Plugin. It then
|
||||
* provides custom branch methods that can be loaded at runtime
|
||||
* from a FlatZinc file.
|
||||
*
|
||||
* In order to use a custom branching, add an annotation to the
|
||||
* FlatZinc solve item like the following:
|
||||
*
|
||||
* ::gecode_search(mybranch(some,arguments,x,y,z))
|
||||
*
|
||||
* This will load the plugin called mybranch and invoke its branch
|
||||
* method with the arguments encoded in an AST.
|
||||
*
|
||||
* The plugin mybranch must reside in a file called mybranch.dll
|
||||
* on Windows, libmybranch.dylib on Mac OS and libmybranch.so on
|
||||
* Linux systems.
|
||||
*
|
||||
* An example plugin can be found in the Gecode source tree under
|
||||
* gecode/flatzinc/exampleplugin.
|
||||
*
|
||||
*/
|
||||
class GECODE_VTABLE_EXPORT BranchPlugin {
|
||||
public:
|
||||
/// The custom branch method that this plugin provides
|
||||
virtual void branch(Gecode::FlatZinc::FlatZincSpace& s,
|
||||
Gecode::FlatZinc::AST::Call* c) = 0;
|
||||
};
|
||||
}}
|
||||
Q_DECLARE_INTERFACE(Gecode::FlatZinc::BranchPlugin,
|
||||
"org.gecode.FlatZinc.BranchPlugin/1.0");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// STATISTICS: flatzinc-any
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,71 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2007
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GECODE_FLATZINC_REGISTRY_HH__
|
||||
#define __GECODE_FLATZINC_REGISTRY_HH__
|
||||
|
||||
#include <gecode/flatzinc.hh>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace Gecode { namespace FlatZinc {
|
||||
|
||||
/// Map from constraint identifier to constraint posting functions
|
||||
class GECODE_FLATZINC_EXPORT Registry {
|
||||
public:
|
||||
/// Type of constraint posting function
|
||||
typedef void (*poster) (FlatZincSpace&,
|
||||
const ConExpr&,
|
||||
AST::Node*);
|
||||
/// Add posting function \a p with identifier \a id
|
||||
void add(const std::string& id, poster p);
|
||||
/// Post constraint specified by \a ce
|
||||
void post(FlatZincSpace& s, const ConExpr& ce);
|
||||
|
||||
private:
|
||||
/// The actual registry
|
||||
std::map<std::string,poster> r;
|
||||
};
|
||||
|
||||
/// Return global registry object
|
||||
GECODE_FLATZINC_EXPORT Registry& registry(void);
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
// STATISTICS: flatzinc-any
|
||||
@@ -1,96 +0,0 @@
|
||||
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
* Main authors:
|
||||
* Guido Tack <tack@gecode.org>
|
||||
*
|
||||
* Copyright:
|
||||
* Guido Tack, 2007
|
||||
*
|
||||
* Last modified:
|
||||
* $Date$ by $Author$
|
||||
* $Revision$
|
||||
*
|
||||
* This file is part of Gecode, the generic constraint
|
||||
* development environment:
|
||||
* http://www.gecode.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GECODE_FLATZINC_SYMBOLTABLE_HH__
|
||||
#define __GECODE_FLATZINC_SYMBOLTABLE_HH__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef GECODE_HAS_GNU_HASH_MAP
|
||||
#include <ext/hash_map>
|
||||
#else
|
||||
#include <map>
|
||||
#endif
|
||||
|
||||
namespace Gecode { namespace FlatZinc {
|
||||
|
||||
/// Symbol table mapping identifiers (strings) to values
|
||||
template<class Val>
|
||||
class SymbolTable {
|
||||
private:
|
||||
#ifdef GECODE_HAS_GNU_HASH_MAP
|
||||
class hashString {
|
||||
public:
|
||||
size_t operator ()(const std::string& x) const {
|
||||
return __gnu_cxx::hash<const char*>()(x.c_str());
|
||||
}
|
||||
};
|
||||
typedef __gnu_cxx::hash_map<std::string,Val,hashString> mymap;
|
||||
#else
|
||||
typedef std::map<std::string,Val> mymap;
|
||||
#endif
|
||||
mymap m;
|
||||
public:
|
||||
/// Insert \a val with \a key
|
||||
bool put(const std::string& key, const Val& val);
|
||||
/// Return whether \a key exists, and set \a val if it does exist
|
||||
bool get(const std::string& key, Val& val) const;
|
||||
};
|
||||
|
||||
template<class Val>
|
||||
bool
|
||||
SymbolTable<Val>::put(const std::string& key, const Val& val) {
|
||||
typename mymap::const_iterator i = m.find(key);
|
||||
bool fresh = (i == m.end());
|
||||
m[key] = val;
|
||||
return fresh;
|
||||
}
|
||||
|
||||
template<class Val>
|
||||
bool
|
||||
SymbolTable<Val>::get(const std::string& key, Val& val) const {
|
||||
typename mymap::const_iterator i = m.find(key);
|
||||
if (i == m.end())
|
||||
return false;
|
||||
val = i->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
}}
|
||||
#endif
|
||||
|
||||
// STATISTICS: flatzinc-any
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user