Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add `dyn` to trait object types |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | modifyprimals |
| Files: | files | file ages | folders |
| SHA1: |
45d9ecf62bfedf78c72ca96c21d56f4e |
| User & Date: | fifr 2019-12-21 21:28:16.624 |
Context
|
2019-12-21
| ||
| 22:48 | Merge release Leaf check-in: 51732172c2 user: fifr tags: modifyprimals | |
| 21:28 | Add `dyn` to trait object types check-in: 45d9ecf62b user: fifr tags: modifyprimals | |
|
2018-12-12
| ||
| 20:47 | Merge trunk check-in: a93b15592c user: fifr tags: modifyprimals | |
Changes
Changes to src/firstorderproblem.rs.
|
| | | 1 2 3 4 5 6 7 8 | // 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 |
| ︙ | ︙ | |||
80 81 82 83 84 85 86 |
AddVariableValue { lower: Real, upper: Real, value: Real },
/// Change the current value of a variable. The bounds remain
/// unchanged.
MoveVariable { index: usize, value: Real },
/// Update primal variables of a subproblem.
ModifyPrimals {
subproblem: usize,
| | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
AddVariableValue { lower: Real, upper: Real, value: Real },
/// Change the current value of a variable. The bounds remain
/// unchanged.
MoveVariable { index: usize, value: Real },
/// Update primal variables of a subproblem.
ModifyPrimals {
subproblem: usize,
modify: Box<dyn Fn(&mut P) -> Result<(), E>>,
},
}
/**
* Trait for implementing a first-order problem description.
*
*/
|
| ︙ | ︙ |
Changes to src/master/base.rs.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
Solver(err) => write!(fmt, "Solver error: {}", err),
Custom(err) => err.fmt(fmt),
}
}
}
impl Error for MasterProblemError {
| | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
Solver(err) => write!(fmt, "Solver error: {}", err),
Custom(err) => err.fmt(fmt),
}
}
}
impl Error for MasterProblemError {
fn cause(&self) -> Option<&dyn Error> {
use self::MasterProblemError::*;
match self {
SubgradientExtension(err) | Solver(err) | Custom(err) => Some(err.as_ref()),
NoMinorants => None,
}
}
}
|
| ︙ | ︙ | |||
86 87 88 89 90 91 92 |
/// Add or movesome variables with bounds.
///
/// If an index is specified, existing variables are moved,
/// otherwise new variables are generated.
fn add_vars(
&mut self,
bounds: &[(Option<usize>, Real, Real)],
| > > > > | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
/// Add or movesome variables with bounds.
///
/// If an index is specified, existing variables are moved,
/// otherwise new variables are generated.
fn add_vars(
&mut self,
bounds: &[(Option<usize>, Real, Real)],
extend_subgradient: &mut dyn FnMut(
usize,
Self::MinorantIndex,
&[usize],
) -> result::Result<DVector, Box<dyn Error>>,
) -> Result<()>;
/// Add a new minorant to the model.
///
/// The function returns a unique (among all minorants of all
/// subproblems) index of the minorant. This index must remain
/// valid until the minorant is aggregated.
|
| ︙ | ︙ |
Changes to src/master/boxed.rs.
|
| | | 1 2 3 4 5 6 7 8 | // Copyright (c) 2016, 2017, 2018, 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 |
| ︙ | ︙ | |||
209 210 211 212 213 214 215 |
fn set_weight(&mut self, weight: Real) -> Result<()> {
self.master.set_weight(weight)
}
fn add_vars(
&mut self,
bounds: &[(Option<usize>, Real, Real)],
| > > > > | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
fn set_weight(&mut self, weight: Real) -> Result<()> {
self.master.set_weight(weight)
}
fn add_vars(
&mut self,
bounds: &[(Option<usize>, Real, Real)],
extend_subgradient: &mut dyn FnMut(
usize,
Self::MinorantIndex,
&[usize],
) -> result::Result<DVector, Box<dyn Error>>,
) -> Result<()> {
if !bounds.is_empty() {
for (index, l, u) in bounds.iter().filter_map(|v| v.0.map(|i| (i, v.1, v.2))) {
self.lb[index] = l;
self.ub[index] = u;
}
self.lb.extend(bounds.iter().filter(|v| v.0.is_none()).map(|x| x.1));
|
| ︙ | ︙ |
Changes to src/master/cpx.rs.
|
| | | 1 2 3 4 5 6 7 8 | // Copyright (c) 2016, 2017, 2018, 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 |
| ︙ | ︙ | |||
157 158 159 160 161 162 163 |
}
}
fn add_vars(
&mut self,
nnew: usize,
changed: &[usize],
| > > > > | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
}
}
fn add_vars(
&mut self,
nnew: usize,
changed: &[usize],
extend_subgradient: &mut dyn FnMut(
usize,
Self::MinorantIndex,
&[usize],
) -> result::Result<DVector, Box<dyn Error>>,
) -> Result<()> {
debug_assert!(!self.minorants[0].is_empty());
let noldvars = self.minorants[0][0].linear.len();
let nnewvars = noldvars + nnew;
let mut changedvars = vec![];
changedvars.extend_from_slice(changed);
|
| ︙ | ︙ |
Changes to src/master/minimal.rs.
|
| | | 1 2 3 4 5 6 7 8 | // 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 |
| ︙ | ︙ | |||
124 125 126 127 128 129 130 |
Ok(self.minorants.len() - 1)
}
fn add_vars(
&mut self,
nnew: usize,
changed: &[usize],
| > > > > | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
Ok(self.minorants.len() - 1)
}
fn add_vars(
&mut self,
nnew: usize,
changed: &[usize],
extend_subgradient: &mut dyn FnMut(
usize,
Self::MinorantIndex,
&[usize],
) -> result::Result<DVector, Box<dyn Error>>,
) -> Result<()> {
if !self.minorants.is_empty() {
let noldvars = self.minorants[0].linear.len();
let mut changedvars = vec![];
changedvars.extend_from_slice(changed);
changedvars.extend(noldvars..noldvars + nnew);
for (i, m) in self.minorants.iter_mut().enumerate() {
|
| ︙ | ︙ |
Changes to src/master/unconstrained.rs.
|
| | | 1 2 3 4 5 6 7 8 | // 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 |
| ︙ | ︙ | |||
77 78 79 80 81 82 83 |
/// The variables in `changed` have been changed, so the subgradient
/// information must be updated. Furthermore, `nnew` new variables
/// are added.
fn add_vars(
&mut self,
nnew: usize,
changed: &[usize],
| > > > > | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
/// The variables in `changed` have been changed, so the subgradient
/// information must be updated. Furthermore, `nnew` new variables
/// are added.
fn add_vars(
&mut self,
nnew: usize,
changed: &[usize],
extend_subgradient: &mut dyn FnMut(
usize,
Self::MinorantIndex,
&[usize],
) -> result::Result<DVector, Box<dyn Error>>,
) -> Result<()>;
/// Solve the master problem.
fn solve(&mut self, eta: &DVector, fbound: Real, augbound: Real, relprec: Real) -> Result<()>;
/// Return the current dual optimal solution.
fn dualopt(&self) -> &DVector;
|
| ︙ | ︙ |
Changes to src/mcf/problem.rs.
| ︙ | ︙ | |||
37 38 39 40 41 42 43 |
write!(fmt, "Format error: {}", self.msg)
}
}
impl Error for MMCFFormatError {}
/// Result type of the MMCFProblem.
| | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
write!(fmt, "Format error: {}", self.msg)
}
}
impl Error for MMCFFormatError {}
/// Result type of the MMCFProblem.
pub type Result<T> = result::Result<T, Box<dyn Error>>;
#[derive(Clone, Copy, Debug)]
struct ArcInfo {
arc: usize,
src: usize,
snk: usize,
}
|
| ︙ | ︙ |
Changes to src/solver.rs.
| ︙ | ︙ | |||
84 85 86 87 88 89 90 |
),
IterationLimit { limit } => write!(fmt, "The iteration limit of {} has been reached.", limit),
}
}
}
impl<E: Error> Error for SolverError<E> {
| | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
),
IterationLimit { limit } => write!(fmt, "The iteration limit of {} has been reached.", limit),
}
}
}
impl<E: Error> Error for SolverError<E> {
fn cause(&self) -> Option<&dyn Error> {
match self {
SolverError::Evaluation(err) => Some(err),
SolverError::Update(err) => Some(err),
SolverError::Master(err) => Some(err),
_ => None,
}
}
|
| ︙ | ︙ | |||
388 389 390 391 392 393 394 |
/// The first order problem description.
problem: P,
/// The solver parameter.
pub params: SolverParams,
/// Termination predicate.
| | | | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
/// The first order problem description.
problem: P,
/// The solver parameter.
pub params: SolverParams,
/// Termination predicate.
pub terminator: Box<dyn Terminator>,
/// Weighter heuristic.
pub weighter: Box<dyn Weighter>,
/// Lower and upper bounds of all variables.
bounds: Vec<(Real, Real)>,
/// Current center of stability.
cur_y: DVector,
|
| ︙ | ︙ | |||
460 461 462 463 464 465 466 |
* Time when the solution process started.
*
* This is actually the time of the last call to `Solver::init`.
*/
start_time: Instant,
/// The master problem.
| | | 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
* Time when the solution process started.
*
* This is actually the time of the last call to `Solver::init`.
*/
start_time: Instant,
/// The master problem.
master: Box<dyn MasterProblem<MinorantIndex = usize>>,
/// The active minorant indices for each subproblem.
minorants: Vec<Vec<MinorantInfo<P::Primal>>>,
/// Accumulated information about the last iteration.
iterinfos: Vec<IterationInfo>,
}
|
| ︙ | ︙ | |||
694 695 696 697 698 699 700 |
subproblem: subproblem,
nsubs: self.minorants.len(),
});
}
for m in &mut self.minorants[subproblem] {
if let Some(ref mut p) = m.primal {
if let Err(err) = modify(p) {
| | | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
subproblem: subproblem,
nsubs: self.minorants.len(),
});
}
for m in &mut self.minorants[subproblem] {
if let Some(ref mut p) = m.primal {
if let Err(err) = modify(p) {
return Err(SolverError::Update(err));
}
}
}
}
}
}
|
| ︙ | ︙ |