x=c(587,589,548,551,586,727,749,703,694,548,624,644,642,419,587,633,745,609,619,762,645,686,715,714,708,480,667,678,696,729,656,627,441,638,651,687,571,468,420,395)
x.agg=c(4855,3532,1423,989,3775,2755,4082,3427)
> sum(x)
[1] 24838
You can model it as an integer programming optimization. There is a solver for that in R (rsymphony i think)
Suppose x has the values and g are the groups, define binary variables b_ij whether x_i belongs to group j. The constraints are straightforward, and you try to maximize the sum.
--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
library(adagio)
x=c(587,589,548,551,586,727,749,703,694,548,624,644,642,419,587,633,745,609,619,762,645,686,715,714,708,480,667,678,696,729,656,627,441,638,651,687,571,468,420,395)
x.agg=c(4855,3532,1423,989,3775,2755,4082,3427)
x2=subsetsum(x,x.agg[1])
> x2
$val
[1] 4855
$inds
[1] 1 3 4 5 7 10 12 13
> sum(x[x2$inds])
[1] 4855
cool. thanks!
--
--
Hi Amit,
In your code - are you still solving that as integer programing, or there is a more efficient way?
Yotam.