Displaying 20 results from an estimated 1000 matches similar to: "constrOptim doesn´t send arguments to optim!(?)"
2009 Nov 18
1
bug in '...' of constrOptim (PR#14071)
Dear all,
There appears to be a bug in how constrOptim handles ... arguments that
are suppose to be passed to optim, according to the documentation. This
means you can't get the hessian to be returned, for example (so this is
a real problem, and not just a question of mistaken documentation).
Looking at the code, it appears that a call to the user-defined f
includes the ..., when the ...
2023 Aug 05
1
feature request: optim() iteration of functions that return multiple values
For a solution that does not require any change to the original function
being optimized, the following one-liner could be used, which converts
existing functions to functions that return only the first element:
returnFirst <- function(fun) function(...) do.call(fun,list(...))[[1]]
Example:
fr <- function(x) { ## Rosenbrock Banana function
x1 <- x[1]
x2 <- x[2]
ans
2004 Jul 14
2
constrOptim and function with additional parameters?
How can I use a function with some additional input parameters
in constrOptim? For example, something like
fr <- function(x,a) { ## Rosenbrock Banana function
x1 <- x[1]
x2 <- x[2]
a * (x2 - x1 * x1)^2 + (1 - x1)^2
}
where the optimum is to be found w.r.t. x. Calling
optim(c(-1.2,1), fr, NULL, a=100) works as expected, but I fail
to provide the a=100 in the constrained case:
2011 Dec 20
1
constrOptim and problem with derivative
Dear List,
I am using constrOptim to solve the following
fr1 <- function(x) {
b0 <- x[1]
b1 <- x[2]
((1/(1+exp(-b0+b1))+(1/(1+exp(-b0)))+(1/(1+exp(-b0-b1)))))/3
}
As you can see, my objective function is
((1/(1+exp(-b0+b1))+(1/(1+exp(-b0)))+(1/(1+exp(-b0-b1)))))/3 and I would
like to solve for both b0 and b1.
If I were to use optim then I would derive the gradient of the
2011 Dec 21
1
constrOptim and further arguments
Dear List,
I have the code below, where I am using the constrained optimisation
package, 'constrOptim.nl' to find the values of two values, b0 and b1.
I have no problems when I enter further variable information DIRECTLY into
the functions, fn, and heq. In this instance I require fn to have -0.0075
appended to it, and in the case of heq, h[1] has -0.2.
library(alabama)
2007 Sep 07
1
'initial value not feasible' in constrOptim
Dear friends.
I am using function
constrOptim(c(0.5,0.3,0.5), fit.error, fit.error.grr, ui=-1*ui,ci=-1*ci)
and I am confronted with error message "initial value not feasible"
I plug in the initial value of (0.5,0.3,0.5) to function fit.error and
fit.error.grr and have pretty reasonable result. I inequality "ui %*% theta
- ci >= 0" as suggested in the R manual and it is
2007 Sep 10
2
Are the error messages of ConstrOptim() consisten with each other?
Dear Friends.
I found something very puzzling with constOptim(). When I change the
parameters for ConstrOptim, the error messages do not seem to be
consistent with each other:
> constrOptim(c(0.5,0.3,0.5), f=fit.error, gr=fit.error.grr, ui=ui,ci=ci)
Error in constrOptim(c(0.5, 0.3, 0.5), f = fit.error, gr = fit.error.grr, :
initial value not feasible
> constrOptim(c(0.5,0.9,0.5),
2009 Nov 04
3
Constrained Optimization
Hi All,
I'm trying to do the following constrained optimization example.
Maximize x1*(1-x1) + x2*(1-x2) + x3*(1-x3)
s.t. x1 + x2 + x3 = 1
x1 >= 0 and x1 <= 1
x2 >= 0 and x2 <= 1
x3 >= 0 and x3 <= 1
which are the constraints.
I'm expecting the answer x1=x2=x3 = 1/3.
I tried the "constrOptim" function in R and I'm running into some issues.
I first start off
2004 Jul 14
0
Re: [R] constrOptim and function with additional parameters? (PR#7088)
I've moved this from r-help to r-bugs. If you reply, please be
careful that replies go to the right place: r-bugs if your comment is
specifically about the bug (and it contains the PR# in the subject
that will be added when this is cc'd to r-devel), r-devel if general
discussion, not both.
On Wed, 14 Jul 2004 10:01:45 -0400, "Roger D. Peng" <rpeng@jhsph.edu>
wrote :
2006 Dec 08
1
MAXIMIZATION WITH CONSTRAINTS
Dear R users,
I?m a graduate students and in my master thesis I must
obtain the values of the parameters x_i which maximize this
Multinomial log?likelihood function
log(n!)-sum_{i=1]^4 log(n_i!)+sum_
{i=1}^4 n_i log(x_i)
under the following constraints:
a) sum_i x_i=1,
x_i>=0,
b) x_1<=x_2+x_3+x_4
c)x_2<=x_3+x_4
I have been using the
?ConstrOptim? R-function with the instructions
2004 Jul 14
0
Re: [R] constrOptim and function with additional parameters? (PR#7089)
Okay, looking at the docs, then it's not a bug, since the "..."
argument is not actually documented as "other arguments passed to f or
grad". However, that *is* how it's document in `optim', so one can
see how this might cause some confusion.
Now, it's not clear to me which other arguments need to be passed to
`optim' except perhaps `hessian'. Am
2019 Apr 16
1
Fix: menu immediate for submenu
Hello,
the hot key assigned to a MENU BEGIN (via MENU LABEL) doesn't cause the submenu to be entered automatically when MENU IMMEDIATE is used (at previous level). Here's a patch over syslinux 6.03. Patch was tested on Debian.
Regards
Dany
*Sample config*
# hot keys: S,1,2 are immediate (screen flash), but not E
MENU IMMEDIATE
LABEL standard
MENU LABEL ^Standard
MENU BEGIN
MENU LABEL
2010 Feb 25
1
multicore in R
Hi,
i have a function:
zz<- (constrOptim(c(.5,0), fr, grr, ui=rbind(c(-1,0),c(1,-1)), ci=c(-0.9,0.1)))
i can get the result by using command (for example): zz$par
now if i can use multicore:
zz<-parallel(constrOptim(c(.5,0), fr, grr, ui=rbind(c(-1,0),c(1,-1)),
ci=c(-0.9,0.1)))
result < collect(zz)
i cant get my the result: result$par because multicore add process id.
for example:
2023 Aug 03
3
feature request: optim() iteration of functions that return multiple values
Dear all,
I have used optim a lot in contexts where it would useful to be able to iterate function myfun that, in addition to the primary objective to be minimized ('minimize.me'), could return other values such as alternative metrics of the minimization, informative intermediate values from the calculations, etc.
myfun <- function()
{
...
return(list(minimize.me = minimize.me, R2 =
2007 Sep 09
2
What does it mean by "initial value not available"?
Dear friends.
I use ConstrOptim( ) and got error message "initial value not available".
My understanding of "initial value not available" is that one of the
following 3 cases happens:
1.The objective function is not well defined at the point of the initial
value.
2. The differentiation of the objective function is not well defined at the
point of the initial value.
3. The
2016 Apr 13
0
on the output of constrOptim()
Dear list,
The following example of constrOptim() where the initial point is the solution shows that the component counts is not a two-element vector as documented in the man page.
constrOptim(c(1,1), fr, grr, ui = diag(2), ci = c(0,0))
Does anyone have the same behavior?
A possible solution is to put line 69 in constrOptim.R before the first possible break line 67.
Regards, Christophe
2009 Jun 03
1
Using constrOptim() function
I have a function myFunction(beta,x) where beta is a vector of coefficients
and x is a data frame (think of it as a matrix). I want to optimize the
function myFunction() by ONLY changing beta, i.e. x stays constant, with 4
constraints. I have the following code (with a separate source file for the
function):
rm(list=ls())
source('mySourceFile')
2017 Nov 13
3
[PATCH RFC v3 4/6] Documentation: Add three sysctls for smart idle poll
From: Quan Xu <quan.xu0 at gmail.com>
To reduce the cost of poll, we introduce three sysctl to control the
poll time when running as a virtual machine with paravirt.
Signed-off-by: Yang Zhang <yang.zhang.wz at gmail.com>
Signed-off-by: Quan Xu <quan.xu0 at gmail.com>
---
Documentation/sysctl/kernel.txt | 35 +++++++++++++++++++++++++++++++++++
arch/x86/kernel/paravirt.c
2017 Nov 13
3
[PATCH RFC v3 4/6] Documentation: Add three sysctls for smart idle poll
From: Quan Xu <quan.xu0 at gmail.com>
To reduce the cost of poll, we introduce three sysctl to control the
poll time when running as a virtual machine with paravirt.
Signed-off-by: Yang Zhang <yang.zhang.wz at gmail.com>
Signed-off-by: Quan Xu <quan.xu0 at gmail.com>
---
Documentation/sysctl/kernel.txt | 35 +++++++++++++++++++++++++++++++++++
arch/x86/kernel/paravirt.c
2010 Jun 17
2
constrOptim( ): conflict between help page and code
There is a contradiction between what the help page says and what constrOptim actually
does with the constraints. The issue is what happens on the boundary.
The help page says
The feasible region is defined by ?ui %*% theta - ci >= 0?,
but the R code for constrOptim reads
if (any(ui %*% theta - ci <= 0))
stop("initial value not feasible")
The following example