Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | solver: Add `cur_y` and `nxt_y` fields to `UpdateState`. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
2b281a925b6d3258cbb9e7553105828e |
| User & Date: | fifr 2016-10-10 20:33:03.321 |
Context
|
2016-10-10
| ||
| 20:33 | solver: Add `last_primal` method to `UpdateState`. check-in: 40a866dae4 user: fifr tags: trunk | |
| 20:33 | solver: Add `cur_y` and `nxt_y` fields to `UpdateState`. check-in: 2b281a925b user: fifr tags: trunk | |
| 14:43 | Add `IterationInfo` to update state. check-in: 8d6b894491 user: fifr tags: trunk | |
Changes
Changes to src/solver.rs.
| ︙ | ︙ | |||
306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
pub struct UpdateState<'a, Pr:'a> {
/// Current model minorants.
minorants: &'a [Vec<MinorantInfo<Pr>>],
/// The last step type.
pub step: Step,
/// Iteration information.
pub iteration_info: &'a [IterationInfo],
}
impl<'a, Pr:'a> UpdateState<'a, Pr> {
pub fn aggregated_primals(&self, subproblem : usize) -> Vec<(Real, &Pr)> {
self.minorants[subproblem].iter().map(|m| {
(m.multiplier, m.primal.as_ref().unwrap())
}).collect()
| > > > > > > | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
pub struct UpdateState<'a, Pr:'a> {
/// Current model minorants.
minorants: &'a [Vec<MinorantInfo<Pr>>],
/// The last step type.
pub step: Step,
/// Iteration information.
pub iteration_info: &'a [IterationInfo],
/// The current candidate. If the step was a descent step, this is
/// the new center.
pub nxt_y: &'a DVector,
/// The center. IF the step was a descent step, this is the old
/// center.
pub cur_y: &'a DVector,
}
impl<'a, Pr:'a> UpdateState<'a, Pr> {
pub fn aggregated_primals(&self, subproblem : usize) -> Vec<(Real, &Pr)> {
self.minorants[subproblem].iter().map(|m| {
(m.multiplier, m.primal.as_ref().unwrap())
}).collect()
|
| ︙ | ︙ | |||
531 532 533 534 535 536 537 |
}
/// Called to update the problem.
///
/// Calling this function typically triggers the problem to
/// separate new constraints depending on the current solution.
fn update_problem(&mut self, term: Step) -> Result<bool> {
| > | > > > > > > > > > | | | > | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
}
/// Called to update the problem.
///
/// Calling this function typically triggers the problem to
/// separate new constraints depending on the current solution.
fn update_problem(&mut self, term: Step) -> Result<bool> {
let updates = {
let state = UpdateState {
minorants: &self.minorants,
step: term,
iteration_info: &self.iterinfos,
// this is a dirty trick: when updating the center, we
// simply swapped the `cur_*` fields with the `nxt_*`
// fields
cur_y: if term == Step::Descent { &self.nxt_y } else { &self.cur_y },
nxt_y: if term == Step::Descent { &self.cur_y } else { &self.nxt_y },
};
match self.problem.update(&state) {
Ok(updates) => updates,
Err(err) => return Err(Error::Update(Box::new(err))),
}
};
let mut newvars = Vec::with_capacity(updates.len());
for u in updates {
match u {
Update::AddVariable{lower, upper} => {
newvars.push((lower, upper));
|
| ︙ | ︙ |