[R] Testing optimization solvers with equality constraints

2021-05-21 Thread Hans W
Just by chance I came across the following example of minimizing a simple function (x,y,z) --> 2 (x^2 - y z) on the unit sphere, the only constraint present. I tried it with two starting points, x1 = (1,0,0) and x2 = (0,0,1). #-- Problem definition in R f = function(x) 2 * (x[1]^2 -

Re: [R] Testing optimization solvers with equality constraints

2021-05-21 Thread Hans W
Mark, you're right, and it's a bit embarrassing as I thought I had looked at it closely enough. This solves the problem for 'alabama::auglag()' in both cases, but NOT for * NlcOptim::solnl -- with x0 * nloptr::auglag -- both x0, x1 * Rsolnp::solnp -- with x0 * Rdonlp::donlp

Re: [R] Testing optimization solvers with equality constraints

2021-05-22 Thread Hans W
Yes. "*on* the unit sphere" means on the surface, as you can guess from the equality constraint. And 'auglag()' does find the minimum, so no need for a special approach. I was/am interested in why all these other good solvers get stuck, i.e., do not move away from the starting point. And how to av

[R] R Redis

2021-11-28 Thread Hans W
> Have anybody used this module? > https://cran.r-project.org/web/packages/rredis/README.html > > Could share your experience please. thank you. I have successfully used this package (on Linux and macOS) and I think it is a great way of storing hashed data across different platforms and programmin

[R] Noisy objective functions

