support.icc
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 inline
00023 Options::Options(const char* n)
00024 : icl(ICL_DEF),
00025 c_d(1),
00026 a_d(1),
00027 mode(EM_SOLUTION),
00028 samples(1),
00029 iterations(1),
00030 solutions(1),
00031 naive(false),
00032 size(0),
00033 name(n) {}
00034
00035
00036 template <class Script, template<class> class Engine>
00037 void
00038 Example::run(const Options& o) {
00039 using namespace std;
00040 try {
00041 switch (o.mode) {
00042 case EM_SOLUTION:
00043 {
00044 cout << o.name << endl;
00045 Timer t;
00046 int i = o.solutions;
00047 t.start();
00048 Script* s = new Script(o);
00049 Engine<Script> e(s,o.c_d,o.a_d);
00050 delete s;
00051 do {
00052 Example* ex = e.next();
00053 if (ex == NULL)
00054 break;
00055 ex->print();
00056 delete ex;
00057 } while (--i != 0);
00058 Search::Statistics stat = e.statistics();
00059 cout << endl;
00060 cout << "Summary" << endl
00061 << "\truntime: " << t.stop() << endl
00062 << "\tsolutions: " << abs(static_cast<int>(o.solutions) - i) << endl
00063 << "\tpropagations: " << stat.propagate << endl
00064 << "\tfailures: " << stat.fail << endl
00065 << "\tclones: " << stat.clone << endl
00066 << "\tcommits: " << stat.commit << endl
00067 << "\tpeak memory: "
00068 << static_cast<int>((stat.memory+1023) / 1024) << " KB"
00069 << endl;
00070 }
00071 break;
00072 case EM_STAT:
00073 {
00074 cout << "%%% " << o.name << endl;
00075 int i = o.solutions;
00076 Script* s = new Script(o);
00077 Engine<Script> e(s,o.c_d,o.a_d);
00078 delete s;
00079 do {
00080 Example* ex = e.next();
00081 if (ex == NULL)
00082 break;
00083 delete ex;
00084 } while (--i != 0);
00085 Search::Statistics stat = e.statistics();
00086 cout << endl
00087 << "\tsolutions: " << abs(static_cast<int>(o.solutions) - i) << endl
00088 << "\tpropagations: " << stat.propagate << endl
00089 << "\tfailures: " << stat.fail << endl
00090 << "\tclones: " << stat.clone << endl
00091 << "\tcommits: " << stat.commit << endl
00092 << "\tpeak memory: "
00093 << static_cast<int>((stat.memory+1023) / 1024) << " KB"
00094 << endl;
00095 }
00096 break;
00097 case EM_TIME:
00098 {
00099 cout << o.name << endl;
00100 Timer t;
00101 GECODE_AUTOARRAY(double,ts,o.samples);
00102 for (int s = o.samples; s--; ) {
00103 t.start();
00104 for (int k = o.iterations; k--; ) {
00105 unsigned int i = o.solutions;
00106 Script* s = new Script(o);
00107 Engine<Script> e(s,o.c_d,o.a_d);
00108 delete s;
00109 do {
00110 Example* ex = e.next();
00111 if (ex == NULL)
00112 break;
00113 delete ex;
00114 } while (--i != 0);
00115 }
00116 ts[s] = t.stop() / o.iterations;
00117 }
00118 double m = am(ts,o.samples);
00119 double d = dev(ts,o.samples) * 100.0;
00120 cout << "\tRuntime: "
00121 << setw(20) << right
00122 << showpoint << fixed
00123 << setprecision(6) << m << "ms"
00124 << setprecision(2) << " (" << d << "% deviation)"
00125 << endl;
00126 }
00127 break;
00128 }
00129 } catch (Exception e) {
00130 cout << "Exception in \"Gecode::" << e.location()
00131 << "\": " << e.info() << "." << endl
00132 << "Stopping..." << endl;
00133 }
00134 }
00135
00136