Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | solver: Do not terminate of problem has been changed. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
3248967d1a16801c190f1d4d5874f18d |
| User & Date: | fifr 2016-10-05 20:11:41.892 |
Context
|
2016-10-05
| ||
| 20:14 | solver: Remove duplicate method `update_problem`. check-in: 8d95c5134e user: fifr tags: trunk | |
| 20:11 | solver: Do not terminate of problem has been changed. check-in: 3248967d1a user: fifr tags: trunk | |
| 16:54 | Add problem update callback. check-in: 814bd7230a user: fifr tags: trunk | |
Changes
Changes to src/solver.rs.
| ︙ | ︙ | |||
499 500 501 502 503 504 505 |
Ok(())
}
/// Solve the problem.
pub fn solve(&mut self) -> Result<()> {
try!(self.init());
for _ in 0..100000 {
| | > > > | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
Ok(())
}
/// Solve the problem.
pub fn solve(&mut self) -> Result<()> {
try!(self.init());
for _ in 0..100000 {
let mut term = try!(self.step());
let changed = try!(self.update_problem(term));
// do not stop if the problem has been changed
if changed && term == Step::Term { term = Step::Null }
try!(self.update_problem(term));
self.show_info(term);
if term == Step::Term {
break;
}
}
Ok(())
|
| ︙ | ︙ | |||
539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
self.master.add_vars(&newvars, &mut move |fidx, minidx, vars| {
problem.extend_subgradient(minorants[fidx][minidx].primal.as_ref().unwrap(), vars).unwrap()
});
}
Ok(())
}
/// Return the current aggregated primal information for a subproblem.
///
/// This function returns all currently used minorants $x_i$ along
/// with their coefficients $\alpha_i$. The aggregated primal can
/// be computed by combining the minorants $\bar{x} =
/// \sum_{i=1}\^m \alpha_i x_i$.
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
self.master.add_vars(&newvars, &mut move |fidx, minidx, vars| {
problem.extend_subgradient(minorants[fidx][minidx].primal.as_ref().unwrap(), vars).unwrap()
});
}
Ok(())
}
/// 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 state = UpdateState {minorants: &self.minorants, step: term};
let updates = 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));
},
}
}
if !newvars.is_empty() {
let mut problem = &mut self.problem;
let minorants = &self.minorants;
self.master.add_vars(&newvars, &mut move |fidx, minidx, vars| {
problem.extend_subgradient(minorants[fidx][minidx].primal.as_ref().unwrap(), vars).unwrap()
});
Ok(true)
} else {
Ok(false)
}
}
/// Return the current aggregated primal information for a subproblem.
///
/// This function returns all currently used minorants $x_i$ along
/// with their coefficients $\alpha_i$. The aggregated primal can
/// be computed by combining the minorants $\bar{x} =
/// \sum_{i=1}\^m \alpha_i x_i$.
|
| ︙ | ︙ |