Dimitri Shvorob
2010-Jan-30 00:15 UTC
[R] Solving an optimization problem: selecting an "optimal" subset
Given vector of numbers x, I wish to select an n-subset with sum closest to fixed value s. Can anyone advise me how to approach this, in R? I have considered Rcplex package, which handles integer/binary linear/quadratic optimization problems, but have difficulty setting up the quadratic form for [sum(x) - s]^2. (Dynamic programming over [0, sum(x)]? A genetic algorithm? Can anyone contribute a binary GA optimization sample?) Thank you. -- View this message in context: http://n4.nabble.com/Solving-an-optimization-problem-selecting-an-optimal-subset-tp1446084p1446084.html Sent from the R help mailing list archive at Nabble.com.
Bart Joosen
2010-Jan-30 09:44 UTC
[R] Solving an optimization problem: selecting an "optimal" subset
Could you please specifiy your problem, if possible with some data? Is it a subset of a vector containing 100 elements, or 10000ths? A random number of elements that should be chosen, or the best 10 values which sums up to a defined value? Bart -- View this message in context: http://n4.nabble.com/Solving-an-optimization-problem-selecting-an-optimal-subset-tp1446084p1457323.html Sent from the R help mailing list archive at Nabble.com.
Dimitri Shvorob
2010-Jan-30 19:17 UTC
[R] Solving an optimization problem: selecting an "optimal" subset
A 40-element subset proves too much :(> Error: cannot allocate vector of size 554.1 MbThanks, Bart! -- View this message in context: http://n4.nabble.com/Solving-an-optimization-problem-selecting-an-optimal-subset-tp1446084p1457597.html Sent from the R help mailing list archive at Nabble.com.
Erwin Kalvelagen
2010-Jan-31 05:23 UTC
[R] Solving an optimization problem: selecting an "optimal" subset
Dimitri Shvorob <dimitri.shvorob <at> gmail.com> writes:> > > ?!! Erwin, may I ask for a working code sample? (Including appropriate > package(s)) > > Thank you.I used GAMS + CPlex. The models are here: http://yetanothermathprogrammingconsultant.blogspot.com/2010/01/solving- optimization-problem-selecting.html. ---------------------------------------------------------------- Erwin Kalvelagen Amsterdam Optimization Modeling Group erwin at amsterdamoptimization.com http://amsterdamoptimization.com