public ITotalFinancialContribution Calculate( ITotalFinancialContributionFactory totalFinancialContributionFactory, Ipa pa, Ir r, ISPx x) { return(totalFinancialContributionFactory.Create( pa.Value .Select( i => r.GetElementAtAsdecimal( i.pIndexElement) * (decimal)x.GetElementAt( i.pIndexElement, i.aIndexElement)) .Sum())); }
public SPObjectiveFunction( IObjectiveFactory objectiveFactory, Ipa pa, Ir r, ISPx x) { Expression expression = Expression.Sum( pa.Value .Select( i => (double)r.GetElementAtAsdecimal( i.pIndexElement) * x.Value[i.pIndexElement, i.aIndexElement])); Objective objective = objectiveFactory.Create( expression, ObjectiveSense.Maximize); this.Value = objective; }