RsBundle  Diff

Differences From Artifact [74791750a7]:

  • File src/solver.rs — part of check-in [0b6fbe2b30] at 2018-06-26 13:46:51 on branch error-handling — Remove explicit lifetime from `FirstOrderOracle` (user: fifr size: 36944)

To Artifact [b6153a17f5]:

  • File src/solver.rs — part of check-in [cd30b6f272] at 2018-06-26 21:17:34 on branch error-handling — master: Subgradient extension callback may return an error. This callback eventually calls a method of the oracle and may fail with some user error. This error is now returned to the master problem and finally back to the solver. (user: fifr size: 36955)

460
461
462
463
464
465
466
467



468
469
470
471
472
473
474
    /// The active minorant indices for each subproblem.
    minorants: Vec<Vec<MinorantInfo<P::Primal>>>,

    /// Accumulated information about the last iteration.
    iterinfos: Vec<IterationInfo>,
}

impl<P: FirstOrderProblem> Solver<P> {



    /**
     * Create a new solver for the given problem.
     *
     * Note that the solver owns the problem, so you cannot use the
     * same problem description elsewhere as long as it is assigned to
     * the solver. However, it is possible to get a reference to the
     * internally stored problem using `Solver::problem()`.







|
>
>
>







460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
    /// The active minorant indices for each subproblem.
    minorants: Vec<Vec<MinorantInfo<P::Primal>>>,

    /// Accumulated information about the last iteration.
    iterinfos: Vec<IterationInfo>,
}

impl<P: FirstOrderProblem> Solver<P>
where
    P::Err: Into<Box<dyn Error>>,
{
    /**
     * Create a new solver for the given problem.
     *
     * Note that the solver owns the problem, so you cannot use the
     * same problem description elsewhere as long as it is assigned to
     * the solver. However, it is possible to get a reference to the
     * internally stored problem using `Solver::problem()`.
681
682
683
684
685
686
687
688

689
690
691
692
693
694
695
696
697
698
699
700

        if !newvars.is_empty() {
            let mut problem = &mut self.problem;
            let minorants = &self.minorants;
            self.master
                .add_vars(
                    &newvars.iter().map(|v| (v.0, v.1, v.2)).collect::<Vec<_>>(),
                    &mut move |fidx, minidx, vars| match problem

                        .extend_subgradient(minorants[fidx][minidx].primal.as_ref().unwrap(), vars)
                        .map(DVector)
                    {
                        Ok(g) => g,
                        Err(_) => unreachable!(),
                    },
                )
                .map_err(SolverError::Master)?;
            // modify moved variables
            for (index, val) in newvars.iter().filter_map(|v| v.0.map(|i| (i, v.3))) {
                self.cur_y[index] = val;
                self.nxt_y[index] = val;







|
>
|
|
<
<
|







684
685
686
687
688
689
690
691
692
693
694


695
696
697
698
699
700
701
702

        if !newvars.is_empty() {
            let mut problem = &mut self.problem;
            let minorants = &self.minorants;
            self.master
                .add_vars(
                    &newvars.iter().map(|v| (v.0, v.1, v.2)).collect::<Vec<_>>(),
                    &mut move |fidx, minidx, vars| {
                        problem
                            .extend_subgradient(minorants[fidx][minidx].primal.as_ref().unwrap(), vars)
                            .map(DVector)


                            .map_err(|e| e.into())
                    },
                )
                .map_err(SolverError::Master)?;
            // modify moved variables
            for (index, val) in newvars.iter().filter_map(|v| v.0.map(|i| (i, v.3))) {
                self.cur_y[index] = val;
                self.nxt_y[index] = val;