Displaying 6 results from an estimated 6 matches for "heq".
Did you mean:
he
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)
fn<-function(x)
(((1/(1+exp(-x[1]+x[2]))+(1/(1+exp(-x[1])))+(1/(1+exp(-x[1]-x[2])))))/3)-0.0075
heq <- function(x) {
h <- rep(NA,2)
h[1] <- (1-(1/(1+exp(-x[1]))/(1/...
2013 Feb 10
3
Constrained Optimization in R (alabama)
...nderstand why the constraints are not satisfied at the solution. I must be
misinterpreting how to specify the constrains somehow.
library(alabama)
ff <- function (x) {
mm <- matrix(c(10, 25, 5, 10), 2, 2)
matx <- matrix(x, 2, 2)
-sum(apply(mm ^ matx, 1, prod))
}
### constraints
heq <- function(x) {
h <- rep(NA, 1)
h[1] <- x[1] + x[3] -1
h[2] <- x[2] + x[4] -1
h[3] <- x[1] * x[3]
h[4] <- x[2] * x[4]
h
}
res <- constrOptim.nl(par = c(1, 1, 1, 1), fn = ff,
heq = heq)
res$convergence #why NULL?
matrix(round(res$par, 2), 2, 2...
2010 Sep 21
2
Trouble with Optimization in "Alabama" Package
...(15,40,50,15)
fn=function(x,...){
return(-1*(((x[1]^y[5])*(x[3]^(1-y[5])))*(((x[2]^y[6])*(x[4]^(1-y[6]))))))
}
hin=function(x,...){
h=rep(NA,2)
h[1]=((x[1]^y[5])*(x[3]^(1-y[5])))-((y[1]^y[5])*(y[3]^(1-y[5])))
h[2]=((x[2]^y[6])*(x[4]^(1-y[6])))-((y[2]^y[6])*(y[4]^(1-y[6])))
return(h)
}
heq=function(x,...){
h=rep(NA,2)
h[1]=x[1]+x[2]-y[1]-y[2]
h[2]=x[3]+x[4]-y[3]-y[4]
return(h)
}
ans2=constrOptim.nl(par=p1,fn=fn,hin=hin,heq=heq,control.outer=list(itmax=
1000,mu0=.00001),list(y,y,y))
Any advice or explanation of my errors would be greatly appreciated!
--
Erik O. Kimbrough
D...
2011 Dec 29
0
problem of "constrOptim.nl", no hessian and convergence values
...vergence
value of "0".
Since constraints are necessary for the identifiability of my mode, I have
to switch to "constrOptim.nl".
Following is my code of the constraint. Could you please help me to check
is there anything wrong?
Thank a lot!
# define the equality constraint
heq<-function(par){
u<-par[1:m]
a<-par[(m+1):(m+n)]
b<-par[(m+n+1):(m+2*n)]
h<-rep(NA,2)
h[1]<-mean(u)-0
h[2]<-var(u)-1
h
}
heq.jac<-function(par){
u<-par[1:m]
a<-par[(m+1):(m+n)]
b<-par[(m+n+1):(m+2*n)]
j <- matrix(NA, 2, length(par))
j[1,]<-c(rep(1,m),rep(0,2*n...
2010 Aug 10
1
[Fwd: Re: optimization subject to constraints]
-------------- next part --------------
An embedded message was scrubbed...
From: Gildas Mazo <gildas.mazo at curie.fr>
Subject: Re: [R] optimization subject to constraints
Date: Tue, 10 Aug 2010 15:49:19 +0200
Size: 4924
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100810/78862894/attachment.eml>
2011 May 18
1
Constrainted Nonlinear Optimization - lack of convergence
Hello,
I am attempting to utilize the 'alabama' package to solve a constrained
nonlinear optimization problem.
The problem has both equality and inequality constraints (heq and hin
functions are used). All constraints are smooth, i.e. I can differentiate
easily to produce heq.jac and hin.jac functions.
My initial solution is feasible; I am attempting to maximize a function,
phi. As such, I create an objective or cost function '-phi', and the
gradient of th...