Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | mmcf: add some doc comments |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
78b057dcc96eed5de8d171c7cb2cbde7 |
| User & Date: | fifr 2021-07-01 07:18:26.841 |
Context
|
2021-07-01
| ||
| 07:27 | mmcf: remove now unsupported `multimodel` option check-in: fa31409d9b user: fifr tags: trunk | |
| 07:18 | mmcf: add some doc comments check-in: 78b057dcc9 user: fifr tags: trunk | |
|
2021-06-30
| ||
| 20:22 | mmcf: simplify reading netgen instances check-in: ff08b91f61 user: fifr tags: trunk | |
Changes
Changes to src/mcf/problem.rs.
| ︙ | ︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
/// Type of errors of the MMCFProblem.
pub type Error = crate::mcf::solver::Error;
/// Result type of the MMCFProblem.
pub type Result<T> = result::Result<T, Error>;
#[derive(Clone, Copy, Debug)]
struct ArcInfo {
arc: usize,
src: usize,
snk: usize,
}
#[derive(Clone, Copy, Debug)]
struct Elem {
ind: usize,
val: Real,
}
/// A single MMCF subproblem, i.e. one network.
struct Subproblem {
/// The (net, cost) pair.
net: mcf::NetSpxSolver,
c: DVector,
}
/// Constraint data of one subproblem.
struct SubData {
lhs: Vec<Vec<Elem>>,
| > > > > > > > > > > > | > > > > > > > > > > > > > > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
/// Type of errors of the MMCFProblem.
pub type Error = crate::mcf::solver::Error;
/// Result type of the MMCFProblem.
pub type Result<T> = result::Result<T, Error>;
/// Data of a single arc read from an instance file.
#[derive(Clone, Copy, Debug)]
struct ArcInfo {
/// The number of this arc
arc: usize,
/// The source node number
src: usize,
/// The sink node number
snk: usize,
}
/// A single coefficient in a linear coupling constraint
#[derive(Clone, Copy, Debug)]
struct Elem {
/// The variable (arc) index
ind: usize,
/// The coefficient
val: Real,
}
/// A single MMCF subproblem, i.e. one network.
struct Subproblem {
/// The (net, cost) pair.
net: mcf::NetSpxSolver,
c: DVector,
}
/// Constraint data of one subproblem.
///
/// This information is used to create the augmented objective function, i.e.
/// cbase - lhs'* y as well as the constant term rhs' * y
struct SubData {
/// The lhs of all constraints. For each constraint this is a list of coefficients.
lhs: Vec<Vec<Elem>>,
/// The right-hand side of each constraint
rhs: DVector,
/// The base costs of each arc
cbase: DVector,
}
unsafe impl Send for Subproblem {}
unsafe impl Sync for Subproblem {}
/// A single multi-commodity flow problem instance.
///
/// The current implementation always keeps a list of all potential
/// coupling constraints but, depending on the separation choice, the
/// may not be in the model. If separation is used a list of "active"
/// constraints is maintained holding the list of those constraints
/// that are in the model. "inactive" constraints may be separated
/// later on.
pub struct MMCFProblem {
pub multimodel: bool,
/// The list of subproblems (single network flows)
subs: Vec<Arc<RwLock<Subproblem>>>,
/// The coupling constraints for each subproblem.
subdatas: Vec<Arc<SubData>>,
/// The list of currently active constraints
active_constraints: Arc<RwLock<Vec<usize>>>,
/// The list of inactive constraints
inactive_constraints: Arc<RwLock<Vec<usize>>>,
/// The thread pool for parallel evaluation
pool: Option<ThreadPool>,
}
impl Subproblem {
fn evaluate<I>(&mut self, data: &SubData, y: &[Real], active: I) -> Result<(Real, DVector, DVector)>
where
I: IntoIterator<Item = usize>,
|
| ︙ | ︙ | |||
331 332 333 334 335 336 337 |
subdatas,
active_constraints: Arc::new(RwLock::new((0..ncaps).collect())),
inactive_constraints: Arc::new(RwLock::new(vec![])),
pool: None,
})
}
| > > | > | 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
subdatas,
active_constraints: Arc::new(RwLock::new((0..ncaps).collect())),
inactive_constraints: Arc::new(RwLock::new(vec![])),
pool: None,
})
}
/// Set whether coupling constraints should be separated.
///
/// If `separate` is true than all constraints will be made
/// inactive, otherwise all constraints will be made active.
pub fn set_separate_constraints(&mut self, separate: bool) {
let nconstrs = self.subdatas[0].lhs.len();
if separate {
self.active_constraints.write().unwrap().clear();
self.inactive_constraints = Arc::new(RwLock::new((0..nconstrs).collect()));
} else {
self.active_constraints = Arc::new(RwLock::new((0..nconstrs).collect()));
|
| ︙ | ︙ |