Hi, I have a problem with R optimization. I try to copy excel solver acts to R. Solver has some problems with nonlinear optimisation. Suppose we have resources: (X,Y,Z)=(20, 30, 25) and services: matrix(10,11,0, 13,12,10, 0,24,26), nrow=3. Now we should optimize the problem: max( min(a/10,b/11) + min(aa/13,bb/12,cc/10) + min(24/bb,26/cc) ) so that a+aa<=15 b+bb+bb<=35 cc+ccc<=40 Can you help me? I don't get the constraints to optim-function. Is there any other way to do this than optim? -- View this message in context: http://r.789695.n4.nabble.com/Optimizing-problem-R-tp4631048.html Sent from the R help mailing list archive at Nabble.com.
I'have tried to do something like that staring values:
pars=c(x1=1,x2=1,x3=1,x4=1,x5=1,x6=1,x7=1)
and the function
f=function(pars){
min(pars[1]/10,pars[2]/11)+min(pars[3]/20,pars[4]/22,pars[5]/25)+min(pars[6]/36,pars[7]/28)
}
optim(pars,f)
but how can I get the constraints in there also?
--
View this message in context:
http://r.789695.n4.nabble.com/Optimizing-problem-R-tp4631048p4631050.html
Sent from the R help mailing list archive at Nabble.com.
On Wed, May 23, 2012 at 12:35:31AM -0700, kylmala wrote:> Hi, > > I have a problem with R optimization. I try to copy excel solver acts to R. > Solver has some problems with nonlinear optimisation. > > Suppose we have resources: (X,Y,Z)=(20, 30, 25) and services: > matrix(10,11,0, 13,12,10, 0,24,26), nrow=3. > > Now we should optimize the problem: max( min(a/10,b/11) + > min(aa/13,bb/12,cc/10) + min(24/bb,26/cc) ) so that > > a+aa<=15 > b+bb+bb<=35 > cc+ccc<=40Hi. The criterion function contains two minima of linear functions, namely min(a/10,b/11) and min(aa/13,bb/12,cc/10), and one minimum of nonlinear functions, namely min(24/bb,26/cc). Is this correct? In a later email, you formulate a problem, where all terms are linear. If the term min(24/bb,26/cc) is actually min(bb/24,cc/26), then the problem may be formulated as a linear programming problem by introducing additional variables m1, m2, m3 and the constraints m1 <= a/10 m1 <= b/11 m2 <= aa/13 m2 <= bb/12 m2 <= cc/10 m3 <= bb/24 m3 <= cc/26 and maximizing m1 + m2 + m3. This problem may be solved using package lpSolve. Petr Savicky.