Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | mmcf: remove now unsupported `multimodel` option |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
fa31409d9b31078d5f897e472c350a30 |
| User & Date: | fifr 2021-07-01 07:27:12.423 |
Context
|
2021-07-01
| ||
| 12:03 | examples/mmcf: remove unneeded `MinorantIndex` specification check-in: bea4fb8acd user: fifr tags: trunk | |
| 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 | |
Changes
Changes to examples/mmcf.rs.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
slv.weighter.set_weight_bounds(1e-1, 100.0);
slv.terminator.termination_precision = 1e-6;
slv.solve()?;
let costs: f64 = (0..slv.problem().num_subproblems())
.map(|i| {
let aggr_primals = slv.aggregated_primal(i).unwrap();
| | | | 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 70 71 72 73 74 75 76 |
slv.weighter.set_weight_bounds(1e-1, 100.0);
slv.terminator.termination_precision = 1e-6;
slv.solve()?;
let costs: f64 = (0..slv.problem().num_subproblems())
.map(|i| {
let aggr_primals = slv.aggregated_primal(i).unwrap();
slv.problem().get_primal_costs(i, &aggr_primals)
})
.sum();
info!("Primal costs: {}", costs);
Ok(())
}
fn solve_sync<M>(master: M, mmcf: MMCFProblem) -> Result<(), Box<dyn Error>>
where
M: Builder<Minorant>,
M::MasterProblem: MasterProblem<Minorant, MinorantIndex = usize>,
{
let mut slv = SyncSolver::<_, StandardTerminator, HKWeighter, M>::with_master(mmcf, master);
slv.weighter.set_weight_bounds(1e-1, 100.0);
slv.terminator.termination_precision = 1e-6;
slv.solve()?;
let costs: f64 = (0..slv.problem().num_subproblems())
.map(|i| {
let aggr_primals = slv.aggregated_primal(i).unwrap();
slv.problem().get_primal_costs(i, &aggr_primals)
})
.sum();
info!("Primal costs: {}", costs);
Ok(())
}
fn main() -> Result<(), Box<dyn Error>> {
|
| ︙ | ︙ | |||
121 122 123 124 125 126 127 |
info!("Use rs-graph network simplex solver");
MMCFProblem::read_mnetgen_with_solver::<mcf::NetSpxSolver>(&filename)?
} else {
info!("Use Cplex network simplex solver");
MMCFProblem::read_mnetgen_with_solver::<mcf::CplexSolver>(&filename)?
};
mmcf.set_separate_constraints(args.separate);
| < | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
info!("Use rs-graph network simplex solver");
MMCFProblem::read_mnetgen_with_solver::<mcf::NetSpxSolver>(&filename)?
} else {
info!("Use Cplex network simplex solver");
MMCFProblem::read_mnetgen_with_solver::<mcf::CplexSolver>(&filename)?
};
mmcf.set_separate_constraints(args.separate);
let mut master = FullMasterBuilder::default();
if args.aggregated {
master.max_bundle_size(if args.bundle_size <= 1 { 50 } else { args.bundle_size });
master.use_full_aggregation();
} else {
master.max_bundle_size(if args.bundle_size <= 1 { 5 } else { args.bundle_size });
|
| ︙ | ︙ | |||
148 149 150 151 152 153 154 |
params.set_l_guess_factor(args.l_guess_factor);
solve_parallel(master, mmcf, params)?;
}
} else {
let mut mmcf = MMCFProblem::read_mnetgen(&filename)?;
mmcf.set_separate_constraints(args.separate);
| < | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
params.set_l_guess_factor(args.l_guess_factor);
solve_parallel(master, mmcf, params)?;
}
} else {
let mut mmcf = MMCFProblem::read_mnetgen(&filename)?;
mmcf.set_separate_constraints(args.separate);
let master = MinimalMasterBuilder::default();
if args.sync {
solve_sync(master, mmcf)?;
} else {
let mut params = Parameters::default();
params.guess_model = if args.nearest_guess {
|
| ︙ | ︙ |
Changes to src/mcf/problem.rs.
| ︙ | ︙ | |||
133 134 135 136 137 138 139 |
/// 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 {
| < < | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
/// 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 {
/// 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
|
| ︙ | ︙ | |||
347 348 349 350 351 352 353 |
.into_iter()
.map(|net| Subproblem { net, c: dvec![] })
.map(RwLock::new)
.map(Arc::new)
.collect();
Ok(MMCFProblem {
| < | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
.into_iter()
.map(|net| Subproblem { net, c: dvec![] })
.map(RwLock::new)
.map(Arc::new)
.collect();
Ok(MMCFProblem {
subs: subproblems,
subdatas,
active_constraints: Arc::new(RwLock::new((0..ncaps).collect())),
inactive_constraints: Arc::new(RwLock::new(vec![])),
pool: None,
})
}
|
| ︙ | ︙ | |||
372 373 374 375 376 377 378 |
} else {
self.active_constraints = Arc::new(RwLock::new((0..nconstrs).collect()));
self.inactive_constraints.write().unwrap().clear();
}
}
/// Compute costs for a primal solution.
| | < | < < < < < < < < < | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
} else {
self.active_constraints = Arc::new(RwLock::new((0..nconstrs).collect()));
self.inactive_constraints.write().unwrap().clear();
}
}
/// Compute costs for a primal solution.
pub fn get_primal_costs(&self, fidx: usize, primals: &DVector) -> Real {
let sub = &self.subdatas[fidx];
primals.iter().enumerate().map(|(i, x)| x * sub.cbase[i]).sum()
}
/// Aggregate primal vectors.
pub fn aggregate_primals_ref(&self, primals: &[(Real, &Vec<DVector>)]) -> Vec<DVector> {
let mut aggr = primals[0]
.1
.iter()
|
| ︙ | ︙ |