Erwin Kalvelagen-2 wrote:
>
> Hans W Borchers googlemail.com> writes:
>> # Prepare inputs for MILP solver
>> obj <- c(rep(0, n), 0, 1, 1, 0)
>> typ <- c(rep("B", n), "B", "C", "C", "B")
>> mat <- matrix(c(s, -z, -1, 1, 0,# a = a_p + a_m
>> rep(0,
Dimitri Shvorob gmail.com> writes:
>
> Given vector of numbers x, I wish to select an n-subset with sum closest
> 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 d
Dimitri Shvorob gmail.com> writes:
>
>
> Thank you very much, Erwin. If I may ask some follow-up questions
> 1. GAMS <> R, ad it's just not entirely clear how to move the soltion to R.
> (At most trivial, how do I "bring in" the subsettable vector into the
> solver?")
> 2. "The quadratic object
> To replace an absolute value by two binary variables is an old trick in
optimization modeling.
I am having trouble Googling it: can anyone suggest a reference, or just
explain?
Thank you.
--
View this message in context:
http://n4.nabble.com/Solving-an-optimization-problem-selecting-an-optim
Thank you very much, Erwin. If I may ask some follow-up questions
1. GAMS <> R, ad it's just not entirely clear how to move the soltion to R.
(At most trivial, how do I "bring in" the subsettable vector into the
solver?")
2. "The quadratic objective can be replaced by a linear one by minimizing
th
Dimitri Shvorob wrote:
>
> Same request to Hans:
> I am afraid I need a little more spoon-feeding following
>
>> I sent a GAMS script modeling this problem to the NEOS solvers
>
> Thanks a lot!
>
If you have access to CPLEX (I mean the commercial program, not Rcplex
which is just an interfa
Dimitri Shvorob 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
Same request to Hans: I am afraid I need a little more spoon-feeding
following
> I sent a GAMS script modeling this problem to the NEOS solvers
Thanks a lot!
--
View this message in context:
http://n4.nabble.com/Solving-an-optimization-problem-selecting-an-optimal-subset-tp1446084p1457747.htm
?!! Erwin, may I ask for a working code sample? (Including appropriate
package(s))
Thank you.
--
View this message in context:
http://n4.nabble.com/Solving-an-optimization-problem-selecting-an-optimal-subset-tp1446084p1457746.html
Sent from the R help mailing list archive at Nabble.com.
__
Dimitri Shvorob gmail.com> writes:
>
> > This is a "subset sum" problem and has been discussed here in December
>
> Thanks a lot! Will investigate.
>
> > Can you settle for an approximate solution?
>
> Absolutely.
You can use the script from the thread "subset sum problem" to find
approxima
Dimitri Shvorob gmail.com> writes:
>
>
> A 40-element subset proves too much :(
>
> > Error: cannot allocate vector of size 554.1 Mb
>
> Thanks, Bart!
I could solve a problem with n=200, k=40 with Cplex's MIQP solver in less than
a
minute, but that may depend heavily on the data. The mode
A 40-element subset proves too much :(
> Error: cannot allocate vector of size 554.1 Mb
Thanks, 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
Here some kind of a brute force attack:
#brute force solution, only working with relative small subsets:
n <- 200
elem <- 3
target <- 200
x <- rnorm(n,100,10)
x.combinations <- combn(x,elem)
sums <- apply(x.combinations,2,function(x) (sum(x)-target)^2)
ans <- (x.combinations[,which.min(sums)])
Found this
http://n4.nabble.com/Subset-sum-problem-td954423.html#a954423
http://n4.nabble.com/The-subset-matching-challenge-td861840.html#a861840
and learnt/remebered about 'subset sum' and 'knapsack' problems.
My case is different (simpler) in that subset size is fixed.
--
View this message
> This is a "subset sum" problem and has been discussed here in December
Thanks a lot! Will investigate.
> Can you settle for an approximate solution?
Absolutely.
> Rcplex: This is a combinatorial problem and cannot be formulated as a
> quadratic optimization problem.
If the objective func
> Is it a subset of a vector containing 100 elements, or 1ths?
I need to pick 2-40 elements out of a 50-200-element-long vector.
> A random number of elements that should be chosen, or the best 10 values
> which sums up to a defined value?
The best 10 values.
I still think that Rcplex
Could you please specifiy your problem, if possible with some data?
Is it a subset of a vector containing 100 elements, or 1ths?
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.
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
18 matches
Mail list logo