channel.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "test/float.hh"
00041
00042 #include <gecode/minimodel.hh>
00043
00044 namespace Test { namespace Float {
00045
00047 namespace Channel {
00048
00050 class Int : public Test {
00051 public:
00053 Int(Gecode::FloatNum st)
00054 : Test("Channel::Int",2,-1,2,st,CPLT_ASSIGNMENT,false) {}
00056 virtual MaybeType solution(const Assignment& x) const {
00057 Gecode::FloatNum tmp;
00058 return (((modf(x[0].min(),&tmp)==0) ||
00059 (modf(x[0].max(),&tmp)==0))
00060 && (x[0]==x[1])) ? MT_TRUE : MT_FALSE;
00061 }
00063 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
00064 using namespace Gecode;
00065 IntVar iv(home,-1000,1000);
00066 channel(home, x[0], iv);
00067 channel(home, iv, x[1]);
00068 }
00069 };
00070
00072 class Bool : public Test {
00073 public:
00075 Bool(Gecode::FloatNum st)
00076 : Test("Channel::Bool",2,0,1,st,CPLT_ASSIGNMENT,false) {}
00078 virtual MaybeType solution(const Assignment& x) const {
00079 Gecode::FloatNum tmp;
00080 return (((modf(x[0].min(),&tmp)==0) ||
00081 (modf(x[0].max(),&tmp)==0))
00082 && (x[0]==x[1])) ? MT_TRUE : MT_FALSE;
00083 }
00085 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
00086 using namespace Gecode;
00087 BoolVar bv(home,0,1);
00088 channel(home, x[0], bv);
00089 channel(home, bv, x[1]);
00090 }
00091 };
00092
00093 Gecode::FloatNum step1 = 0.7;
00094 Gecode::FloatNum step2 = 0.1;
00095
00096 Int ci(step1);
00097 Bool cb(step2);
00099
00100 }
00101 }}
00102
00103
00104