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

float.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Mikael Lagerkvist <lagerkvist@gecode.org>
00006  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
00007  *
00008  *  Copyright:
00009  *     Christian Schulte, 2005
00010  *     Mikael Lagerkvist, 2006
00011  *     Vincent Barichard, 2012
00012  *
00013  *  Last modified:
00014  *     $Date: 2016-10-20 17:25:30 +0200 (Thu, 20 Oct 2016) $ by $Author: schulte $
00015  *     $Revision: 15217 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 #ifndef __GECODE_TEST_FLOAT_HH__
00043 #define __GECODE_TEST_FLOAT_HH__
00044 
00045 #include "test/test.hh"
00046 
00047 #include <gecode/float.hh>
00048 
00049 namespace Test {
00050 
00052   namespace Float {
00053 
00055     enum MaybeType {
00056       MT_FALSE = 0, //< Does hold
00057       MT_TRUE,      //< Does not hold
00058       MT_MAYBE      //< Might or might not hold
00059     };
00060 
00062     MaybeType operator &(MaybeType a, MaybeType b);
00063 
00065     enum AssignmentType {
00066       CPLT_ASSIGNMENT = 0,
00067       RANDOM_ASSIGNMENT,
00068       EXTEND_ASSIGNMENT
00069     };
00070 
00071     class Test;
00072 
00083 
00084     class Assignment {
00085     protected:
00086       int n;              
00087       Gecode::FloatVal d; 
00088     public:
00090       Assignment(int n0, const Gecode::FloatVal& d0);
00092       virtual bool operator()(void) const = 0;
00094       virtual void operator++(void) = 0;
00096       virtual Gecode::FloatVal operator[](int i) const = 0;
00098       virtual void set(int i, const Gecode::FloatVal& val) = 0;
00100       int size(void) const;
00102       virtual ~Assignment(void);
00103     };
00104 
00106     class CpltAssignment : public Assignment {
00107     protected:
00108       Gecode::FloatVal* dsv; 
00109       Gecode::FloatNum step; 
00110     public:
00112       CpltAssignment(int n, const Gecode::FloatVal& d, Gecode::FloatNum s);
00114       virtual bool operator()(void) const;
00116       virtual void operator++(void);
00118       virtual Gecode::FloatVal operator[](int i) const;
00120       virtual void set(int i, const Gecode::FloatVal& val);
00122       virtual ~CpltAssignment(void);
00123     };
00124 
00126     class ExtAssignment : public Assignment {
00127     protected:
00128       const Test* curPb;     
00129       Gecode::FloatVal* dsv; 
00130       Gecode::FloatNum step; 
00131     public:
00133       ExtAssignment(int n, const Gecode::FloatVal& d, Gecode::FloatNum s, const Test * pb);
00135       virtual bool operator()(void) const;
00137       virtual void operator++(void);
00139       virtual Gecode::FloatVal operator[](int i) const;
00141       virtual void set(int i, const Gecode::FloatVal& val);
00143       virtual ~ExtAssignment(void);
00144     };
00145 
00146 
00148     class RandomAssignment : public Assignment {
00149     protected:
00150       Gecode::FloatVal* vals; 
00151       int  a;                 
00152 
00153       Gecode::FloatNum randval(void);
00154     public:
00156       RandomAssignment(int n, const Gecode::FloatVal& d, int a);
00158       virtual bool operator()(void) const;
00160       virtual void operator++(void);
00162       virtual Gecode::FloatVal operator[](int i) const;
00164       virtual void set(int i, const Gecode::FloatVal& val);
00166       virtual ~RandomAssignment(void);
00167     };
00168 
00170     class TestSpace : public Gecode::Space {
00171     public:
00173       Gecode::FloatVal d;
00175       Gecode::FloatNum step;
00177       Gecode::FloatVarArray x;
00179       Gecode::Reify r;
00181       Test* test;
00183       bool reified;
00184 
00192       TestSpace(int n, Gecode::FloatVal& d, Gecode::FloatNum s, Test* t);
00200       TestSpace(int n, Gecode::FloatVal& d, Gecode::FloatNum s, Test* t,
00201                 Gecode::ReifyMode rm);
00203       TestSpace(bool share, TestSpace& s);
00205       virtual Gecode::Space* copy(bool share);
00207       virtual void dropUntil(const Assignment& a);
00209       bool assigned(void) const;
00211       bool matchAssignment(const Assignment& a) const;
00213       void post(void);
00215       bool failed(void);
00217       void rel(int i, Gecode::FloatRelType frt, Gecode::FloatVal n);
00219       void rel(bool sol);
00223       void assign(const Assignment& a, MaybeType& sol, bool skip=false);
00225       void bound(void);
00229       Gecode::FloatNum cut(int* cutDirections);
00231       void prune(int i);
00233       void prune(void);
00235       bool prune(const Assignment& a, bool testfix);
00237       void disable(void);
00239       void enable(void);
00241       unsigned int propagators(void);
00242     };
00243 
00248     class Test : public Base {
00249     protected:
00251       int arity;
00253       Gecode::FloatVal dom;
00255       Gecode::FloatNum step;
00257       AssignmentType assigmentType;
00259       bool reified;
00261       int rms;
00263       bool testsearch;
00265       bool testfix;
00267       bool testsubsumed;
00269 
00270 
00271       bool eqv(void) const;
00273       bool imp(void) const;
00275       bool pmi(void) const;
00277     public:
00285       Test(const std::string& s, int a, const Gecode::FloatVal& d,
00286            Gecode::FloatNum st, AssignmentType at,
00287            bool r);
00295       Test(const std::string& s, int a,
00296            Gecode::FloatNum min, Gecode::FloatNum max,
00297            Gecode::FloatNum st, AssignmentType at,
00298            bool r);
00300       virtual Assignment* assignment(void) const;
00303       virtual bool extendAssignement(Assignment& a) const;
00305       virtual MaybeType solution(const Assignment&) const = 0;
00308       bool subsumed(const TestSpace& ts) const;
00310       virtual bool ignore(const Assignment& a) const;
00312       virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) = 0;
00314       virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x,
00315                         Gecode::Reify r);
00317       virtual bool run(void);
00319 
00320 
00321       static std::string str(Gecode::FloatRelType frt);
00323       static std::string str(Gecode::FloatNum f);
00325       static std::string str(Gecode::FloatVal f);
00327       static std::string str(const Gecode::FloatValArgs& f);
00329 
00330 
00331 
00332       static MaybeType cmp(Gecode::FloatVal x, Gecode::FloatRelType r,
00333                            Gecode::FloatVal y);
00335       static MaybeType eq(Gecode::FloatVal x, Gecode::FloatVal y);
00337       bool flip(void);
00339     };
00341 
00343     class FloatRelTypes {
00344     private:
00346       static const Gecode::FloatRelType frts[6];
00348       int i;
00349     public:
00351       FloatRelTypes(void);
00353       void reset(void);
00355       bool operator()(void) const;
00357       void operator++(void);
00359       Gecode::FloatRelType frt(void) const;
00360     };
00361 
00362   }
00363 }
00364 
00369 std::ostream& operator<<(std::ostream& os, const Test::Float::Assignment& a);
00370 
00371 #include "test/float.hpp"
00372 
00373 #endif
00374 
00375 // STATISTICS: test-float
00376