Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Solver: call `init` from `solve` not from `solve_iter`. `solve_iter` is supposed to be called several times. Hence the solver must not be reinitialized each time the function is called. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
77497707206cbf57eeb1d3e1d779bf92 |
| User & Date: | fifr 2019-07-15 12:29:50.244 |
Context
|
2019-07-15
| ||
| 12:32 | Solver: add `solve_with_limit` check-in: 2314de719c user: fifr tags: trunk | |
| 12:29 | Solver: call `init` from `solve` not from `solve_iter`. check-in: 7749770720 user: fifr tags: trunk | |
| 12:20 | Solver: simplify re-raise of master problem errors check-in: bf831bc6e2 user: fifr tags: trunk | |
Changes
Changes to src/solver.rs.
| ︙ | ︙ | |||
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
Ok(())
}
/// Solve the problem.
pub fn solve(&mut self) -> Result<(), SolverError<P::Err>> {
const LIMIT: usize = 10_000;
if self.solve_iter(LIMIT)? {
Ok(())
} else {
Err(SolverError::IterationLimit { limit: LIMIT })
}
}
/// Solve the problem but stop after `niter` iterations.
///
/// The function returns `Ok(true)` if the termination criterion
/// has been satisfied. Otherwise it returns `Ok(false)` or an
/// error code.
///
/// If this function is called again, the solution process is
/// continued from the previous point. Because of this one must
/// call `init()` before the first call to this function.
pub fn solve_iter(&mut self, niter: usize) -> Result<bool, SolverError<P::Err>> {
| > > > < < < | 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
Ok(())
}
/// Solve the problem.
pub fn solve(&mut self) -> Result<(), SolverError<P::Err>> {
const LIMIT: usize = 10_000;
// First initialize the internal data structures.
self.init()?;
if self.solve_iter(LIMIT)? {
Ok(())
} else {
Err(SolverError::IterationLimit { limit: LIMIT })
}
}
/// Solve the problem but stop after `niter` iterations.
///
/// The function returns `Ok(true)` if the termination criterion
/// has been satisfied. Otherwise it returns `Ok(false)` or an
/// error code.
///
/// If this function is called again, the solution process is
/// continued from the previous point. Because of this one must
/// call `init()` before the first call to this function.
pub fn solve_iter(&mut self, niter: usize) -> Result<bool, SolverError<P::Err>> {
for _ in 0..niter {
let mut term = self.step()?;
let changed = self.update_problem(term)?;
// do not stop if the problem has been changed
if changed && term == Step::Term {
term = Step::Null
}
|
| ︙ | ︙ |