Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Move `parallel` to `solver::sync` |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | restructure |
| Files: | files | file ages | folders |
| SHA1: |
62c311d2a4533203087023457738e137 |
| User & Date: | fifr 2019-07-30 07:40:07.612 |
Context
|
2019-07-30
| ||
| 08:01 | Rearrange master problem module check-in: d5eed55bb2 user: fifr tags: restructure | |
| 07:40 | Move `parallel` to `solver::sync` check-in: 62c311d2a4 user: fifr tags: restructure | |
| 07:25 | Remove old sequential solver check-in: b194454b53 user: fifr tags: restructure | |
Changes
Changes to examples/cflp.rs.
| ︙ | ︙ | |||
27 28 29 30 31 32 33 |
use std::io::Write as _;
use std::sync::Arc;
use env_logger::{self, fmt::Color};
use ordered_float::NotNan;
use threadpool::ThreadPool;
| < | | < | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
use std::io::Write as _;
use std::sync::Arc;
use env_logger::{self, fmt::Color};
use ordered_float::NotNan;
use threadpool::ThreadPool;
use bundle::problem::{EvalResult, FirstOrderProblem as ParallelProblem, ResultSender};
use bundle::solver::sync::{DefaultSolver, NoBundleSolver};
use bundle::{dvec, DVector, Minorant, Real};
const Nfac: usize = 3;
const Ncus: usize = 5;
const F: [Real; Nfac] = [1000.0, 1000.0, 1000.0];
const CAP: [Real; Nfac] = [500.0, 500.0, 500.0];
const C: [[Real; Ncus]; Nfac] = [
|
| ︙ | ︙ | |||
250 251 252 253 254 255 256 |
let (args, _) = opts! {
synopsis "Solver a simple capacitated facility location problem";
opt minimal:bool, desc:"Use the minimal master model";
}
.parse_or_exit();
if !args.minimal {
| | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
let (args, _) = opts! {
synopsis "Solver a simple capacitated facility location problem";
opt minimal:bool, desc:"Use the minimal master model";
}
.parse_or_exit();
if !args.minimal {
let mut slv = DefaultSolver::<_>::new(CFLProblem::new());
slv.terminator.termination_precision = 1e-9;
slv.master.max_bundle_size = 5;
slv.solve()?;
show_primals(|i| slv.aggregated_primal(i).unwrap())?;
} else {
let mut slv = NoBundleSolver::<_>::new(CFLProblem::new());
slv.terminator.termination_precision = 1e-5;
slv.solve()?;
show_primals(|i| slv.aggregated_primal(i).unwrap())?;
}
Ok(())
}
|
Changes to examples/mmcf.rs.
| ︙ | ︙ | |||
19 20 21 22 23 24 25 |
use env_logger::fmt::Color;
use log::{info, Level};
use rustop::opts;
use std::io::Write;
use bundle::master::{Builder as MasterBuilder, MasterProblem};
use bundle::mcf::MMCFProblem;
| | | | 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 |
use env_logger::fmt::Color;
use log::{info, Level};
use rustop::opts;
use std::io::Write;
use bundle::master::{Builder as MasterBuilder, MasterProblem};
use bundle::mcf::MMCFProblem;
use bundle::solver::sync::Solver;
use bundle::{terminator::StandardTerminator, weighter::HKWeighter};
use bundle::{FullMasterBuilder, MinimalMasterBuilder};
use std::error::Error;
use std::result::Result;
fn solve_parallel<M>(master: M, mmcf: MMCFProblem) -> Result<(), Box<dyn Error>>
where
M: MasterBuilder,
M::MasterProblem: MasterProblem<MinorantIndex = usize>,
{
let mut slv = Solver::<_, 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();
|
| ︙ | ︙ |
Changes to examples/quadratic.rs.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 |
use env_logger::fmt::Color;
use log::{debug, Level};
use rustop::opts;
use std::io::Write;
use std::sync::Arc;
use std::thread;
| < | | < | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
use env_logger::fmt::Color;
use log::{debug, Level};
use rustop::opts;
use std::io::Write;
use std::sync::Arc;
use std::thread;
use bundle::problem::{EvalResult, FirstOrderProblem as ParallelProblem, ResultSender};
use bundle::solver::sync::{DefaultSolver, NoBundleSolver};
use bundle::{DVector, Minorant, Real};
#[derive(Clone)]
struct QuadraticProblem {
a: [[Real; 2]; 2],
b: [Real; 2],
c: Real,
|
| ︙ | ︙ | |||
139 140 141 142 143 144 145 |
synopsis "Solver a simple quadratic optimization problem";
opt minimal:bool, desc:"Use the minimal master model";
}
.parse_or_exit();
let f = QuadraticProblem::new();
if !args.minimal {
| | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
synopsis "Solver a simple quadratic optimization problem";
opt minimal:bool, desc:"Use the minimal master model";
}
.parse_or_exit();
let f = QuadraticProblem::new();
if !args.minimal {
let mut solver = DefaultSolver::<_>::new(f);
solver.solve().map_err(|e| format!("{}", e))?;
} else {
let mut solver = NoBundleSolver::<_>::new(f);
solver.solve().map_err(|e| format!("{}", e))?;
}
Ok(())
}
|
Changes to src/lib.rs.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 |
pub mod vector;
pub use crate::vector::{DVector, Vector};
pub mod minorant;
pub use crate::minorant::{Aggregatable, Minorant};
| | > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
pub mod vector;
pub use crate::vector::{DVector, Vector};
pub mod minorant;
pub use crate::minorant::{Aggregatable, Minorant};
pub mod problem;
pub mod solver;
pub mod weighter;
pub mod terminator;
pub mod master;
|
| ︙ | ︙ |
Changes to src/master/primalmaster.rs.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ //! A wrapper around master problems to handle primal information. use super::MasterProblem; | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
//! A wrapper around master problems to handle primal information.
use super::MasterProblem;
use crate::problem::SubgradientExtender;
use crate::{Aggregatable, Minorant, Real};
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
/// A wrapper around `MasterProblem` to handle primal information.
///
|
| ︙ | ︙ |
Changes to src/mcf/problem.rs.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/> // use crate::mcf; | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
//
use crate::mcf;
use crate::problem::{
EvalResult, FirstOrderProblem as ParallelProblem, ResultSender, Update as ParallelUpdate, UpdateSender,
UpdateState as ParallelUpdateState,
};
use crate::{DVector, Minorant, Real};
use itertools::izip;
use log::{debug, warn};
|
| ︙ | ︙ |
Deleted src/parallel/mod.rs.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Name change from src/parallel/problem.rs to src/problem.rs.
| ︙ | ︙ |
Name change from src/parallel/masterprocess.rs to src/solver/masterprocess.rs.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 |
//! Asynchronous process solving a master problem.
use crossbeam::channel::{unbounded as channel, Receiver, Sender};
use log::{debug, warn};
use std::sync::Arc;
use threadpool::ThreadPool;
| < | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
//! Asynchronous process solving a master problem.
use crossbeam::channel::{unbounded as channel, Receiver, Sender};
use log::{debug, warn};
use std::sync::Arc;
use threadpool::ThreadPool;
use super::sync::Error;
use crate::master::primalmaster::PrimalMaster;
use crate::master::MasterProblem;
use crate::problem::{FirstOrderProblem, SubgradientExtender};
use crate::{DVector, Minorant, Real};
/// Configuration information for setting up a master problem.
pub struct MasterConfig {
/// The number of subproblems.
pub num_subproblems: usize,
/// The number of variables.
|
| ︙ | ︙ |
Name change from src/parallel/solver.rs to src/solver/sync.rs.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 |
use std::sync::Arc;
use std::time::Instant;
use threadpool::ThreadPool;
use crate::{DVector, Real};
use super::masterprocess::{MasterConfig, MasterProcess, MasterResponse};
| < > > > > > > > | 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 |
use std::sync::Arc;
use std::time::Instant;
use threadpool::ThreadPool;
use crate::{DVector, Real};
use super::masterprocess::{MasterConfig, MasterProcess, MasterResponse};
use crate::master::{self, MasterProblem};
use crate::problem::{EvalResult, FirstOrderProblem, Update, UpdateState};
use crate::terminator::{StandardTerminatable, StandardTerminator, Terminator};
use crate::weighter::{HKWeightable, HKWeighter, Weighter};
/// The default iteration limit.
pub const DEFAULT_ITERATION_LIMIT: usize = 10_000;
/// The default solver.
pub type DefaultSolver<P> = Solver<P, StandardTerminator, HKWeighter, crate::FullMasterBuilder>;
/// The minimal bundle solver.
pub type NoBundleSolver<P> = Solver<P, StandardTerminator, HKWeighter, crate::MinimalMasterBuilder>;
/// Error raised by the parallel bundle [`Solver`].
#[derive(Debug)]
pub enum Error<E> {
/// An error raised when creating a new master problem solver.
BuildMaster(Box<dyn std::error::Error>),
/// An error raised by the master problem process.
Master(Box<dyn std::error::Error>),
|
| ︙ | ︙ |