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 #ifndef __FIMCP_COMMON_OPTIONS__
00035 #define __FIMCP_COMMON_OPTIONS__
00036
00037 #include <cmath>
00038 #include <vector>
00039 using namespace std;
00040 #include <gecode/driver.hh>
00041 using namespace Gecode;
00042 #include "textoption.hh"
00043 #include "stringuintoption.hh"
00044 #include "floatoption.hh"
00045
00046 enum OutputType {
00047 OUT_NONE,
00048 OUT_FIMI,
00049 OUT_FULL,
00050 OUT_CPVARS,
00051 };
00052
00053
00054
00055
00056
00057 class Options_fimcp : public Options {
00058 protected:
00059 StringOption _branchval;
00060 StringOption _output;
00061
00062 vector<BaseOption*> _list_specific;
00063 const char* _description;
00064 const char* _usage;
00065
00066
00067 TextOption _datafile;
00068 TextOption _attrfile;
00069 TextOption _solfile;
00070 UnsignedIntOption _cclause;
00071 FloatOption _freq;
00072 FloatOption _infreq;
00073 StringUIntOption _bound1;
00074 StringUIntOption _bound2;
00075 UnsignedIntOption _alpha;
00076 UnsignedIntOption _beta;
00077 FloatOption _delta;
00078 FloatOption _epsilon;
00079 public:
00080
00081 Options_fimcp(const char* e)
00082 : Options(e)
00083 , _branchval("-branchval", "branch value variants", INT_VAL_MAX)
00084 , _output("-output", "type of output of solutions", OUT_FIMI)
00085 , _list_specific()
00086
00087 , _datafile("-datafile", "filename of dataset to use (any name)", "example.txt")
00088 , _attrfile("-attrfile", "filename of attributes to use (any name)", "")
00089 , _solfile("-solfile", "filename to write solutions to (any name)", "")
00090 , _cclause("-cclause", "coverage constraint using clause ?", 1)
00091 , _freq("-freq", "frequency (>1 is absolute, <1 is percentage, eg 0.10 is 10%)", 0.10)
00092 , _infreq("-infreq", "frequency (>1 is absolute, <1 is percentage, eg 0.10 is 10%)", 0.10)
00093 , _bound1("-bound1", "bound parameters: eg GQ 0", IRT_GQ, 0)
00094 , _bound2("-bound2", "bound parameters: eg GQ 0", IRT_GQ, 0)
00095 , _alpha("-alpha", "alpha parameter", 0)
00096 , _beta("-beta", "beta parameter", 0)
00097 , _delta("-delta", "delta parameter", 0.0)
00098 , _epsilon("-epsilon", "epsilon parameter", 0.0) {
00099
00100
00101 solutions(0);
00102 iterations(10);
00103 c_d(0);
00104
00105
00106 _branching.add(INT_VAR_NONE, "input");
00107 _branching.add(INT_VAR_MIN_MIN, "min");
00108 _branching.add(INT_VAR_MIN_MAX, "minmax");
00109 _branching.add(INT_VAR_MAX_MIN, "maxmin");
00110 _branching.add(INT_VAR_MAX_MAX, "max");
00111 _branching.add(INT_VAR_SIZE_MIN, "size_min");
00112 _branching.add(INT_VAR_SIZE_MAX, "size_max");
00113 _branching.add(INT_VAR_DEGREE_MIN, "degree_min");
00114 _branching.add(INT_VAR_DEGREE_MAX, "degree_max");
00115 _branching.add(INT_VAR_SIZE_DEGREE_MIN, "size_degree_min");
00116 _branching.add(INT_VAR_SIZE_DEGREE_MAX, "size_degree_max");
00117 _branching.add(INT_VAR_REGRET_MIN_MIN, "regret_min");
00118 _branching.add(INT_VAR_REGRET_MIN_MAX, "regret_minmax");
00119 _branching.add(INT_VAR_REGRET_MAX_MIN, "regret_maxmin");
00120 _branching.add(INT_VAR_REGRET_MAX_MAX, "regret_max");
00121 branching(INT_VAR_DEGREE_MAX);
00122
00123 _branchval.add(INT_VAL_MIN, "min");
00124 _branchval.add(INT_VAL_MAX, "max");
00125 _branchval.add(INT_VAL_MED, "med");
00126 add(_branchval);
00127
00128
00129 _bound1.add(IRT_EQ, "EQ", "EQual");
00130 _bound1.add(IRT_NQ, "NQ", "Not Equal");
00131 _bound1.add(IRT_LQ, "LQ", "Less or eQual");
00132 _bound1.add(IRT_LE, "LE", "LEss");
00133 _bound1.add(IRT_GQ, "GQ", "Greater or eQual");
00134 _bound1.add(IRT_GR, "GR", "GReater");
00135 _bound2.add(IRT_EQ, "EQ", "EQual");
00136 _bound2.add(IRT_NQ, "NQ", "Not Equal");
00137 _bound2.add(IRT_LQ, "LQ", "Less or eQual");
00138 _bound2.add(IRT_LE, "LE", "LEss");
00139 _bound2.add(IRT_GQ, "GQ", "Greater or eQual");
00140 _bound2.add(IRT_GR, "GR", "GReater");
00141
00142 _output.add(OUT_NONE, "none", "do not output solutions");
00143 _output.add(OUT_FIMI, "normal", "print solutions (FIMI-style)");
00144 _output.add(OUT_FULL, "full", "print solutions (FIMI-style) and transaction sets");
00145 _output.add(OUT_CPVARS, "cpvars", "print the CP variables of the solutions)");
00146 add_specific(_output);
00147 add_specific(_cclause);
00148
00149 add_specific(_datafile);
00150 add_specific(_solfile);
00151 }
00152
00153
00154
00155 inline void add_specific(BaseOption& o) {
00156 _list_specific.push_back(&o);
00157 }
00158
00159
00160 inline void branchval(int v) {
00161 _branchval.value(v);
00162 }
00163 inline int branchval(void) const {
00164 return _branchval.value();
00165 }
00166
00167
00168 inline void output(int v) {
00169 _output.value(v);
00170
00171 }
00172 inline int output(void) const {
00173 return _output.value();
00174 }
00175
00176
00177
00178 inline void datafile(const char* s) {
00179 _datafile.value(s);
00180
00181 }
00182 inline const char* datafile(void) const {
00183 return _datafile.value();
00184 }
00185
00186
00187 inline void attrfile(const char* s) {
00188 _attrfile.value(s);
00189 add_specific(_attrfile);
00190 }
00191 inline const char* attrfile(void) const {
00192 return _attrfile.value();
00193 }
00194
00195
00196 inline void solfile(const char* s) {
00197 _solfile.value(s);
00198
00199 }
00200 inline const char* solfile(void) const {
00201 return _solfile.value();
00202 }
00203
00204
00205 inline void cclause(unsigned int v) {
00206 _cclause.value(v);
00207
00208 }
00209 inline unsigned int cclause(void) const {
00210 return _cclause.value();
00211 }
00212
00213
00214 inline void freq(float v) {
00215 _freq.value(v);
00216 add_specific(_freq);
00217 }
00218 inline unsigned int getFreq(unsigned int total) const {
00219 if (_freq.value() < 1) {
00220
00221 return (unsigned int)(floor((_freq.value()*total)+0.5));
00222 } else {
00223 return (unsigned int)_freq.value();
00224 }
00225 }
00226
00227 inline void infreq(float v) {
00228 _infreq.value(v);
00229 add_specific(_infreq);
00230 }
00231 inline unsigned int getInfreq(unsigned int total) const {
00232 if (_infreq.value() < 1) {
00233
00234 return (unsigned int)(_infreq.value()*total);
00235 } else {
00236 return (unsigned int)_infreq.value();
00237 }
00238 }
00239
00240
00241 inline void bound1_val(unsigned int v) {
00242 _bound1.value(v);
00243 add_specific(_bound1);
00244 }
00245 inline unsigned int bound1_val(void) const {
00246 return _bound1.value();
00247 }
00248 inline void bound1_op(int r) {
00249 _bound1.oper(r);
00250 }
00251 inline int bound1_op(void) const {
00252 return _bound1.oper();
00253 }
00254
00255 inline void bound2_val(unsigned int v) {
00256 _bound2.value(v);
00257 add_specific(_bound2);
00258 }
00259 inline unsigned int bound2_val(void) const {
00260 return _bound2.value();
00261 }
00262 inline void bound2_op(int r) {
00263 _bound2.oper(r);
00264 }
00265 inline int bound2_op(void) const {
00266 return _bound2.oper();
00267 }
00268
00269
00270 inline void alpha(unsigned int v) {
00271 _alpha.value(v);
00272 add_specific(_alpha);
00273 }
00274 inline unsigned int alpha(void) const {
00275 return _alpha.value();
00276 }
00277
00278 inline void beta(unsigned int v) {
00279 _beta.value(v);
00280 add_specific(_beta);
00281 }
00282 inline unsigned int beta(void) const {
00283 return _beta.value();
00284 }
00285
00286
00287 inline void delta(float v) {
00288 _delta.value(v);
00289 add_specific(_delta);
00290 }
00291 inline float delta(void) const {
00292 return _delta.value();
00293 }
00294
00295 inline void epsilon(float v) {
00296 _epsilon.value(v);
00297 add_specific(_epsilon);
00298 }
00299 inline float epsilon(void) const {
00300 return _epsilon.value();
00301 }
00302
00303
00304 inline void description(const char* s) {
00305 _description = s;
00306 }
00307
00308
00309 inline void usage(const char* s) {
00310 _usage = s;
00311 }
00312
00313
00314
00315 void parse(int& argc, char* argv[]) {
00316 int x = _list_specific.size();
00317
00318
00319 next:
00320 Options::parse(argc,argv);
00321
00322 for (int i = 0; i != x; i++)
00323 if (_list_specific[i]->parse(argc,argv))
00324 goto next;
00325 }
00326
00327 virtual void help(void) {
00328 Options::help();
00329
00330 std::cerr << "Specific options for " << name() << ":" << std::endl;
00331 int x = _list_specific.size();
00332 for (int i = 0; i != x; i++)
00333 _list_specific[i]->help();
00334
00335 std::cerr << "Description:" << std::endl
00336 << " " << _description << std::endl;
00337 std::cerr << "Usage example:" << std::endl
00338 << " " << "./" << name() << " " << _usage << std::endl;
00339 }
00340 };
00341
00342 #endif