00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _CJLS_WT_H_
00021 #define _CJLS_WT_H_ 1
00022
00023 #include <string>
00024 #include "CjLinkSelector.hh"
00025
00026 namespace jmitie {
00027 namespace corelib {
00028 class CjLS_wt : public CjLinkSelector {
00029 public:
00030
00031 static std::string getName_static() { return "wt"; }
00032 virtual std::string getName() const { return getName_static(); }
00033 std::string getProperty(const std::string & prop) const { return getProperty_static(prop); }
00034 static std::string getProperty_static(const std::string & opt) {
00035 if(opt=="desc") return "Selects a link based on its weight.";
00036 if(opt=="usage") return getProperty_static("desc") + "\n" +
00037 "(min|max|pref)\tSpecifies whether to select the link with the absolute minimum or maximum, or whether to use roulette wheel selection preferring links with a high weight^exp value.\n" \
00038 "[exp=float]\tThe optional exponent of the link weight when using pref selection.\n";
00039 throw std::invalid_argument("CjLS_wt::getProperty_static(" + opt + "): Unknown property requested.");
00040 }
00041
00042 CjLS_wt(std::string args, const ctor_va_t & va );
00043
00044 virtual bool selectLink( select_arg_t &, unsigned int & from, unsigned int & to );
00045 virtual ~CjLS_wt() {};
00046
00047 protected:
00048 enum sel_t { NOTSET = 0, MIN, MAX, PREF };
00049 sel_t selecta;
00050 double m_exp;
00051 bool m_exp_set;
00052 bool m_dupe_link_ok;
00053
00054 private:
00055
00056 };
00057 }
00058 }
00059
00060 #endif // _CJLS_WT_H_