RsBundle  Diff

Differences From Artifact [0809fb85f1]:

  • File src/mcf/problem.rs — part of check-in [5401c89abf] at 2019-07-25 14:24:47 on branch mmcf-separation — mmcf: return early if no inactive constraints remain (user: fifr size: 19865)

To Artifact [16b1460343]:

  • File src/mcf/problem.rs — part of check-in [4e64e6a06c] at 2019-07-25 14:50:22 on branch mmcf-separation — mmcf: add `set_separate_constraints` method (user: fifr size: 20318) [more...]

301
302
303
304
305
306
307
308
309
310
311
312












313
314
315
316
317
318
319
            .map(RwLock::new)
            .map(Arc::new)
            .collect();

        Ok(MMCFProblem {
            multimodel: false,
            subs: subproblems,
            active_constraints: vec![],
            inactive_constraints: (0..ncaps).collect(),
            pool: None,
        })
    }













    /// Compute costs for a primal solution.
    pub fn get_primal_costs(&self, fidx: usize, primals: &[DVector]) -> Real {
        let sub = self.subs[fidx].read().unwrap();
        if self.multimodel {
            primals[0].iter().enumerate().map(|(i, x)| x * sub.cbase[i]).sum()
        } else {







|
|



>
>
>
>
>
>
>
>
>
>
>
>







301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
            .map(RwLock::new)
            .map(Arc::new)
            .collect();

        Ok(MMCFProblem {
            multimodel: false,
            subs: subproblems,
            active_constraints: (0..ncaps).collect(),
            inactive_constraints: vec![],
            pool: None,
        })
    }

    /// Mark all constraints as being separated.
    pub fn set_separate_constraints(&mut self, separate: bool) {
        let nconstrs = self.subs[0].read().unwrap().lhs.len();
        if separate {
            self.active_constraints.clear();
            self.inactive_constraints = (0..nconstrs).collect();
        } else {
            self.active_constraints = (0..nconstrs).collect();
            self.inactive_constraints.clear();
        }
    }

    /// Compute costs for a primal solution.
    pub fn get_primal_costs(&self, fidx: usize, primals: &[DVector]) -> Real {
        let sub = self.subs[fidx].read().unwrap();
        if self.multimodel {
            primals[0].iter().enumerate().map(|(i, x)| x * sub.cbase[i]).sum()
        } else {