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 #include "test/float.hh"
00037
00038 #include <gecode/minimodel.hh>
00039
00040 namespace Test { namespace Float {
00041
00043 namespace Channel {
00044
00046 class Int : public Test {
00047 public:
00049 Int(Gecode::FloatNum st)
00050 : Test("Channel::Int",2,-1,2,st,CPLT_ASSIGNMENT,false) {}
00052 virtual MaybeType solution(const Assignment& x) const {
00053 Gecode::FloatNum tmp;
00054 return (((modf(x[0].min(),&tmp)==0) ||
00055 (modf(x[0].max(),&tmp)==0))
00056 && (x[0]==x[1])) ? MT_TRUE : MT_FALSE;
00057 }
00059 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
00060 using namespace Gecode;
00061 IntVar iv(home,-1000,1000);
00062 channel(home, x[0], iv);
00063 channel(home, iv, x[1]);
00064 }
00065 };
00066
00068 class Bool : public Test {
00069 public:
00071 Bool(Gecode::FloatNum st)
00072 : Test("Channel::Bool",2,0,1,st,CPLT_ASSIGNMENT,false) {}
00074 virtual MaybeType solution(const Assignment& x) const {
00075 Gecode::FloatNum tmp;
00076 return (((modf(x[0].min(),&tmp)==0) ||
00077 (modf(x[0].max(),&tmp)==0))
00078 && (x[0]==x[1])) ? MT_TRUE : MT_FALSE;
00079 }
00081 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
00082 using namespace Gecode;
00083 BoolVar bv(home,0,1);
00084 channel(home, x[0], bv);
00085 channel(home, bv, x[1]);
00086 }
00087 };
00088
00089 Gecode::FloatNum step1 = 0.7;
00090 Gecode::FloatNum step2 = 0.1;
00091
00092 Int ci(step1);
00093 Bool cb(step2);
00095
00096 }
00097 }}
00098
00099
00100