105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
-
+
|
/// The coefficient
val: Real,
}
/// A single MMCF subproblem, i.e. one network.
struct Subproblem {
/// The (net, cost) pair.
net: mcf::NetSpxSolver,
net: Box<dyn mcf::Solver>,
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
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
-
+
|
return Err(ExtraNodField);
}
}
// read nodes
let mut nets = Vec::with_capacity(ncom);
for i in 0..ncom {
nets.push(mcf::NetSpxSolver::new(i, nnodes)?)
nets.push(S::new(i, nnodes)?)
}
for line in File::open(&format!("{}.sup", basename)).map(BufReader::new)?.lines() {
let line = line?;
let mut data = line.split_whitespace();
let node = data.next().ok_or(MissingSupField("node"))?.parse::<usize>()?;
let com = data.next().ok_or(MissingSupField("com"))?.parse::<usize>()?;
let supply = data.next().ok_or(MissingSupField("supply"))?.parse::<Real>()?;
|
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
-
+
+
+
+
|
.zip(std::iter::once(rhs).chain(std::iter::repeat(dvec![])))
.map(|((cbase, lhs), rhs)| SubData { lhs, rhs, cbase })
.map(Arc::new)
.collect();
let subproblems = nets
.into_iter()
.map(|net| Subproblem { net, c: dvec![] })
.map(|net| Subproblem {
net: Box::new(net),
c: dvec![],
})
.map(RwLock::new)
.map(Arc::new)
.collect();
Ok(MMCFProblem {
subs: subproblems,
subdatas,
|