1
2
3
4
5
6
7
8
|
1
2
3
4
5
6
7
8
|
-
+
|
// Copyright (c) 2016, 2017 Frank Fischer <frank-fischer@shadow-soft.de>
// Copyright (c) 2016, 2017, 2019 Frank Fischer <frank-fischer@shadow-soft.de>
//
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
-
+
-
+
|
Solver(err) => write!(fmt, "Solver error: {}", err),
Custom(err) => err.fmt(fmt),
}
}
}
impl Error for MasterProblemError {
fn cause(&self) -> Option<&Error> {
fn cause(&self) -> Option<&dyn Error> {
use self::MasterProblemError::*;
match self {
SubgradientExtension(err) | Solver(err) | Custom(err) => Some(err.as_ref()),
NoMinorants => None,
}
}
}
/// Result type of master problems.
pub type Result<T> = result::Result<T, MasterProblemError>;
/// Callback for subgradient extensions.
pub type SubgradientExtension<'a, I> = FnMut(usize, I, &[usize]) -> result::Result<DVector, Box<dyn Error>> + 'a;
pub type SubgradientExtension<'a, I> = dyn FnMut(usize, I, &[usize]) -> result::Result<DVector, Box<dyn Error>> + 'a;
pub trait MasterProblem {
/// Unique index for a minorant.
type MinorantIndex: Copy + Eq;
/// Set the number of subproblems.
fn set_num_subproblems(&mut self, n: usize) -> Result<()>;
|