RsBundle  Diff

Differences From Artifact [4c54b32ea4]:

  • File src/solver/sync.rs — part of check-in [c6a75adbd3] at 2019-11-18 22:19:11 on branch trunk — sync: cleanup imports (user: fifr size: 29733)

To Artifact [cf3bbb4227]:

  • File src/solver/sync.rs — part of check-in [4d0fdfb346] at 2019-11-22 09:01:41 on branch result-sender — problem: hide result channel in opaque type `ResultSender` (user: fifr size: 29785)

25
26
27
28
29
30
31
32

33
34
35
36
37
38
39
25
26
27
28
29
30
31

32
33
34
35
36
37
38
39







-
+







use std::time::Instant;
use threadpool::ThreadPool;

use crate::{DVector, Real};

use super::masterprocess::{self, MasterConfig, MasterProcess, MasterResponse};
use crate::master::{Builder as MasterBuilder, MasterProblem};
use crate::problem::{EvalResult, FirstOrderProblem, Update, UpdateState};
use crate::problem::{EvalResult, FirstOrderProblem, ResultSender, Update, 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;

/// The default solver.
536
537
538
539
540
541
542
543

544
545
546
547
548
549
550
536
537
538
539
540
541
542

543
544
545
546
547
548
549
550







-
+







        ));

        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(i, y.clone(), i, self.client_tx.clone().unwrap())
                .evaluate(i, y.clone(), ResultSender::new(i, self.client_tx.clone().unwrap()))
                .map_err(Error::Evaluation)?;
        }

        debug!("Initialization complete");

        self.start_time = Instant::now();

769
770
771
772
773
774
775
776

777
778
779
780
781
782
783
769
770
771
772
773
774
775

776
777
778
779
780
781
782
783







-
+







            .resize(self.problem.num_subproblems(), -Real::infinity());
        self.data.cnt_remaining_mins = self.problem.num_subproblems();

        // Start evaluation of all subproblems at the new candidate.
        let client_tx = self.client_tx.as_ref().ok_or(Error::NotInitialized)?;
        for i in 0..self.problem.num_subproblems() {
            self.problem
                .evaluate(i, self.data.nxt_y.clone(), i, client_tx.clone())
                .evaluate(i, self.data.nxt_y.clone(), ResultSender::new(i, client_tx.clone()))
                .map_err(Error::Evaluation)?;
        }
        Ok(false)
    }

    fn update_problem(&mut self, step: Step) -> Result<bool, Error<P::Err>> {
        let master_proc = self.master_proc.as_mut().ok_or(Error::NotInitialized)?;