2023-08-13 Thread Hans W
While working on 'random walk' applications, I got interested in optimizing noisy objective functions. As an (artificial) example, the following is the Rosenbrock function, where Gaussian noise of standard deviation `sd = 0.01` is added to the function value. fn <- function(x) (1

Re: [R] Noisy objective functions

2023-08-13 Thread Hans W
;SANN". See the Optimization cheatsheet I wrote with John Nash: "NOTE: CG (John is the author!) and SANN are NOT recommended." https://github.com/hwborchers/CheatSheets/blob/main/Base%20R%20Optim%20Cheatsheet.pdf Hans W. On Sun, 13 Aug 2023 at 21:28, Hans W wrote: > > While w

[R] Dependency errors for package pracma

2023-11-08 Thread Hans W
I tried to update my package {pracma} on CRAN from 2.4.2 (2022-09-21) to version 2.4.4 (2023-11-08). This package reverse depends / imports / suggests on 350 packages on CRAN and 25 packages on Bioconductor. The only changes are small corrections on some help files, a new function for stereographi

Re: [R] Dependency errors for package pracma

2023-11-09 Thread Hans W
What really interests me: With all those strict checking procedures, how is it possible that the new 'Matrix' version got accepted on CRAN? I think this happened twice to me before, and it takes a lot of time to check package dependencies that turn out to be not dependent -- more time than checki

[R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Hans W
library that provides this functionality? Or is there a simple trick to do this in R? The expression 'x[0]' must be possible, does this mean the syntax of R has to be twisted somehow? Thanks, Hans W. [[alternative HTML version deleted]] _

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Hans W
t 13:36, Ben Bolker wrote: > > https://cran.r-project.org/package=index0 > > On Sun, Apr 21, 2024, 3:56 AM Hans W wrote: >> >> As we all know, in R indices for vectors start with 1, i.e, x[0] is not a >> correct expression. Some algorithms, e.g. in graph theory or comb

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-24 Thread Hans W
I hereby protest strongly against the misuse of this thread through unnecessary and pointless discussions. My request was satisfactorily answered with references to R libraries and legitimate warnings about the use of zero-based indexing schemes in R. If you want to continue the discussions, PLEASE

Re: [R] Optimisation with Normalisation Constraint

2018-06-22 Thread Hans W Borchers
One way will be to solve this as an ordinary optimization problem with an equality constraint. Function `alabama::auglag` can do this: library(alabama) fn <- function(p) sum((df$y - p[1]*exp(-p[2]*df$x))^2) heq <- function(p) sum(p[1]*exp(-p[2]*df$x)) - 5 # Start with initial valu

Re: [R] Looking for an R package for Set Cover Problem

2015-01-25 Thread Hans W Borchers
As the Wikipedia page you took your example problem from explains, the sets cover problem can be formulated as an integer linear programming problem. In R, such problems will be solved effectively applying one of the available MILP packages, for example LPsolve or Rsymphony. Kumar Mainali gmail.

Re: [R] Nonlinear integer programming (again)

2015-02-16 Thread Hans W Borchers
Zwick, Rebecca J ETS.ORG> writes: > Oddly, Excel's Solver will produce a solution to such problems but > (1) I don't trust it and > (2) it cannot handle a large number of constraints. > [...] > My question is whether there is an R package that can handle this problem. There are not many free in

Re: [R] integrate with vector arguments

2015-02-26 Thread Hans W Borchers
marKo ffri.hr> writes: > > I'm a bit stuck. > I have to integrate a series of polynomial functions with vector > arguments. > > v1<-c(1:5) > v2<-c(1:5) > > f1<-function (x) {v1*x+v2*x^2} > > The problem is that integrate(f1, 0, 1) does not work. The point is not that there are "vector arguments"

Re: [R] Second order bessel function

2015-03-05 Thread Hans W Borchers
On Wed Mar 4 21:32:30 CET 2015 Chris Vanlangenberg writes: > > I want to compute the numerical values for modified second order bessel > function given x and other parameters, currently base R has a bessel > function for 1st order and I have tried to use the relationship between 1st > and 2nd order

Re: [R] How can I know the Hausdorff dimensions of fractals in the 'fractalcurve' function of package 'pracma'?

2018-09-15 Thread Hans W Borchers
> Dear Dr. Hans W. Borchers, This is a public mailing list; do not address specific people here, everyone can read and (possibly) answer your questions. And please send e-mail in plain text format, not as HTML. > I'm using your 'pracma' package. It is very useful. May I ha

Re: [R] CRAN package NlcOptim query

2018-12-12 Thread Hans W Borchers
This is still not complete: `x_than0` is missing. `Constr_new` is written with a capital 'C'. And aeq2 is a list of column vectors, not a matrix. Setting the tolerance to 0 does not seem to be a good idea. Making aeq2 a matrix and adding `x_than0 <- matrix(c(1, 1))`, then aeq2 <- as.matrix(ae

Re: [R] CRAN package NlcOptim query

2019-01-15 Thread Hans W Borchers
Wed, Dec 12, 2018 at 12:45 PM Hans W Borchers wrote: > > This is still not complete: `x_than0` is missing. > `Constr_new` is written with a capital 'C'. > And aeq2 is a list of column vectors, not a matrix. > Setting the tolerance to 0 does not seem to be a good idea. &

Re: [R] CRAN package NlcOptim query

2019-01-18 Thread Hans W Borchers
The maintainer of the *NlcOptim* package told me that he has fixed the problem and already submitted a new version to CRAN. Thanks, XianYan, for this prompt reaction. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.

Re: [R] lsqlin in R package pracma

2015-08-26 Thread Hans W Borchers
On Mon Aug 24 Wang, Xue, Ph.D. Wang.Xue at mayo.edu wrote > I am looking for a R version of Matlab function lsqlin. I came across > R pracma package which has a lsqlin function. Compared with Matlab lsqlin, > the R version does not allow inequality constraints. > I am wondering if this functionalit

Re: [R] lsqlin in R package pracma

2015-08-26 Thread Hans W Borchers
I am a strong advocate of the *nloptr* package; and "sequential quadratic programming", i.e. slsqp(), should be a good choice for least-squares problems. Note that you still have to provide a starting point. BUT: this point does not need to lie in the interior of the feasible region. So you can st

Re: [R] lsqlin in R package pracma

2015-08-28 Thread Hans W Borchers
I got interested in enabling the full funcionality that MATLAB's lsqlin() has, that is with equality and bound constraints. To replace an equality constraint with two inequality constraints will not work with solve.QP() because it requires positive definite matrices. I will use kernlab::ipop() inst

Re: [R] lsqlin in R package pracma

2015-09-04 Thread Hans W Borchers
On Tue, Sep 1, 2015 at 11:24 PM, Wang, Xue, Ph.D. wrote: > > slsqp in R seems quite slow. Does anyone have some suggestion as how to speed > up this? > It is no surprise that a general solver like slsqp() takes longer than specialized quadratic solvers such as solve.QP, ipop(), or lowRankQP(). Y

Re: [R] principal factor analysis

2008-07-20 Thread Hans W. Borchers
Jinsong Zhao mail.hzau.edu.cn> writes: > > Hi, > > Is there a function to do principal factor analysis in R? Do a 'RSiteSearch("factor analysis")' and you will find several packages for Factor Analysis, such as: FAiRFactor Analysis in R FactoMineR Factor Analysis and Data Min

Re: [R] Non-linearly constrained optimisation

2008-07-20 Thread Hans W. Borchers
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/N

Re: [R] Editor fpr Mac OS

2008-07-21 Thread Hans W. Borchers
Angelo Scozzarella tiscali.it> writes: > > Hi, > is there a good editor for Mac Os? We had the same discussion in December 2007 and again in June 2008. Please consider the recommendations given in these threads. My personal favorite: TextMate , though commercial, is exc

Re: [R] randomForest Tutorial

2008-07-22 Thread Hans W. Borchers
The help pages for 'randomForest' are quite clear in stating how to use the 'randomForest()' function. Input is a data frame (not a csv-file) and a formula involving attribute names. There is a kind of tutorial for classification and clustering with Random Forests on Leo Breiman's web page

Re: [R] How to get rule number in arules

2008-07-24 Thread Hans W. Borchers
As always, 'str(rules)' will provide you with a view on the internal structure of 'rules'. By the way, 'rules' is of class 'rules', see the "rules-class" entry in the ARULES help pages, with more explanations on the meaning of attributes. For example, '[EMAIL PROTECTED]' will show support, confid

Re: [R] Coconut benchmark for R?

2008-07-24 Thread Hans W. Borchers
I wonder what such a benchmark test would be good for. Relevant and speaking tests in Global Optimization are formulated as models in AMPL, GAMS, GMPK, MPS, etc. Rewriting a model in matrix form can be a tedious manual task and I have not yet seen it. Very few optimization packages in R accept s

Re: [R] Fit a 3-Dimensional Line to Data Points

2008-07-25 Thread Hans W. Borchers
S. M. Niaz Arifin yahoo.com> writes: > > Hi Experts, > I am new to R, and was wondering how to do 3D linear > regression in R. In other words, I need to Fit a > 3-Dimensional Line to Data Points (input). > > I googled before posting this, and found that it is > possible in Matlab and other comme

Re: [R] Solving Yis[i] = a*cos((2*pi/T)*(times[i] - Tau)) + ...

2008-08-01 Thread Hans W. Borchers
Treat it as an over-determined linear system, that is: A <- cbind(cos((2*pi/T)*(Times - Tau)), sin((2*pi/T)*(Times - Tau))) qr.solve(A, Yis) because 'solve' will only handle square matrices. Hans W. Borchers Josué Polanco wrote: > > Hi everybody, > &

Re: [R] convert for loop into apply()

2008-08-03 Thread Hans W. Borchers
Also, your request can easily be formulated as an SQL statement, for example utilizing the 'sqldf' package: library(sqldf) a1 <- data.frame(id = 1:6, cat = paste('cat', rep(1:3, c(2,3,1))), st = c(1, 7, 30, 40, 59, 91), en = c(5, 25, 39, 55

Re: [R] Long Range Dependence: Hurst exponent estimation

2008-08-04 Thread Hans W. Borchers
> There is the 'fdim' package that computes the fractal dimension D. Between D and the Hurst exponent H there should be a relation D = 2 - H I wonder if this is true when computing D and H with different approaches Regards, Hans Werner Borchers ABB Corporate Research jpmorgan.com> write

Re: [R] Are there any guis out there, which will allow editing of the graph?

2008-08-04 Thread Hans W. Borchers
Duncan Murdoch stats.uwo.ca> writes: > > On 04/08/2008 12:50 PM, Arthur Roberts wrote: > > Hi, all, > > > > I would like to know if there is any gui interface out there > > (academic or commercial) that allows one to edit R-language generated > > graphs (e.g positioning x axis labels.)

Re: [R] Constrained Optimization

2008-08-04 Thread Hans W. Borchers
gmx.net> writes: > > Hello, > > I am trying to run a constrained optimization in R. "constrOptim" is really > useful and has helped me a lot, but unfortunately, it doesn't provide the > hessian. Is there a solution to this problem? You didn't provide an example to understand why 'optim' do

Re: [R] re cursive root finding

2008-08-08 Thread Hans W. Borchers
As your curve is defined by its points, I don't see any reason to artificially apply functions such as 'uniroot' or 'optim' (being a real overkill in this situation). First smooth the curve with splines, Savitsky-Golay, or Whittacker smoothing, etc., then loop through the sequence of points an

Re: [R] FastICA

2008-08-11 Thread Hans W. Borchers
Maura E Monville gmail.com> writes: > > Is the FastICA R implementation as good as the MatLab Implementation ? > I would appreciate talking to someone who has used FastICA for R. The fastICA packages for Matlab and R (and there is even a version for Python) have a common origin at the Helsinki

Re: [R] FastICA

2008-08-12 Thread Hans W. Borchers
Prof Brian Ripley stats.ox.ac.uk> writes: > > On Tue, 12 Aug 2008, someone with no signature wrote: > > > Maura E Monville gmail.com> writes: > > > >> > >> Is the FastICA R implementation as good as the MatLab Implementation ? > >> I would appreciate talking to someone who has used FastICA for

Re: [R] FastICA

2008-08-12 Thread Hans W. Borchers
I may not have been as wrong as Prof. Ripley suggested when I wrote "The fastICA packages for Matlab and R (...) have a common origin at the Helsinki University of Technology." Please consider the following lines from the 'fastICA' help page (?fastICA): FastICA algorithm Description:

Re: [R] exporting adaBoost model

2008-08-17 Thread Hans W. Borchers
One way to port these kinds of models between applications is the Predictive Model Markup Language (PMML). The R package 'PMML' supports linear regression, rpart, SVM, and others, not adaBoost. On the other side, not even the Python machine learning library Orange does have an import function fo

Re: [R] Exponential smoothing?

2008-08-19 Thread Hans W. Borchers
Öhagen Patrik mpa.se> writes: > > Dear List, > > I have used all my resources (i.e. "help.search) and I still havn't been > able to figure out if there is an Exponential Smoothing command in R. A few weeks ago the book "Forecasting with Exponential Smoothing" by Hyndman et al. has appeared

Re: [R] nonlinear constrained optimization

2008-08-19 Thread Hans W. Borchers
Paul Smith gmail.com> writes: > > Up to my best knowledge, R cannot deal with optimization problems with > nonlinear constraints, unless one uses the penalty method. Outside R, > Ipopt and Algencan can solve problems like yours, but one needs to > program in AMPL and/or C/Fortran. > > Paul > P

Re: [R] Linear objective function with Quadratic constraints

2009-09-19 Thread Hans W. Borchers
vikrant S wrote: > > I am new to R and I want to solve this following problem using R. > > My Objective function is a linear function with Quadratic constraints. I > want to know how to solve this problem and which package will be helpful > for me for solving such type of problems. Moreover my

Re: [R] Quadratic Constraints

2009-09-20 Thread Hans W. Borchers
The package lpSolve (that I have recommended before) supports so-called 'semi-continuous variables', that is "Semi-continuous variables are variables that must take a value between their their minimum and maximum or zero. So these variables are treated the same as regular variables, e

Re: [R] Semi continous variable- define bounds using lpsolve

2009-09-22 Thread Hans W. Borchers
I played around a bit with the original 'lp-solve' program --- i.e., not the R package but the program to be downloaded from Sourceforge ---, at least version 5.5.0.15 through its IDE. I was not even able to reproduce the example on semi-continuous variables in the reference documentation at

Re: [R] Semi continous variable- define bounds using lpsolve

2009-09-22 Thread Hans W. Borchers
But of course, it is always possible to emulate a semi-continuous variable by introducing a binary variable and use some "big-M" trick. That is, with a new binary variable b we add the following two conditions: x3 - 3.6 * b >= 0 and x3 - 10 * b <= 0 # Big-M trick, here M >= 10

[R] Find a rectangle of maximal area

2010-03-21 Thread Hans W Borchers
For an application in image processing -- using R for statistical purposes -- I need to solve the following task: Given n (e.g. n = 100 or 200) points in the unit square, more or less randomly distributed. Find a rectangle of maximal area within the square that does not contain any of these points

Re: [R] Optimization and Linear Programming in R

2009-06-26 Thread Hans W Borchers
csiro.au> writes: > Dear List, > > [...] > > We are looking for a solver that can deal with this nonlinear integer > programming problem. We looked at a number of packages on the CRAN Task > View: Optimization and Mathematical Programming, however, we have not > been able to locate one that

Re: [R] Equivalent to Matlab's "Ans"

2009-06-30 Thread Hans W. Borchers
There is a discussion on this topic under the heading "A shorter version of .Last.value" on July 7, 2008, see for example http://www.nabble.com/A-shorter-version-of-%22.Last.value%22--to18322831.html#a18322831 --Hans Werner Stephane-18 wrote: > > Hi everyone, > I was just wondering if there i

Re: [R] R- NLP on R but ....

2009-07-06 Thread Hans W Borchers
Rahul Varshney gmail.com> writes: > > I'll appreciate the help on the following problem: > > I solved many Nonlinear programming problems with nonlinear > constraintsRdonlp is working well but i am unable to get INTEGER data > with nonlinear constraints in Rdonlp. Is it possible to get Inte

[R] r-project.org address blacklisted by anti-spam software

2009-07-07 Thread Hans W Borchers
Dear List: An e-mail mentioning the r-project.org address and sent to a friend at a German university was considered spam by the local spam filter. Its reasoning: the URL "r-project.org" is blacklisted at uribl.swinog.ch resp. at antispam.imp.ch. I checked the list http://antispam.imp.ch/swi

[R] R interface to PSwarm

2009-07-23 Thread Hans W Borchers
Dear list: Being a bit unsatisfied with global optimization approaches in R such as "SANN" (in 'optim') or DEoptim, I looked for alternatives on the Web, such as PSwarm or PIKAIA. There is an R interface to PSwarm (version 1.4) on its home page which I wa

Re: [R] Automatic differentiation in R

2009-07-23 Thread Hans W. Borchers
Having given a lecture on "Numerical Derivatives" just a short time ago, I would like to mention the following: Many functions, especially in engineering, are not available as formulas built simply from arithmetical operators and elementary functions. They are provided as intricate procedures, a

Re: [R] computing the radius of an arc

2009-07-24 Thread Hans W Borchers
Nair, Murlidharan T iusb.edu> writes: > > Hi!! > > I am interesting in computing the radius of an arc that best approximates > a curve. Is there an R function that I can use to draw an arc? > Nothing useful came up when I searched help.search. Does anyone have any > suggestion to do this? >

Re: [R] computing the radius of an arc

2009-07-28 Thread Hans W Borchers
Nair, Murlidharan T iusb.edu> writes: > > Alex Brenning, the developer of the RSAGA package told me that and I quote > "the RSAGA package (which uses functions from the free geographical > information system [GIS] SAGA GIS) has a curvature function that is designed > to calculate the curvatur

Re: [R] re ading jpeg images?

2009-07-28 Thread Hans W. Borchers
I found the 'biOps' package for "Image and data analysis" quite helpful. (I did some astronomical investigations with it --- counting galaxies in a Hubble picture---and I do recommend this package.) Under Windows you have to unpack the 'libjpeg' and 'libtiff' libraries beforehand somewhere in yo

Re: [R] Find a rectangle of maximal area

2010-03-22 Thread Hans W Borchers
Hans W Borchers googlemail.com> writes: > > For an application in image processing -- using R for statistical purposes -- > I need to solve the following task: > > Given n (e.g. n = 100 or 200) points in the unit square, more or less > randomly distributed. Find a rect

Re: [R] Find a rectangle of maximal area

2010-03-22 Thread Hans W Borchers
Barry Rowlingson lancaster.ac.uk> writes: > > On Mon, Mar 22, 2010 at 4:28 PM, Hans W Borchers > googlemail.com> wrote: > > > Still I believe that a clever approach might be possible avoiding the need > > to > > call a commercial solver. I am getting

Re: [R] Ubuntu, Revolutions, R

2009-10-05 Thread Hans W. Borchers
I updated to Ubuntu 9.10 Beta yesterday, and yes I do see the same message and I am a bit irritated. I don't want to read these 'marketing' lines any time I start up R. I simply deleted the lines from "/etc/R/Rprofile.site" for now, but I am still wondering who put that in. Is there any deeper r

Re: [R] help using R's linprog for LP

2009-10-24 Thread Hans W Borchers
Medha Atre gmail.com> writes: > > Hi, > > I found the reason. By default it puts a condition for x >= 0. Is > there a way to get rid of this condition? The constraints x >= 0 are used in most linear programming realizations. Some bounds from below are needed. The trick to circumvent the restr

Re: [R] Implementation of the "Shuffled Complex Evolution" (SCE-UA) Algorithm

2009-11-11 Thread Hans W Borchers
Simon Seibert mytum.de> writes: > > Good evening list, > I'm looking for an R implementation of the "Shuffled Complex > Evolution” (SCE-UA) algorithm after Duan et al. (1993). Does anybody > know if there is an extension/ package existing that contains it? > Thanks very much for your help! Che

Re: [R] optim or nlminb for minimization, which to believe?

2009-11-29 Thread Hans W Borchers
Your function named 'gradient' is not the correct gradient. Take as an example the following point x0, very near to the true minimum, x0 <- c(-0.2517964, 0.4898680, -0.2517962, 0.4898681, 0.7500995) then you get > gradient(x0) [1] -0.0372110470 0.0001816991 -0.0372102284 0.000182

Re: [R] Modular inverses

2009-12-01 Thread Hans W Borchers
SJ Robson-Davis bristol.ac.uk> writes: > > I want to find the inverse of an integer k mod p (prime.) Is there a > function that can do this for me? I know i could simply write (k^(p-2)) %% > p, but i need to do this for large primes (above 100) and this gives the > warning message: > probabl

Re: [R] Solve linear program without objective function

2009-12-04 Thread Hans W Borchers
Andreas Wittmann gmx.de> writes: > > Dear R-users, > > i try to solve to following linear programm in R > > 0 * x_1 + 2/3 * x_2 + 1/3 * x_3 + 1/3 * x_4 = 0.3 > x_1 + x_2 + x_3 + x_4 = 1 > x_1, x_2, x_3, x_4 > 0, > x_1, x_2, x_3, x_4 < 1 > > as you can see i have no objective function here bes

Re: [R] Modula Generators

2009-12-08 Thread Hans W Borchers
Sam K yahoo.co.uk> writes: > > Hi all, > > Is there function on R for calculating Modula generators? For example for > primes above 100, e.g 157, i want > to know which number generates the group under multiplication mod 157. i.e i > want to find an element whose > order is 156. The problem I

Re: [R] Subset sum problem.

2009-12-09 Thread Hans W Borchers
Geert Janssens telenet.be> writes: > > Hi, > > I'm quite new to the R-project. I was suggested to look into it because I am > trying to solve the "Subset sum" problem", which basically is: > Given a set of integers and an integer s, does any non-empty subset sum to s? > (See http://en.wikipedi

Re: [R] Subset sum problem.

2009-12-09 Thread Hans W Borchers
Geert Janssens telenet.be> writes: > > On Wednesday 9 December 2009, Hans W Borchers wrote: > > Geert Janssens telenet.be> writes: > > > [ ... ] > > > Has anybody tackled this issue before in R ? If so, I would be very > > > grateful if you cou

Re: [R] how to count the total number of (INCLUDING overl apping) occurrences of a substring within a string ?

2009-12-20 Thread Hans W Borchers
Gabor Grothendieck gmail.com> writes: > > Use a zero lookaround expression. It will not consume its match. See ?regexp > > > gregexpr("a(?=a)", "aaa", perl = TRUE) > [[1]] > [1] 1 2 > attr(,"match.length") > [1] 1 1 I wonder how you would count the number of occurrences of, for example, 'aba'

Re: [R] how to count the total number of (INCLUDING overl apping) occurrences of a substring within a string ?

2009-12-20 Thread Hans W Borchers
I am still not able to reproduce this with lookahead. Attempts with gregexpr("(.)?=.\\1", "ababacababab", perl = TRUE) do not work as the lookahead expression apparently does not know about the captured group from before. Regards Hans Werner Correction: I meant the '

Re: [R] how to count the total number of (INCLUDING overl apping) occurrences of a substring within a string ?

2009-12-20 Thread Hans W Borchers
Hans W Borchers googlemail.com> writes: > Sorry, my fault. I forgot the brackets. With gregexpr("(.)(?=.\\1)", "ababacababab", perl = TRUE) it works as you suggested. Thanks Hans Werner __ R-help@r-project.org mailing

Re: [R] newtons method

2009-05-14 Thread Hans W. Borchers
Dear Ravi: Thanks for pointing out the homotopy methods. Coming from Mathematics I was always considering SINGULAR for such a task which is also providing results when the solution set is not isolated points, but an algebraic variety. For single points, homotopy methods appear to be an effectiv

Re: [R] asking advice for Integer Programming packages

2009-03-29 Thread Hans W. Borchers
Looking into the 'Optimization' task view you will also identify the Rsymphony package. A short overview of these packages and a benchmark based on a test suite can be found in . Different problems may have quite different ru

Re: [R] Constrined dependent optimization.

2009-03-30 Thread Hans W. Borchers
Image you want to minimize the following linear function f <- function(x) sum( c(1:50, 50:1) * x / (50*51) ) on the set of all permutations of the numbers 1,..., 100. I wonder how will you do that with lpSolve? I would simply order the coefficients and then sort the numbers 1,...,100 accord

Re: [R] Constrined dependent optimization.

2009-04-04 Thread Hans W. Borchers
Just in case you are still interested in theoretical aspects: In combinatorial optimization, the problem you describe is known as the Quadratic (Sum) Assignment Problem (QAP or QSAP) and is well known to arise in facility and warehouse layouts. The task itself is considered hard, comparable to th

Re: [R] Constrined dependent optimization.

2009-04-09 Thread Hans W. Borchers
uch preprocessing is not worth doing and will not speed up the optimization procedure considerably. Regards, Hans Werner rkevinburton wrote: > > > It has been suggested that I do a cluster analysis. Wouldn't this bet > mepart way there? > > Thank you for your resp

Re: [R] MDL - Fayyad & Irani Discretization

2009-04-27 Thread Hans W. Borchers
I have asked for this some years ago and did not got a positive hint. To my knowledge this has not changed since then. Brian Ripley proposed to use the 'rpart' algorithm for discretization. I think I applied the RELIEF-F method at that time and also wrote a simplified Fayyad-Irani function on my

Re: [R] optimization problem

2010-01-17 Thread Hans W. Borchers
Ravi Varadhan jhmi.edu> writes: > > Interesting! > > Now, if I change the "cost matrix", D, in the LSAP formulation slightly > such that it is quadratic, it finds the best solution to your example: Dear Ravi, I thought your solution is ingenious, but after the discussion with Erwin Kalvela

Re: [R] optimization problem

2010-01-17 Thread Hans W. Borchers
Ravi Varadhan jhmi.edu> writes: > > Dear Hans, > > I agree with your comments. My intuition was that the quadratic > form would be better behaved than the radical form (less > nonlinear!?). So, I was "hoping" to see a change in behavior when > the cost function was altered from a radical (i.

Re: [R] problem with the precision of numbers

2010-01-19 Thread Hans W Borchers
manchester.ac.uk> writes: > [...] > > I suspect this is an invented computation -- the "3456" strikes > me as "unlikely" (it reminds me of my habitual illustrative use > of set.seed(54321)). > > There is a definite problem with the development given by kayj. > When k=2000 and i=k, the formula

Re: [R] problem with the precision of numbers

2010-01-25 Thread Hans W Borchers
kayj yahoo.com> writes: > > > Hi All, > > thank you all for your help. I have tried Bill's script and it works! so I > am trying to think what was the problem and it looks like it i sthe > precision. so you defined a function of the precision and evaluates at > precision=500. Bill, I was wonder

Re: [R] Solving an optimization problem: selecting an & quot;optimal" subset

2010-01-30 Thread Hans W Borchers
Dimitri Shvorob gmail.com> writes: > > > 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?

Re: [R] Solving an optimization problem: selecting an "optimal" subset

2010-01-30 Thread Hans W Borchers
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

Re: [R] Solving an optimization problem: selecting an "optimal" subset

2010-01-31 Thread Hans W Borchers
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

Re: [R] Solving an optimization problem: selecting an "optimal" subset

2010-02-01 Thread Hans W Borchers
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

Re: [R] Solving an optimization problem: selecting an " optimal" subset

2010-02-02 Thread Hans W Borchers
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") >>

Re: [R] Sorting

2010-02-06 Thread Hans W Borchers
David Neu davidneu.com> writes: > > Hi, > > I have a list of vectors (of varying lengths). I'd like to sort this > list by applying a function to each pair of vectors in the list and > returning information to sorting routine that let's it know which one > is larger. > > To solve problems lik

Re: [R] Sorting

2010-02-06 Thread Hans W Borchers
David Neu davidneu.com> writes: > David Neu davidneu.com> writes: > > Hi, > > I have a list of vectors (of varying lengths).  I'd like to sort this > list by applying a function to each pair of vectors in the list and > returning information to sorting routine that let's it know which one > is l

[R] class of 'try' if error is raised

2019-12-15 Thread Hans W Borchers
I have been informed by CRAN administrators that the development version of R issues warnings for my package(s). Some are easy to mend (such as Internet links not working anymore), but this one I don't know how to avoid: Error in if (class(e) == "try-error") { : the condition has length > 1 I

Re: [R] class of 'try' if error is raised

2019-12-15 Thread Hans W Borchers
en mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Sun, Dec 15, 2019 at 6:21 AM Hans W Borchers wrote: >> >> I have been informed by CRAN administrators that th

[R] Which external functions are called in a package?

2020-01-03 Thread Hans W Borchers
How can I find out which functions of my package A are called within another package B that depends on, imports, or suggests package A ? And more specifically, which functions in B are calling functions in A ? I tried to utilize the *pkgapi* package, but get error messages like > map_package(

[R] Fwd: Which external functions are called in a package?

2020-01-03 Thread Hans W Borchers
You are absolutely right. I forgot that there is a difference between the unpacked and the installed directory of a package. The documentation of the *pkgapi* package in development is quite scarce and does not mention the details. Thanks for the tip. --HW PS: Still I would like to learn about ot

Re: [R] Fwd: Which external functions are called in a package?

2020-01-03 Thread Hans W Borchers
e reverse dependencies on your packages' CRAN web page. > > On January 3, 2020 1:45:42 PM PST, Hans W Borchers > wrote: > >You are absolutely right. I forgot that there is a difference between > >the unpacked and the installed directory of a package. The > >documentation

[R] Which external functions are called in a package? [Solved]

2020-01-08 Thread Hans W Borchers
By using the *pkgapi* package and with quite a bit of manual work I was able to (almost) automatically find all function calls to my package in 150 depending on, importing, or suggesting packages. It took two days to overcome all the obstacles during the process -- and was a very rewarding experien

Re: [R] How to double integrate a function in R

2013-07-26 Thread Hans W Borchers
Tiago V. Pereira mbe.bio.br> writes: > I am trying to double integrate the following expression: > > # expression > (1/(2*pi))*exp(-y2/2)*sqrt((y1/(y2-y1))) > > for y2>y1>0. > > I am trying the following approach > > # first attempt > > library(cubature) > fun <- function(x) { (1/(2*

Re: [R] minimizing a numerical integration

2013-02-16 Thread Hans W Borchers
> Dear all, > > I am a new user to R and I am using pracma and nloptr libraries to minimize > a numerical integration subject to a single constraint . The integrand > itself is somehow a complicated function of x and y that is computed > through several steps. i formulated the integrand in a sepa

Re: [R] Using lm to estimate a parameter?

2013-02-19 Thread Hans W Borchers
Uwe Ligges statistik.tu-dortmund.de> writes: > > On 19.02.2013 11:23, hellen wrote: > > Hi, > > I have a data with three variables (X,Y,Z) and I have an equation as > > Z=X/(1+L*X/Y) where L is a constant which need to be estimated from data. > > How should I write the formula in lm or is it poss

Re: [R] R nls results different from those of Excel ??

2013-02-19 Thread Hans W Borchers
Jeff Newmiller dcn.davis.ca.us> writes: > > Excel definitely does not use nonlinear least squares fitting for power > curve fitting. It uses linear LS fitting of the logs of x and y. There > should be no surprise in the OP's observation. May I be allowed to say that the general comments on MS Ex

Re: [R] Optimization in R similar to MS Excel Solver

2013-03-12 Thread Hans W Borchers
Pavel_K vsb.cz> writes: > > Dear all, > I am trying to find the solution for the optimization problem focused on > the finding minimum cost. > I used the solution proposed by excel solver, but there is a restriction > in the number of variables. > > My data consists of 300 rows represent cities

Re: [R] Is DUD available in nls()?

2013-04-02 Thread Hans W Borchers
Bert Gunter gene.com> writes: > > I certainly second all Jeff's comments. > > **HOWEVER** : > http://www.tandfonline.com/doi/pdf/10.1080/00401706.1978.10489610 > > IIRC, DUD's provenance is old, being originally a BMDP feature. > Thanks for the pointer. That seems to be an interesting derivat

  1   2   3   >