RsBundle  Diff

Differences From Artifact [dbdd4928cb]:

  • File src/solver.rs — part of check-in [8d6b894491] at 2016-10-10 14:43:45 on branch trunk — Add `IterationInfo` to update state. (user: fifr size: 29785)

To Artifact [138b031a5e]:

  • File src/solver.rs — part of check-in [2b281a925b] at 2016-10-10 20:33:03 on branch trunk — solver: Add `cur_y` and `nxt_y` fields to `UpdateState`. (user: fifr size: 30462)

306
307
308
309
310
311
312






313
314
315
316
317
318
319
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325







+
+
+
+
+
+







pub struct UpdateState<'a, Pr:'a> {
    /// Current model minorants.
    minorants: &'a [Vec<MinorantInfo<Pr>>],
    /// The last step type.
    pub step: Step,
    /// Iteration information.
    pub iteration_info: &'a [IterationInfo],
    /// The current candidate. If the step was a descent step, this is
    /// the new center.
    pub nxt_y: &'a DVector,
    /// The center. IF the step was a descent step, this is the old
    /// center.
    pub cur_y: &'a DVector,
}

impl<'a, Pr:'a> UpdateState<'a, Pr> {
    pub fn aggregated_primals(&self, subproblem : usize) -> Vec<(Real, &Pr)> {
        self.minorants[subproblem].iter().map(|m| {
            (m.multiplier, m.primal.as_ref().unwrap())
        }).collect()
531
532
533
534
535
536
537

538
539
540
541














542
543
544
545
546
547
548
537
538
539
540
541
542
543
544




545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565







+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+







    }

    /// Called to update the problem.
    ///
    /// Calling this function typically triggers the problem to
    /// separate new constraints depending on the current solution.
    fn update_problem(&mut self, term: Step) -> Result<bool> {
        let updates = {
        let state = UpdateState {minorants: &self.minorants, step: term, iteration_info: &self.iterinfos};
        let updates = match self.problem.update(&state) {
            Ok(updates) => updates,
            Err(err) => return Err(Error::Update(Box::new(err))),
            let state = UpdateState {
                minorants: &self.minorants,
                step: term,
                iteration_info: &self.iterinfos,
                // this is a dirty trick: when updating the center, we
                // simply swapped the `cur_*` fields with the `nxt_*`
                // fields
                cur_y: if term == Step::Descent { &self.nxt_y } else { &self.cur_y },
                nxt_y: if term == Step::Descent { &self.cur_y } else { &self.nxt_y },
            };
            match self.problem.update(&state) {
                Ok(updates) => updates,
                Err(err) => return Err(Error::Update(Box::new(err))),
            }
        };

        let mut newvars = Vec::with_capacity(updates.len());
        for u in updates {
            match u {
                Update::AddVariable{lower, upper} => {
                    newvars.push((lower, upper));