RsBundle  Diff

Differences From Artifact [27fc4afb03]:

  • File src/mcf/problem.rs — part of check-in [d98bdda26e] at 2016-10-02 07:02:23 on branch trunk — mcf: Verify arc numbers when reading files. (user: fifr size: 10420)

To Artifact [57706d9f48]:

  • File src/mcf/problem.rs — part of check-in [5221a3331a] at 2016-10-13 17:47:02 on branch trunk — Change parameters of `FirstOrderProblem::aggregate_primals`. Now the primals and coefficients are passed as (coeff, primal) pairs. This ensures that the number of coefficients always equals the number of primals by design. (user: fifr size: 10426)

186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
                }
            }
            sum
        }
    }

    /// Aggregate primal vectors.
    pub fn aggregate_primals_ref(&self, coeffs: &[Real], primals: &[&Vec<DVector>]) -> Vec<DVector> {
        let mut aggr = primals[0].iter().map(|x| {
            let mut r = dvec![];
            r.scal(coeffs[0], x);
            r
        }).collect::<Vec<_>>();

        for i in 1..primals.len() {
            for (j,x) in primals[i].iter().enumerate() {
                aggr[j].add_scaled(coeffs[i], x);
            }
        }

        aggr
    }
}








|
|

|



|
|
|







186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
                }
            }
            sum
        }
    }

    /// Aggregate primal vectors.
    pub fn aggregate_primals_ref(&self, primals: &[(Real, &Vec<DVector>)]) -> Vec<DVector> {
        let mut aggr = primals[0].1.iter().map(|x| {
            let mut r = dvec![];
            r.scal(primals[0].0, x);
            r
        }).collect::<Vec<_>>();

        for &(alpha, primal) in &primals[1..] {
            for (j,x) in primal.iter().enumerate() {
                aggr[j].add_scaled(alpha, x);
            }
        }

        aggr
    }
}

303
304
305
306
307
308
309
310
311
312
313
            Ok(SimpleEvaluation {
                objective: objective,
                minorants: vec![(Minorant { constant: objective, linear: subg }, sols)],
            })
        }
    }

    fn aggregate_primals(&mut self, coeffs: &[Real], primals: Vec<Vec<DVector>>) -> Vec<DVector> {
        self.aggregate_primals_ref(coeffs, &primals.iter().map(|x| x).collect::<Vec<_>>())
    }
}







|
|


303
304
305
306
307
308
309
310
311
312
313
            Ok(SimpleEvaluation {
                objective: objective,
                minorants: vec![(Minorant { constant: objective, linear: subg }, sols)],
            })
        }
    }

    fn aggregate_primals(&mut self, primals: Vec<(Real, Vec<DVector>)>) -> Vec<DVector> {
        self.aggregate_primals_ref(&primals.iter().map(|&(alpha, ref x)| (alpha, x)).collect::<Vec<_>>())
    }
}