00001
00002 #include <iostream>
00003
00004 #include "cpsp/gecode/GC_StlSetRangeIterator.hh"
00005 #include <gecode/kernel.hh>
00006 #include <gecode/int.hh>
00007 #include <set>
00008 void test_SetIterator() {
00009 using namespace cpsp;
00010 using namespace cpsp::gecode;
00011 using namespace std;
00012
00013 set<int> s;
00014 for (int i=0; i< 5; i++) {
00015 s.insert(i);
00016 s.insert(i+6);
00017 s.insert(i+10);
00018 }
00019 for(set<int>::const_iterator it= s.begin(); it!= s.end(); it++)
00020 std::cout <<" " <<*it;
00021 std::cout <<endl;
00022
00023 GC_StlSetRangeIterator itR(&s);
00024
00025 Gecode::IntSet is1(itR);
00026 std::cout <<"\n" <<is1 <<endl;
00027
00028 }
00029
00030
00031 #include <vector>
00032 #include "cpsp/HPThreadingOptions.hh"
00033 #include "cpsp/gecode/GC_ThreadingSpace.hh"
00034 void test_Threading(int argc, char **argv) {
00035 using namespace cpsp;
00036 using namespace gecode;
00037 using namespace std;
00038
00039 HPThreadingOptions opts(argc,argv);
00040
00041 HCore core(0,4);
00042 core.addPoint(biu::IntPoint(0,0,0));
00043 core.addPoint(biu::IntPoint(1,0,0));
00044 core.addPoint(biu::IntPoint(2,0,0));
00045 core.addPoint(biu::IntPoint(3,0,0));
00046
00047 try {
00048 cout << "\n\nTesting Gecode" << endl;
00049
00050 int maxSols = 99999999, sols = maxSols;
00051
00052 GC_ThreadingSpace* s = new GC_ThreadingSpace(opts, core);
00053
00054 typedef Gecode::DFS<GC_ThreadingSpace> Engine;
00055 Engine e( s);
00056 delete s;
00057
00058
00059 do {
00060 GC_ThreadingSpace* ex = e.next();
00061 if (ex == NULL)
00062 break;
00063
00064 std::cout <<opts.getLattice()->getString(
00065 opts.getLattice()->indicesToAbsMoves(
00066 ex->getSolution()))
00067 <<std::endl;
00068 delete ex;
00069 } while (--sols > 0);
00070
00071 Gecode::Search::Statistics stat = e.statistics();
00072
00073 cout << endl;
00074 cout << "Summary" << endl
00075 << "\tsolutions: " << abs(maxSols - sols) << endl
00076 << "\tpropagations: " << stat.propagate << endl
00077 << "\tfailures: " << stat.fail << endl
00078 << "\tclones: " << stat.clone << endl
00079 << "\tcommits: " << stat.commit << endl
00080 << "\tpeak memory: "
00081 << static_cast<int>((stat.memory+1023) / 1024) << " KB"
00082 << endl;
00083 } catch (Gecode::Exception e) {
00084 cout << "Exception in \"Gecode::" << e.location()
00085 << "\": " << e.info() << "." << endl
00086 << "Stopping..." << endl;
00087 }
00088
00089
00090 }
00091
00092
00093 #include "cpsp/gecode/GC_HPThreading.hh"
00094 void test_threading_gecode(int argc, char**argv) {
00095 using namespace cpsp;
00096 using namespace cpsp::gecode;
00097
00098 HPThreadingOptions opts(argc,argv);
00099
00100 GC_HPThreading threading(&opts);
00101 threading.generateStructures();
00102 }
00103
00104 int main(int argc, char **argv) {
00105
00106
00107 test_threading_gecode(argc, argv);
00108 return 0;
00109 }