RsBundle  Diff

Differences From Artifact [9dbf86c5f6]:

  • File src/solver/sync.rs — part of check-in [e72dc2257c] at 2019-11-18 13:58:23 on branch sync-cleanup — sync: implement `Default` for `SolverData` (user: fifr size: 30729)

To Artifact [e6beece32d]:

  • File src/solver/sync.rs — part of check-in [f600a37ff9] at 2019-11-18 15:34:50 on branch sync-cleanup — sync: simplify `show_info` (user: fifr size: 30270) [more...]

724
725
726
727
728
729
730
731

732
733
734
735
736
737
738
739
740
741
742
743
744
745
724
725
726
727
728
729
730

731







732
733
734
735
736
737
738







-
+
-
-
-
-
-
-
-







        } else {
            step = Step::Null;
            self.cnt_null += 1;
            self.data.cur_weight = self.weighter.null_weight(&self.data);
            master.set_weight(self.data.cur_weight)?;
        }

        Self::show_info(
        self.show_info(step);
            &self.start_time,
            step,
            &self.data,
            self.cnt_descent,
            self.cnt_null,
            self.data.cnt_updates,
        );
        self.data.cnt_iter += 1;

        // Update problem.
        if self.update_problem(step)? {
            self.data.updated = true;
        }

765
766
767
768
769
770
771
772
773
774

775
776
777
778
779
780
781
782
783
784
785
786
758
759
760
761
762
763
764



765





766
767
768
769
770
771
772







-
-
-
+
-
-
-
-
-







            self.data.cur_weight = self.weighter.initial_weight(&self.data);
            master.set_weight(self.data.cur_weight)?;
            master.solve(self.data.cur_val)?;
            return Ok(false);
        }

        if self.terminator.terminate(&self.data) && !self.data.updated {
            Self::show_info(
                &self.start_time,
                Step::Term,
            self.show_info(Step::Term);
                &self.data,
                self.cnt_descent,
                self.cnt_null,
                self.data.cnt_updates,
            );
            info!("Termination criterion satisfied");
            return Ok(true);
        }

        // Compress bundle
        master.compress()?;

884
885
886
887
888
889
890
891

892
893
894
895
896
897
898
899

900
901
902
903
904
905
906
907
908
909
910



911
912
913
914
915
916





917
918
919
920
921
922
923
924
925
926
927
928
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
900
901
902
903
904
905
906
907







-
+
-
-
-
-
-
-
-
-
+








-
-
-
+
+
+

-
-
-
-
-
+
+
+
+
+












    /// This value is $f(\hat{y}) + \varrho \cdot \Delta$ where
    /// $\Delta = f(\hat{y}) - \hat{f}(\bar{y})$ is the expected
    /// progress and $\varrho$ is the `acceptance_factor`.
    fn get_descent_bound(acceptance_factor: Real, data: &SolverData) -> Real {
        data.cur_val - acceptance_factor * (data.cur_val - data.nxt_mod)
    }

    fn show_info(
    fn show_info(&self, step: Step) {
        start_time: &Instant,
        step: Step,
        data: &SolverData,
        cnt_descent: usize,
        cnt_null: usize,
        cnt_updates: usize,
    ) {
        let time = start_time.elapsed();
        let time = self.start_time.elapsed();
        info!(
            "{} {:0>2}:{:0>2}:{:0>2}.{:0>2} {:4} {:4} {:4}{:1}  {:9.4} {:9.4} \
             {:12.6e}({:12.6e}) {:12.6e}",
            if step == Step::Term { "_endit" } else { "endit " },
            time.as_secs() / 3600,
            (time.as_secs() / 60) % 60,
            time.as_secs() % 60,
            time.subsec_nanos() / 10_000_000,
            cnt_descent,
            cnt_descent + cnt_null,
            cnt_updates,
            self.cnt_descent,
            self.cnt_descent + self.cnt_null,
            self.data.cnt_updates,
            if step == Step::Descent { "*" } else { " " },
            data.cur_weight,
            data.expected_progress(),
            data.nxt_mod,
            data.nxt_val,
            data.cur_val
            self.data.cur_weight,
            self.data.expected_progress(),
            self.data.nxt_mod,
            self.data.nxt_val,
            self.data.cur_val
        );
    }

    /// Return the aggregated primal of the given subproblem.
    pub fn aggregated_primal(&self, subproblem: usize) -> Result<P::Primal, Error<P::Err>> {
        Ok(self
            .master_proc
            .as_ref()
            .ok_or(Error::NotSolved)?
            .get_aggregated_primal(subproblem)?)
    }
}