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
00028 #ifndef _IE_RETTYPE_H
00029 #define _IE_RETTYPE_H
00030
00031 #include <basic_alltype.h>
00032 #include <termreason.h>
00033 #include <info_contents.h>
00034 #include <search_node.h>
00035 #include <delta.h>
00036 #include <api_exception.h>
00037 #include <certificate.h>
00038
00039 namespace coco {
00040
00042
00049 class ie_return_type
00050 {
00051 private:
00053 termination_reason termr;
00056 info_contents info;
00057
00059 std::list<delta> deltas;
00061 std::list<double> weights;
00063 std::list<certificate> certs;
00067 std::list<delta_id> _d;
00068
00069 public:
00071 ie_return_type() : termr(), info(), deltas(), weights(), certs(), _d() {}
00073 ie_return_type(const termination_reason& __t) : termr(__t), info(), deltas(),
00074 weights(), certs(), _d() {}
00077 ie_return_type(const delta_base* __d, double __w)
00078 : termr(), info(), deltas(), weights(1,__w),
00079 certs(1,certificate(no_certificate())), _d()
00080 { deltas.push_back(__d->new_copy()); }
00083 ie_return_type(const delta_base* __d, double __w, const certificate_base* __c)
00084 : termr(), info(), deltas(), weights(1,__w), certs(),
00085 _d()
00086 { deltas.push_back(__d->new_copy());
00087 certs.push_back(__c->new_copy()); }
00090 ie_return_type(const std::pair<delta_base*,double>& __d)
00091 : termr(), info(), deltas(), weights(1,__d.second),
00092 certs(1,certificate(no_certificate())), _d()
00093 { deltas.push_back(__d.first->new_copy()); }
00096 ie_return_type(const std::triple<delta_base*,double,certificate_base*>& __d)
00097 : termr(), info(), deltas(), weights(1,__d.second),
00098 certs(), _d()
00099 { deltas.push_back(__d.first->new_copy());
00100 certs.push_back(__d.third->new_copy()); }
00103 ie_return_type(delta __d, double __w) : termr(), info(), deltas(1,__d),
00104 weights(1,__w),
00105 certs(1,certificate(no_certificate())),
00106 _d() {}
00109 ie_return_type(delta __d, double __w, certificate __c) : termr(), info(),
00110 deltas(1,__d), weights(1,__w),
00111 certs(1,__c), _d() {}
00114 ie_return_type(const std::pair<delta,double>& __d) : termr(), info(),
00115 deltas(1,__d.first), weights(1,__d.second),
00116 certs(1,certificate(no_certificate())), _d() {}
00119 ie_return_type(const std::triple<delta,double,certificate>& __d)
00120 : termr(), info(), deltas(1,__d.first), weights(1,__d.second),
00121 certs(1,__d.third), _d() {}
00124 ie_return_type(const std::list<delta>& __d, const std::list<double>& __w) :
00125 termr(), info(), deltas(__d), weights(__w),
00126 certs(), _d()
00127 {
00128 no_certificate ncrt;
00129 for(unsigned int i=__d.size(); i>0; ++i)
00130 certs.push_back(certificate(ncrt));
00131 if(deltas.size() != weights.size())
00132 throw api_exception(apiee_internal, "ie_return_type: number of deltas different from number of weights!");
00133 }
00136 ie_return_type(const std::list<delta>& __d, const std::list<double>& __w,
00137 const std::list<certificate>& __c) :
00138 termr(), info(), deltas(__d), weights(__w), certs(__c), _d()
00139 {
00140 if(deltas.size() != weights.size())
00141 throw api_exception(apiee_internal, "ie_return_type: number of deltas different from number of weights!");
00142 if(deltas.size() != certs.size())
00143 throw api_exception(apiee_internal, "ie_return_type: number of deltas different from number of certificates!");
00144 }
00147 ie_return_type(const delta_base* __d, double __w,
00148 const termination_reason& __t)
00149 : termr(__t), info(), deltas(), weights(1,__w),
00150 certs(1,certificate(no_certificate())), _d()
00151 { deltas.push_back(__d->new_copy()); }
00155 ie_return_type(const delta_base* __d, double __w, const certificate_base* __c,
00156 const termination_reason& __t)
00157 : termr(__t), info(), deltas(), weights(1,__w), certs(), _d()
00158 { deltas.push_back(__d->new_copy());
00159 certs.push_back(__c->new_copy()); }
00163 ie_return_type(const std::pair<delta_base*,double>& __d,
00164 const termination_reason& __t)
00165 : termr(__t), info(), deltas(), weights(1,__d.second),
00166 certs(1,certificate(no_certificate())), _d()
00167 { deltas.push_back(__d.first->new_copy()); }
00171 ie_return_type(const std::triple<delta_base*,double,certificate_base*>& __d,
00172 const termination_reason& __t)
00173 : termr(__t), info(), deltas(), weights(1,__d.second), certs(),
00174 _d()
00175 { deltas.push_back(__d.first->new_copy());
00176 certs.push_back(__d.third->new_copy()); }
00179 ie_return_type(delta __d, double __w, const termination_reason& __t)
00180 : termr(__t), info(), deltas(1,__d), weights(1,__w),
00181 certs(1,certificate(no_certificate())), _d()
00182 {}
00186 ie_return_type(delta __d, double __w, certificate __c,
00187 const termination_reason& __t)
00188 : termr(__t), info(), deltas(1,__d), weights(1,__w),
00189 certs(1,__c), _d()
00190 {}
00194 ie_return_type(const std::pair<delta,double>& __d,
00195 const termination_reason& __t) : termr(__t), info(),
00196 deltas(1,__d.first), weights(1,__d.second),
00197 certs(1,certificate(no_certificate())), _d() {}
00201 ie_return_type(const std::triple<delta,double,certificate>& __d,
00202 const termination_reason& __t) : termr(__t), info(),
00203 deltas(1,__d.first), weights(1,__d.second),
00204 certs(1,__d.third), _d() {}
00208 ie_return_type(const std::list<delta>& __d, const std::list<double>& __w,
00209 const termination_reason& __t) :
00210 termr(__t), info(), deltas(__d), weights(__w),
00211 certs(), _d()
00212 {
00213 no_certificate ncrt;
00214 for(unsigned int i=__d.size(); i>0; ++i)
00215 certs.push_back(certificate(ncrt));
00216 if(deltas.size() != weights.size())
00217 throw "ie_return_type: number of deltas different from number of weights!";
00218 }
00222 ie_return_type(const std::list<delta>& __d, const std::list<double>& __w,
00223 const std::list<certificate>& __c,
00224 const termination_reason& __t) :
00225 termr(__t), info(), deltas(__d), weights(__w), certs(__c), _d()
00226 {
00227 if(deltas.size() != weights.size())
00228 throw "ie_return_type: number of deltas different from number of weights!";
00229 if(deltas.size() != certs.size())
00230 throw "ie_return_type: number of deltas different from number of certificates!";
00231 }
00233 ie_return_type(const ie_return_type& __r)
00234 : termr(__r.termr), info(__r.info), deltas(__r.deltas),
00235 weights(__r.weights), certs(__r.certs), _d() {}
00236
00238 virtual ~ie_return_type() {}
00239
00240 public:
00242 void set_termination_reason(const termination_reason& __t);
00243
00245 const termination_reason& term_reason() const;
00246
00248
00249 const info_contents& get_info() const;
00251
00253
00257 bool set_information(const std::string& iname, const basic_alltype& a,
00258 bool force = false);
00259 bool set_information(const char* iname, const basic_alltype& a,
00260 bool force = false);
00262
00264
00268 bool set_information_i(const std::string& iname, int i,
00269 const basic_alltype& a, bool force = false);
00270 bool set_information_i(const char* iname, int i,
00271 const basic_alltype& a, bool force = false);
00273
00275
00277 const basic_alltype& information(const std::string& iname) const;
00278 const basic_alltype& information(const char* iname) const;
00280
00282
00284 const basic_alltype& information(const std::string& iname, int i) const;
00285 const basic_alltype& information(const char* iname, int i) const;
00287
00289
00291 bool has_information(const std::string& __s) const;
00292 bool has_information(const char* __s) const;
00294
00296
00298 bool has_information(const std::string& __s, int i) const;
00299 bool has_information(const char* __s, int i) const;
00301
00303
00306 bool information_indices_set(const std::string& __s,
00307 std::vector<int>& __idx) const;
00308 bool information_indices_set(const char* __s,
00309 std::vector<int>& __idx) const;
00311
00313
00314 void unset_information(const std::string& __s);
00315 void unset_information(const char* __s);
00317
00319
00321 void unset_information(const std::string& __s, int i);
00322 void unset_information(const char* __s, int i);
00324
00326
00332 template <class _TS>
00333 bool retrieve_from_info(const std::string& __s,
00334 const std::vector<_TS>*& __b) const;
00335
00336 template <class _TS>
00337 bool retrieve_from_info(const std::string& __s, const linalg::matrix<_TS>*& __b) const;
00338
00339 template <class _TS>
00340 bool retrieve_from_info(const std::string& __s, _TS& __b) const;
00341
00342 template <class _TS>
00343 bool retrieve_from_info(const char* __s, const std::vector<_TS>*& __b) const;
00344
00345 template <class _TS>
00346 bool retrieve_from_info(const char* __s, const linalg::matrix<_TS>*& __b) const;
00347
00348 template <class _TS>
00349 bool retrieve_from_info(const char* __s, _TS& __b) const;
00351
00353
00360 template <class _TS>
00361 bool retrieve_from_info(const std::string& __s, const std::vector<_TS>*& __b,
00362 const std::vector<_TS>* __def) const;
00363
00364 template <class _TS>
00365 bool retrieve_from_info(const std::string& __s, const linalg::matrix<_TS>*& __b,
00366 const linalg::matrix<_TS>* __def) const;
00367
00368 template <class _TS>
00369 bool retrieve_from_info(const std::string& __s, _TS& __b,
00370 const _TS& __def) const;
00371
00372 template <class _TS>
00373 bool retrieve_from_info(const char* __s, const std::vector<_TS>*& __b,
00374 const std::vector<_TS>* __def) const;
00375
00376 template <class _TS>
00377 bool retrieve_from_info(const char* __s, const linalg::matrix<_TS>*& __b,
00378 const linalg::matrix<_TS>* __def) const;
00379
00380 template <class _TS>
00381 bool retrieve_from_info(const char* __s, _TS& __b, const _TS& __def) const;
00383
00385
00391 template <class _TS>
00392 bool retrieve_from_info_i(const std::string& __s, int i,
00393 const std::vector<_TS>*& __b) const;
00394
00395 template <class _TS>
00396 bool retrieve_from_info_i(const std::string& __s, int i,
00397 const linalg::matrix<_TS>*& __b) const;
00398
00399 template <class _TS>
00400 bool retrieve_from_info_i(const std::string& __s, int i, _TS& __b) const;
00401
00402 template <class _TS>
00403 bool retrieve_from_info_i(const char* __s, int i,
00404 const std::vector<_TS>*& __b) const;
00405
00406 template <class _TS>
00407 bool retrieve_from_info_i(const char* __s, int i,
00408 const linalg::matrix<_TS>*& __b) const;
00409
00410 template <class _TS>
00411 bool retrieve_from_info_i(const char* __s, int i, _TS& __b) const;
00413
00415
00422 template <class _TS>
00423 bool retrieve_from_info_i(const std::string& __s, int i,
00424 const std::vector<_TS>*& __b,
00425 const std::vector<_TS>* __def) const;
00426
00427 template <class _TS>
00428 bool retrieve_from_info_i(const std::string& __s, int i,
00429 const linalg::matrix<_TS>*& __b,
00430 const linalg::matrix<_TS>* __def) const;
00431
00432 template <class _TS>
00433 bool retrieve_from_info_i(const std::string& __s, int i, _TS& __b,
00434 const _TS& __def) const;
00435
00436 template <class _TS>
00437 bool retrieve_from_info_i(const char* __s, int i, const std::vector<_TS>*& __b,
00438 const std::vector<_TS>* __def) const;
00439
00440 template <class _TS>
00441 bool retrieve_from_info_i(const char* __s, int i, const linalg::matrix<_TS>*& __b,
00442 const linalg::matrix<_TS>* __def) const;
00443
00444 template <class _TS>
00445 bool retrieve_from_info_i(const char* __s, int i, _TS& __b,
00446 const _TS& __def) const;
00448
00450 ie_return_type operator+(const std::pair<delta_base*,double>& __d);
00452 ie_return_type& operator+=(const std::pair<delta_base*,double>& __d);
00455 ie_return_type operator+(
00456 const std::triple<delta_base*,double,certificate_base*>& __d);
00459 ie_return_type& operator+=(
00460 const std::triple<delta_base*,double,certificate_base*>& __d);
00461 #if 0
00462 ie_return_type operator+(const std::pair<delta,double>& __d);
00463 ie_return_type& operator+=(const std::pair<delta,double>& __d);
00464 #endif
00465
00466 ie_return_type& operator=(const ie_return_type& __d);
00467
00469 unsigned int n_deltas() const { return deltas.size(); }
00470
00477 const std::list<delta_id>& get(work_node& wn, double thresh=-COCO_INF);
00478
00484 void getd(std::list<delta>& dels, std::list<certificate>& certl,
00485 double thresh);
00486 };
00487
00488 }
00489
00490 #include <ie_rettype.hpp>
00491
00492 #endif