Add term `n*x` to the linear expression
(&mut self, x: Rc<Path>, n: Integer)
| 63 | |
| 64 | /// Add term `n*x` to the linear expression |
| 65 | pub fn add_term(&mut self, x: Rc<Path>, n: Integer) { |
| 66 | if let Some(num) = self.cof_map.get(&x) { |
| 67 | let r = num + n; |
| 68 | if r == 0 { |
| 69 | self.cof_map.remove(&x); |
| 70 | } else { |
| 71 | self.cof_map.insert(x.clone(), r); |
| 72 | } |
| 73 | } else if n != 0 { |
| 74 | self.cof_map.insert(x.clone(), n); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | impl<Num> From<Num> for LinearExpression |