Hello R community, I am using R for creating a model using optimization. I would like to ask if there is R-function/package for solving the problem below: Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each i = 1, ..., n. subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi <= c, where c is a scalar. (x is a vector of variables, A is nxm matrix, b is a vector) [[alternative HTML version deleted]]
Hello R community, I am sorry for the previous accidental posting as I pressed a wrong key. I am using R for creating a model using optimization. I would like to ask if there is R-function/package for solving the problem below: Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each i = 1, ..., n. subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi <= c, where c is a scalar. (x is a vector of variables, A is nxm matrix, b is a vector) I tried to use optim(), nlm(), and constrOptim, but they do not allow a kind of the constraint in the problem above. Thanks for your help. Regards, Vu ----- Original Message ---- From: Vu Nguyen <vuqn@yahoo.com> To: r-help@stat.math.ethz.ch Sent: Tuesday, July 31, 2007 3:50:52 PM Subject: Nonlinear optimization with constraints Hello R community, I am using R for creating a model using optimization. I would like to ask if there is R-function/package for solving the problem below: Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each i = 1, ..., n. subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi <= c, where c is a scalar. (x is a vector of variables, A is nxm matrix, b is a vector) [[alternative HTML version deleted]]
Make a function and add the constraints to the function eg. if (Ai1 > x ) Inf. By making the result Infinite, you have added the constraints manually. Vu Nguyen-4 wrote:> > Hello R community, > > I am sorry for the previous accidental posting as I pressed a wrong key. > > I am using R for creating a model using optimization. I would like to ask > if there is R-function/package for solving the problem below: > > Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each > i = 1, ..., n. > subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi <= c, where c is a > scalar. > (x is a vector of variables, A is nxm matrix, b is a vector) > > I tried to use optim(), nlm(), and constrOptim, but they do not allow a > kind of the constraint in the problem above. > > Thanks for your help. > > Regards, > Vu > > > ----- Original Message ---- > From: Vu Nguyen <vuqn at yahoo.com> > To: r-help at stat.math.ethz.ch > Sent: Tuesday, July 31, 2007 3:50:52 PM > Subject: Nonlinear optimization with constraints > > > Hello R community, > > I am using R for creating a model using optimization. I would like to ask > if there is R-function/package for solving the problem below: > > Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each > i = 1, ..., n. > subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi <= c, where c is a > scalar. > (x is a vector of variables, A is nxm matrix, b is a vector) > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: http://www.nabble.com/Re%3A-Nonlinear-optimization-with-constraints-tf4197046.html#a11941309 Sent from the R help mailing list archive at Nabble.com.
If you put in penalties for breaking constraints, it is generally better to make the penalty depend on the size of the violation. This keeps the function continuous (though usually not differentiable at the boundary), and gives the optimizer a hint about which way to go. Patrick Burns patrick at burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Bartjoosen wrote:>Make a function and add the constraints to the function eg. if (Ai1 > x ) >Inf. >By making the result Infinite, you have added the constraints manually. > > > >Vu Nguyen-4 wrote: > > >>Hello R community, >> >>I am sorry for the previous accidental posting as I pressed a wrong key. >> >>I am using R for creating a model using optimization. I would like to ask >>if there is R-function/package for solving the problem below: >> >>Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each >>i = 1, ..., n. >>subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi <= c, where c is a >>scalar. >>(x is a vector of variables, A is nxm matrix, b is a vector) >> >>I tried to use optim(), nlm(), and constrOptim, but they do not allow a >>kind of the constraint in the problem above. >> >>Thanks for your help. >> >>Regards, >>Vu >> >> >>----- Original Message ---- >>From: Vu Nguyen <vuqn at yahoo.com> >>To: r-help at stat.math.ethz.ch >>Sent: Tuesday, July 31, 2007 3:50:52 PM >>Subject: Nonlinear optimization with constraints >> >> >>Hello R community, >> >>I am using R for creating a model using optimization. I would like to ask >>if there is R-function/package for solving the problem below: >> >>Minimize sum(abs(exp^(Ai1 x1 + Ai2 x2 + ... + Aim xm - bi) - 1)), for each >>i = 1, ..., n. >>subject to Ai1 x1 + Ai2 x2 + ... + Ajm xm - bi <= c, where c is a >>scalar. >>(x is a vector of variables, A is nxm matrix, b is a vector) >> [[alternative HTML version deleted]] >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>https://stat.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide >>http://www.R-project.org/posting-guide.html >>and provide commented, minimal, self-contained, reproducible code. >> >> >> >> > > >