tolga.i.uzuner at jpmorgan.com
2008-Jul-19 22:10 UTC
[R] Non-linearly constrained optimisation
Dear R Users, I am looking for some guidance on setting up an optimisation in R with non-linear constraints. Here is my simple problem: - I have a function h(inputs) whose value I would like to maximise - the 'inputs' are subject to lower and upper bounds - however, I have some further constraints: I would like to constrain the values for two other separate function f(inputs) and g(inputs) to be within certain bounds This means the 'inputs' must not only lie within the bounds specified by the 'upper' and 'lower' bounds, but they must also not take on values such that f(inputs) and g(inputs) take on values outside defined values. h, f and g are all non-linear. I believe constroptim would work if f and g were linear. Alas, they are not. Is there any other way I can achieve this in R ? Thanks in advance, Tolga Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the event you are receiving the offering materials attached below related to your interest in hedge funds or private equity, this communication may be intended as an offer or solicitation for the purchase or sale of such fund(s). All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.
Tolga, Your issue seems to be a common one at present. While I am relatively new to R (and would welcome being corrected), I haven't been able to find an existing module to parse algebraic equations and build acyclic networks (for the objective function and each constraint) to submit to solving routines (such as optim, BB, Patrick Burns' genopt from S Poetry, Algencan etc). Certainly there are the components to build one, for example topological sort packages like mathgraph and Carter Butts' network. I have implemented acyclic networks in three major projects and so I have started to contemplate the missing package in both R and Mathematica. At this point I am significantly further advanced in Mathematica, building from Eric Swanson's excellent perturbationAIM package. Yet it seems slightly odd to me that the required functionality hasn't been developed in R up to this point in time. Many people need this functionality, the network algorithms have been around for forty years and there are many solvers, even open source ones like ipopt. Of course, the "big guns" in this field are GAMS and AMPL and it is perhaps their overwhelming presence or respect for the developers of these packages that has led R developers to be somewhat cautious about releasing code in this area. However, there are already alternatives. For a quasi open source version of AMPL you could use Dr Ampl (http://www.gerad.ca/~orban/drampl/ ) or write your problem in GAMS or AMPL format and submit to the Neos server either directly (http://neos.mcs.anl.gov/neos/) or by using pyneos.py (www.gerad.ca/~orban/pyneos/pyneos.py). I really hope this gets worked out in R at some stage! Stuart On Sun, 20 Jul 2008 08:10:35 +1000, <tolga.i.uzuner at jpmorgan.com> wrote:> Dear R Users, > I am looking for some guidance on setting up an optimisation in R with > non-linear constraints. > > Here is my simple problem: > - I have a function h(inputs) whose value I would like to maximise > - the 'inputs' are subject to lower and upper bounds > - however, I have some further constraints: I would like to constrain the > values for two other separate function f(inputs) and g(inputs) to be > within > certain bounds > > This means the 'inputs' must not only lie within the bounds specified by > the 'upper' and 'lower' bounds, but they must also not take on values > such > that f(inputs) and g(inputs) take on values outside defined values. h, f > and g are all non-linear. > > I believe constroptim would work if f and g were linear. Alas, they are > not. Is there any other way I can achieve this in R ? > > Thanks in advance, > Tolga > > Generally, this communication is for informational purposes only > and it is not intended as an offer or solicitation for the purchase > or sale of any financial instrument or as an official confirmation > of any transaction. In the event you are receiving the offering > materials attached below related to your interest in hedge funds or > private equity, this communication may be intended as an offer or > solicitation for the purchase or sale of such fund(s). All market > prices, data and other information are not warranted as to > completeness or accuracy and are subject to change without notice. > Any comments or statements made herein do not necessarily reflect > those of JPMorgan Chase & Co., its subsidiaries and affiliates. > > This transmission may contain information that is privileged, > confidential, legally privileged, and/or exempt from disclosure > under applicable law. If you are not the intended recipient, you > are hereby notified that any disclosure, copying, distribution, or > use of the information contained herein (including any reliance > thereon) is STRICTLY PROHIBITED. Although this transmission and any > attachments are believed to be free of any virus or other defect > that might affect any computer system into which it is received and > opened, it is the responsibility of the recipient to ensure that it > is virus free and no responsibility is accepted by JPMorgan Chase & > Co., its subsidiaries and affiliates, as applicable, for any loss > or damage arising in any way from its use. If you received this > transmission in error, please immediately contact the sender and > destroy the material in its entirety, whether in electronic or hard > copy format. Thank you. > Please refer to http://www.jpmorgan.com/pages/disclosures for > disclosures relating to UK legal entities. > > ______________________________________________ > R-help at r-project.org 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.-- DISCLAIMER: This email message and any accompanying atta...{{dropped:10}}
Please have a look at the 'Rdonlp2' package at <http://arumat.net/Rdonlp2/>. It provides non-linear optinization with nonlinear constraints, so it may be exactly what you are looking for. Whether this algorithm is powerful enough for your task has to be seen. There are examples on the Web page that will enable a quick start. You did not give information about the complexity of your task, nor whether you are seeking local or global solutions. Hans Werner Borchers ABB Corporate Research Dear R Users, I am looking for some guidance on setting up an optimisation in R with non-linear constraints. Here is my simple problem: - I have a function h(inputs) whose value I would like to maximise - the 'inputs' are subject to lower and upper bounds - however, I have some further constraints: I would like to constrain the values for two other separate function f(inputs) and g(inputs) to be within certain bounds This means the 'inputs' must not only lie within the bounds specified by the 'upper' and 'lower' bounds, but they must also not take on values such that f(inputs) and g(inputs) take on values outside defined values. h, f and g are all non-linear. I believe constroptim would work if f and g were linear. Alas, they are not. Is there any other way I can achieve this in R ? Thanks in advance, Tolga ----- ---- Hans W. Borchers ABB Corporate Research Germany -- View this message in context: http://www.nabble.com/Non-linearly-constrained-optimisation-tp18549310p18558334.html Sent from the R help mailing list archive at Nabble.com.