Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | solver: remove remaing `try!` |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
40f31dd62cb4cac5db527897956efa6d |
| User & Date: | fifr 2017-11-20 09:05:37.844 |
Context
|
2017-11-20
| ||
| 09:11 | Refactoring check-in: 741fb52a85 user: fifr tags: trunk | |
| 09:05 | solver: remove remaing `try!` check-in: 40f31dd62c user: fifr tags: trunk | |
| 09:02 | Refactor `SolverError::Parameter` check-in: c24cf8d06e user: fifr tags: trunk | |
Changes
Changes to src/solver.rs.
| ︙ | ︙ | |||
481 482 483 484 485 486 487 |
/// Returns a reference to the solver's current problem.
pub fn problem(&self) -> &P {
&self.problem
}
/// Initialize the solver.
pub fn init(&mut self) -> Result<(), SolverError> {
| | | 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
/// Returns a reference to the solver's current problem.
pub fn problem(&self) -> &P {
&self.problem
}
/// Initialize the solver.
pub fn init(&mut self) -> Result<(), SolverError> {
self.params.check()?;
if self.cur_y.len() != self.problem.num_variables() {
self.cur_valid = false;
self.cur_y.init0(self.problem.num_variables());
}
let lb = self.problem.lower_bounds();
let ub = self.problem.upper_bounds();
|
| ︙ | ︙ | |||
543 544 545 546 547 548 549 |
/// 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> {
for _ in 0..niter {
| | | | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
/// 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> {
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
}
self.show_info(term);
if term == Step::Term {
return Ok(true)
|
| ︙ | ︙ | |||
864 865 866 867 868 869 870 |
/// Perform one bundle iteration.
#[cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
pub fn step(&mut self) -> Result<Step, SolverError> {
self.iterinfos.clear();
if !self.cur_valid {
// current point needs new evaluation
| | | | | 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 |
/// Perform one bundle iteration.
#[cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
pub fn step(&mut self) -> Result<Step, SolverError> {
self.iterinfos.clear();
if !self.cur_valid {
// current point needs new evaluation
self.init_master()?;
}
self.solve_model()?;
if self.terminator.terminate(¤t_state!(self, Step::Term), &self.params) {
return Ok(Step::Term);
}
let m = self.problem.num_subproblems();
let descent_bnd = self.get_descent_bound();
let nullstep_bnd = if m == 1 {
self.get_nullstep_bound()
} else {
INFINITY
};
let relprec = if m == 1 {
self.get_relative_precision()
} else {
0.0
};
self.compress_bundle()?;
let mut nxt_lb = 0.0;
let mut nxt_ub = 0.0;
self.new_cutval = 0.0;
for fidx in 0..self.problem.num_subproblems() {
let result = self.problem
.evaluate(fidx, &self.nxt_y, nullstep_bnd, relprec)
|
| ︙ | ︙ |