Struct pcp::term::sum::Sum

source ·
pub struct Sum<VStore> { /* private fields */ }

Implementations§

Examples found in repository?
src/libpcp/term/sum.rs (line 40)
39
40
41
  fn clone(&self) -> Self {
    Sum::new(self.vars.iter().map(|v| v.bclone()).collect())
  }
More examples
Hide additional examples
src/libpcp/propagators/cumulative.rs (line 98)
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  pub fn join<CStore>(&mut self, vstore: &mut VStore, cstore: &mut CStore) where
    CStore: IntCStore<VStore> + 'static
  {
    let tasks = self.starts.len();
    // Special case where only one task needs to be scheduled.
    if tasks == 1 {
      // c >= r[j]
      cstore.alloc(Box::new(x_geq_y(self.capacity_var(), self.resource_at(0))));
    }
    else {
      // forall( j in tasks ) (...)
      for j in 0..tasks {
        let mut resource_vars = vec![];
        self.intermediate.push(vec![]);
        for i in 0..tasks {
          if i != j {
            // conj <-> s[i] <= s[j] /\ s[j] < s[i] + d[i]
            let conj = Box::new(Conjunction::new(vec![
              // s[i] <= s[j]
              Box::new(x_leq_y(self.start_at(i), self.start_at(j))),
              // s[j] < s[i] + d[i]
              Box::new(XLessYPlusZ::new(self.start_at(j), self.start_at(i), self.duration_at(i)))]));

            // bi <-> conj
            let bi = Boolean::new(vstore);
            let equiv = equivalence(Box::new(bi.clone()), conj);
            cstore.alloc(equiv);

            // r = bi * r[i]
            let ri = self.resource_at(i);
            let ri_ub = ri.read(vstore).upper();
            let r_dom = Domain::new(Bound::zero(), ri_ub);
            // let hole = Domain::new(Bound::one(), ri_ub.clone() - Bound::one());
            let r = vstore.alloc(r_dom);
            self.intermediate.last_mut().unwrap().push(r.index());
            let r = Box::new(r) as Var<VStore>;
            cstore.alloc(Box::new(XEqYMulZ::new(r.bclone(), Box::new(bi), ri)));
            resource_vars.push(r);
          }
        }
        //  sum( i in tasks where i != j )(...)
        let sum = Box::new(Sum::new(resource_vars));
        // c >= r[j] + sum
        cstore.alloc(Box::new(x_geq_y_plus_z(self.capacity_var(), self.resource_at(j), sum)));
      }
    }
  }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.