conv.cc
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 #include "gecode/set.hh"
00027 #include "gecode/set/convex.hh"
00028
00029 #include "gecode/iter.hh"
00030
00031 namespace Gecode { namespace Set { namespace Convex {
00032
00033 Actor*
00034 Convex::copy(Space* home, bool share) {
00035 return new (home) Convex(home,share,*this);
00036 }
00037
00038 ExecStatus
00039 Convex::propagate(Space* home) {
00040
00041
00042
00043
00044
00045
00046
00047 if (x0.glbSize()>0) {
00048 GECODE_ME_CHECK( x0.include(home,x0.glbMin(),x0.glbMax()) );
00049 } else {
00050
00051
00052
00053
00054 LubRanges<SetView> ubRangeIt(x0);
00055 unsigned int maxWidth = 0;
00056 for (;ubRangeIt();++ubRangeIt){
00057 maxWidth = std::max(maxWidth, ubRangeIt.width());
00058 }
00059 GECODE_ME_CHECK( x0.cardMax(home,maxWidth) );
00060 }
00061
00062
00063
00064
00065 LubRanges<SetView> ubRangeIt(x0);
00066 Iter::Ranges::Cache< LubRanges<SetView> > ubRangeItC(ubRangeIt);
00067 for (;ubRangeItC();++ubRangeItC){
00068 if (ubRangeItC.width() < (unsigned int) x0.cardMin()
00069 || ubRangeItC.min() > x0.glbMin()
00070 || ubRangeItC.max() < x0.glbMax()
00071 ) {
00072 GECODE_ME_CHECK( x0.exclude(home,ubRangeItC.min(), ubRangeItC.max()) );
00073 }
00074 }
00075 if (x0.assigned()) {return ES_SUBSUMED;}
00076 return ES_FIX;
00077 }
00078
00079 }}}
00080
00081