31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
-
+
|
use threadpool::ThreadPool;
use crate::{DVector, Minorant, Real};
use super::channels::{
ChannelResultSender, ChannelUpdateSender, ClientReceiver, ClientSender, EvalResult, Message, Update,
};
use super::masterprocess::{MasterConfig, MasterError, MasterProcess, MasterResponse, Response};
use super::masterprocess::{MasterError, MasterProcess, MasterResponse, Response};
use crate::master::{Builder as MasterBuilder, MasterProblem};
use crate::problem::{FirstOrderProblem, UpdateState};
use crate::terminator::{StandardTerminatable, StandardTerminator, Terminator};
use crate::weighter::{HKWeightable, HKWeighter, Weighter};
/// The default iteration limit.
pub const DEFAULT_ITERATION_LIMIT: usize = 10_000;
|
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
|
-
-
-
-
+
-
-
-
-
-
-
-
+
-
-
-
-
+
+
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
|
self.cnt_null = 0;
self.cnt_evals = 0;
let (tx, rx) = channel();
self.client_tx = Some(tx.clone());
self.client_rx = Some(rx);
let master_config = MasterConfig {
num_subproblems: m,
num_vars: n,
lower_bounds: self.problem.lower_bounds().map(DVector),
let lower_bounds = self.problem.lower_bounds().map(DVector);
upper_bounds: self.problem.upper_bounds().map(DVector),
};
if master_config
.lower_bounds
.as_ref()
.map(|lb| lb.len() != n)
if lower_bounds.as_ref().map(|lb| lb.len() != n).unwrap_or(false) {
.unwrap_or(false)
{
return Err(Error::Dimension {
what: "lower bounds".to_string(),
});
}
if master_config
.upper_bounds
let upper_bounds = self.problem.upper_bounds().map(DVector);
.as_ref()
.map(|ub| ub.len() != n)
if upper_bounds.as_ref().map(|ub| ub.len() != n).unwrap_or(false) {
.unwrap_or(false)
{
return Err(Error::Dimension {
what: "upper bounds".to_string(),
});
}
debug!("Start master process");
self.master_proc = Some(MasterProcess::start(
self.master.build().map_err(Error::BuildMaster)?,
master_config,
tx,
&mut self.threadpool,
// Initialize the master problem.
let mut master = self.master.build().map_err(Error::BuildMaster)?;
master.set_num_subproblems(m).map_err(Error::BuildMaster)?;
master
.set_vars(n, lower_bounds, upper_bounds)
.map_err(Error::BuildMaster)?;
self.master_proc = Some(MasterProcess::start(master, tx, &mut self.threadpool));
));
debug!("Initial problem evaluation");
// We need an initial evaluation of all oracles for the first center.
let y = Arc::new(self.data.cur_y.clone());
for i in 0..m {
self.problem
.evaluate(
|