509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
|
if changed && term == Step::Term { term = Step::Null }
try!(self.update_problem(term));
self.show_info(term);
if term == Step::Term {
break;
}
}
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<()> {
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(())
}
/// Called to update the problem.
///
/// Calling this function typically triggers the problem to
/// separate new constraints depending on the current solution.
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
509
510
511
512
513
514
515
516
517
518
519
520
521
522
|
if changed && term == Step::Term { term = Step::Null }
try!(self.update_problem(term));
self.show_info(term);
if term == Step::Term {
break;
}
}
Ok(())
}
/// Called to update the problem.
///
/// Calling this function typically triggers the problem to
/// separate new constraints depending on the current solution.
|