Exemple #1
0
 forceinline void
 TaskTree<TaskView,Node>::update(int i, bool l) {
   if (l)
     i = _leaf[i];
   assert(!n_root(i));
   do {
     i = n_parent(i);
     node[i].update(node[n_left(i)],node[n_right(i)]);
   } while (!n_root(i));
 }
Exemple #2
0
  forceinline long long int
  ExtOmegaTree<TaskView>::env(int i) {
    // Enter task i
    leaf(i).e = tasks[i].e(); 
    leaf(i).env = 
      static_cast<long long int>(c)*tasks[i].est()+tasks[i].e();
    leaf(i).cenv = 
      static_cast<long long int>(c-ci)*tasks[i].est()+tasks[i].e();
    TaskTree<TaskView,ExtOmegaNode>::update(i);

    // Perform computation of node for task with minest
    int met = 0;
    {
      long long int e = 0;
      while (!n_leaf(met)) {
        if (plus(node[n_right(met)].cenv,e) > 
            static_cast<long long int>(c-ci) * tasks[i].lct()) {
          met = n_right(met);
        } else {
          e += node[n_right(met)].e; met = n_left(met);
        }
      }
    }

    /*
     * The following idea to compute the cut in one go is taken from:
     * Joseph Scott, Filtering Algorithms for Discrete Resources, 
     * Master Thesis, Uppsala University, 2010 (in preparation).
     */

    // Now perform split from leaf met upwards
    long long int a_e = node[met].e;
    long long int a_env = node[met].env;
    long long int b_e = 0;

    while (!n_root(met)) {
      if (left(met)) {
        b_e += node[n_right(n_parent(met))].e;
      } else {
        a_env = std::max(a_env, plus(node[n_left(n_parent(met))].env,a_e));
        a_e += node[n_left(n_parent(met))].e;
      }
      met = n_parent(met);
    }

    return plus(a_env,b_e);
  }
Exemple #3
0
 forceinline bool
 TaskTree<TaskView,Node>::right(int i) {
   assert(!n_root(i));
   // A left node has an even number
   return (i & 1) == 0;
 }
Exemple #4
0
 forceinline bool
 TaskTree<TaskView,Node>::left(int i) {
   assert(!n_root(i));
   // A left node has an odd number
   return (i & 1) != 0;
 }