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/driver.hh>
00039
00040 #include <gecode/minimodel.hh>
00041 #include <gecode/float.hh>
00042
00043 using namespace Gecode;
00044
00071 class ArchimedeanSpiral : public Script {
00072 protected:
00074 FloatVarArray f;
00076 FloatNum step;
00077 public:
00079 ArchimedeanSpiral(const Options&)
00080 : f(*this,4,-20,20), step(0.1) {
00081
00082 FloatVar theta = f[0];
00083 FloatVar r = f[3];
00084 FloatVar x = f[1];
00085 FloatVar y = f[2];
00086
00087 rel(*this, theta >= 0);
00088 rel(*this, theta <= 6*FloatVal::pi());
00089 rel(*this, r >= 0);
00090 rel(*this, r*cos(theta) == x);
00091 rel(*this, r*sin(theta) == y);
00092 rel(*this, r == theta);
00093
00094 branch(*this,f[0],FLOAT_VAL_SPLIT_MIN());
00095 }
00097 ArchimedeanSpiral(bool share, ArchimedeanSpiral& p)
00098 : Script(share,p), step(p.step) {
00099 f.update(*this,share,p.f);
00100 }
00102 virtual Space* copy(bool share) {
00103 return new ArchimedeanSpiral(share,*this);
00104 }
00106 virtual void constrain(const Space& _b) {
00107 const ArchimedeanSpiral& b = static_cast<const ArchimedeanSpiral&>(_b);
00108 rel(*this, f[0] >= (b.f[0].max()+step));
00109 }
00111 virtual void print(std::ostream& os) const {
00112 os << "XY " << f[1].med() << " " << f[2].med()
00113 << std::endl;
00114 }
00115
00116 };
00117
00121 int main(int argc, char* argv[]) {
00122 Options opt("ArchimedeanSpiral");
00123 opt.parse(argc,argv);
00124 opt.solutions(0);
00125 Script::run<ArchimedeanSpiral,BAB,Options>(opt);
00126 return 0;
00127 }
00128
00129