unary.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 #include <gecode/scheduling/unary.hh>
00039
00040 #include <algorithm>
00041
00042 namespace Gecode {
00043
00044 void
00045 unary(Home home, const IntVarArgs& s, const IntArgs& p) {
00046 using namespace Gecode::Scheduling;
00047 using namespace Gecode::Scheduling::Unary;
00048 if (s.same(home))
00049 throw Int::ArgumentSame("Scheduling::unary");
00050 if (s.size() != p.size())
00051 throw Int::ArgumentSizeMismatch("Scheduling::unary");
00052 for (int i=p.size(); i--; ) {
00053 Int::Limits::positive(p[i],"Scheduling::unary");
00054 Int::Limits::check(static_cast<double>(s[i].max()) + p[i],
00055 "Scheduling::unary");
00056 }
00057 if (home.failed()) return;
00058 TaskArray<ManFixTask> t(home,s.size());
00059 for (int i=s.size(); i--; )
00060 t[i].init(s[i],p[i]);
00061 GECODE_ES_FAIL(home,ManProp<ManFixTask>::post(home,t));
00062 }
00063
00064 void
00065 unary(Home home, const IntVarArgs& s, const IntArgs& p,
00066 const BoolVarArgs& m) {
00067 using namespace Gecode::Scheduling;
00068 using namespace Gecode::Scheduling::Unary;
00069 if (s.same(home))
00070 throw Int::ArgumentSame("Scheduling::unary");
00071 if ((s.size() != p.size()) || (s.size() != m.size()))
00072 throw Int::ArgumentSizeMismatch("Scheduling::unary");
00073 for (int i=p.size(); i--; ) {
00074 Int::Limits::positive(p[i],"Scheduling::unary");
00075 Int::Limits::check(static_cast<double>(s[i].max()) + p[i],
00076 "Scheduling::unary");
00077 }
00078 if (home.failed()) return;
00079 TaskArray<OptFixTask> t(home,s.size());
00080 for (int i=s.size(); i--; )
00081 t[i].init(s[i],p[i],m[i]);
00082 GECODE_ES_FAIL(home,OptProp<OptFixTask>::post(home,t));
00083 }
00084
00085 }
00086
00087