Re: [R] How to stop the minimization when the condition does not hold

From: Aleš Žiberna <ales.ziberna_at_guest.arnes.si>
Date: Fri 25 Mar 2005 - 19:16:29 EST

First you have to be more specific, what are actually the parameters of the function that
you want to optiomize and what are actually constants.

So you would need to specify your objective function "function(theta)=lambda*(Constr)^2-f(x,theta)" (which is not realy writen the R-way)
as
fun<-function(Constr,theta){lambda*(Constr)^2-f(x,theta)} However, since, if I understand correclty, you don't want Constr to be smaller or equal to d, you should somehow build this into your objective function, like:

fun<-function(Constr,theta){lambda*(Constr)^2-f(x,theta)+ifelse(Constr<=d, Inf, 0)}

I hope this helps,
Ales Ziberna

> Dear experts!
> I have a minimization problem with non-linear constraint and Objective
> function(theta)=lambda*(Constr)^2-f(x,theta). Theta is a vector of
> parameters.
> I'd like to stop the optimization after the value of the constraint is
> less
> or equal some constant value, say d, and save the last computed value of
> the
> function.
> For this purpose, I thought to define the Objective function like this:
>
> if (Constraint>d) fun<- ....
> else stop
>
> but this does not work with error message:
> Error in f(x, ...) : Object "fun" not found
>
> I am using nlm for minimization.
> Thanks a lot for help and suggestions,
> Vicky Landsman.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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
>
>



R-help@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 Received on Fri Mar 25 19:24:23 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:56 EST