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<_>>())
}
}
|