RsBundle  Diff

Differences From Artifact [f155d33946]:

  • File src/solver.rs — part of check-in [ee9e94be2a] at 2018-08-30 09:04:44 on branch modifyprimals — Add `Update::ModifyPrimal` update information (user: fifr size: 36987)

To Artifact [e29d89e899]:

  • File src/solver.rs — part of check-in [a5c90ab126] at 2018-08-30 11:07:51 on branch modifyprimals — Implement `Update::ModifyPrimals` (user: fifr size: 37929)

46
47
48
49
50
51
52


53
54
55
56
57
58
59
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61







+
+







    Parameter(ParameterError),
    /// The lower bound of a variable is larger than the upper bound.
    InvalidBounds { lower: Real, upper: Real },
    /// The value of a variable is outside its bounds.
    ViolatedBounds { lower: Real, upper: Real, value: Real },
    /// The variable index is out of bounds.
    InvalidVariable { index: usize, nvars: usize },
    /// A subproblem index is out of bounds.
    InvalidSubproblem { subproblem: usize, nsubs: usize },
    /// Iteration limit has been reached.
    IterationLimit { limit: usize },
}

impl<E: fmt::Display> fmt::Display for SolverError<E> {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
        use self::SolverError::*;
69
70
71
72
73
74
75





76
77
78
79
80
81
82
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89







+
+
+
+
+







                fmt,
                "Violated bounds, lower:{}, upper:{}, value:{}",
                lower, upper, value
            ),
            InvalidVariable { index, nvars } => {
                write!(fmt, "Variable index out of bounds, got:{} must be < {}", index, nvars)
            }
            InvalidSubproblem { subproblem, nsubs } => write!(
                fmt,
                "Subproblem index out of bounds, got:{} must be < {}",
                subproblem, nsubs
            ),
            IterationLimit { limit } => write!(fmt, "The iteration limit of {} has been reached.", limit),
        }
    }
}

impl<E: Error> Error for SolverError<E> {
    fn cause(&self) -> Option<&Error> {
675
676
677
678
679
680
681
682















683
684
685
686
687
688
689
682
683
684
685
686
687
688

689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710







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







                    }
                    let (lower, upper) = self.bounds[index];
                    if value < lower || value > upper {
                        return Err(SolverError::ViolatedBounds { lower, upper, value });
                    }
                    newvars.push((Some(index), lower - value, upper - value, value));
                }
                Update::ModifyPrimal(_modify) => unimplemented!(),
                Update::ModifyPrimals { subproblem, modify } => {
                    if subproblem >= self.minorants.len() {
                        return Err(SolverError::InvalidSubproblem {
                            subproblem: subproblem,
                            nsubs: self.minorants.len(),
                        });
                    }
                    for m in &mut self.minorants[subproblem] {
                        if let Some(ref mut p) = m.primal {
                            if let Err(err) = modify(p) {
                                return Err(SolverError::Update(err));;
                            }
                        }
                    }
                }
            }
        }

        if !newvars.is_empty() {
            let problem = &mut self.problem;
            let minorants = &self.minorants;
            self.master