Slave function for portfolio search
| 213 | } |
| 214 | /// Slave function for portfolio search |
| 215 | virtual bool slave(const MetaInfo& mi) { |
| 216 | if (mi.type() == MetaInfo::PORTFOLIO) { |
| 217 | double tbf = opt.tbf(); |
| 218 | Rnd r(seeds[mi.asset() % n_seeds]); |
| 219 | switch (opt.branching()) { |
| 220 | case BRANCH_SIZE: |
| 221 | { |
| 222 | auto tbl = |
| 223 | [tbf] (const Space&, double w, double b) { |
| 224 | assert(w >= b); |
| 225 | return b + (w - b) * tbf; |
| 226 | }; |
| 227 | branch(*this, e, tiebreak(INT_VAR_SIZE_MIN(tbl), |
| 228 | INT_VAR_RND(r)), |
| 229 | INT_VAL_MIN()); |
| 230 | } |
| 231 | break; |
| 232 | case BRANCH_AFC_SIZE: |
| 233 | { |
| 234 | auto tbl = |
| 235 | [tbf] (const Space&, double w, double b) { |
| 236 | assert(b >= w); |
| 237 | return b - (b - w) * tbf; |
| 238 | }; |
| 239 | branch(*this, e, tiebreak(INT_VAR_AFC_SIZE_MAX(opt.decay(), tbl), |
| 240 | INT_VAR_RND(r)), |
| 241 | INT_VAL_MIN()); |
| 242 | } |
| 243 | break; |
| 244 | default: ; |
| 245 | } |
| 246 | } |
| 247 | return true; |
| 248 | } |
| 249 | /// Constructor for cloning \a s |
| 250 | QCP(QCP& s) |
| 251 | : Script(s), opt(s.opt), spec(s.spec) { |
nothing calls this directly
no test coverage detected