15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
//
use crate::{DVector, Minorant, Real};
use std::error::Error;
use std::result;
// /// Error type for master problems.
// #[derive(Debug)]
// pub enum MasterProblemError {
// /// Extension of the subgradient failed with some user error.
// SubgradientExtension(Box<dyn Error + Send + Sync>),
// /// No minorants available when solving the master problem
// NoMinorants,
// /// An error in the solver backend occurred.
// Solver(Box<dyn Error + Send + Sync>),
// /// A custom error (specific to the master problem solver) occurred.
// Custom(Box<dyn Error + Send + Sync>),
// }
// impl fmt::Display for MasterProblemError {
// fn fmt(&self, fmt: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
// use self::MasterProblemError::*;
// match self {
// SubgradientExtension(err) => write!(fmt, "Subgradient extension failed: {}", err),
// NoMinorants => write!(fmt, "No minorants when solving the master problem"),
// Solver(err) => write!(fmt, "Solver error: {}", err),
// Custom(err) => err.fmt(fmt),
// }
// }
// }
// impl Error for MasterProblemError {
// fn source(&self) -> Option<&(dyn Error + 'static)> {
// use self::MasterProblemError::*;
// match self {
// SubgradientExtension(err) => Some(err.as_ref()),
// Solver(err) | Custom(err) => Some(err.as_ref()),
// NoMinorants => None,
// }
// }
// }
/// Callback for subgradient extensions.
pub type SubgradientExtension<'a, I> =
FnMut(usize, I, &[usize]) -> result::Result<DVector, Box<dyn Error + Send + Sync + 'static>> + 'a;
pub trait MasterProblem {
/// Unique index for a minorant.
type MinorantIndex: Copy + Eq;
|