s-news
[Top] [All Lists]

Re Splus NuOpt for S-PLUS Version 1.4.6.3

To: <s-news@lists.biostat.wustl.edu>
Subject: Re Splus NuOpt for S-PLUS Version 1.4.6.3
From: "Steve Su" <s.su@qut.edu.au>
Date: Mon, 20 Sep 2004 12:14:00 +1000
Dear All,

I would like to thank John James from insightful.com for his useful reply :)

Please see below :)

Steve.

----- Original Message ----- 
From: "John James" <JJames@insightful.com>
To: "Steve Su" <s.su@qut.edu.au>
Sent: Friday, September 17, 2004 10:08 PM
Subject: RE: [S] Splus NuOpt for S-PLUS Version 1.4.6.3


Steve

I happen to be working on a similar problem...

Your issue is that NUOPT doesn't always get the correct method or parameters
automatically. "Trust" is effective but needs care with initial positions.

Add

nuopt.options(scaling="on", method="asqp", told=1e-10, tolx=1e-10,
eps=1e-10)

before System, and on my machine it seems to solve correctly.

Also I would always define *all* constraints as constraints - or none, and
you seem to have a couple of typo's (q.v. q[i]<-1)

Hope this helps

John James
Insightful

######################################################################

module(nuopt)
initial <- c(0,0,0)
new.model()
I<-Set(1:3)
i<-Element(set=I)
p<-Variable(init=list(1:3, initial), index=I)
q<-Variable(init=list(1:3, initial), index=I)

Sum(p[i],i)==1
Sum(q[i],i)==1

p[i]>=0
p[i]<=1

q[i]>=0
q[i]<=1

f <- Objective("maximize")
f~(Sum(p[i]*q[i],i)-Sum(q[i]^2,i))*100+(Sum(q[i]^2,i)-1)*10

# nuopt.options()
nuopt.options(scaling="on", method="asqp", told=1e-10, tolx=1e-10,
eps=1e-10)
sys <-System()
sol <- solve(sys)

############################################################################
#
########

qq <- pp <- rep(1/3, 3)
qq <- pp <- rep(0, 3)
qq[1]<- pp[1] <- 1

pp <- as.vector(sol$variables$p$current)
qq <- as.vector(sol$variables$q$current)

100*pp[1]*qq[1]+100*pp[2]*qq[2]+100*pp[3]*qq[3]-100*qq[1]*qq[1]-100*qq[2]*qq
[
2]-100*qq[3]*qq[3]+10*qq[1]*qq[1]+10*qq[2]*qq[2]+10*qq[3]*qq[3]-10




-----Original Message-----
From: Steve Su [mailto:s.su@qut.edu.au]
Sent: 17 September 2004 09:07
To: s-news@lists.biostat.wustl.edu
Subject: [S] Splus NuOpt for S-PLUS Version 1.4.6.3

Dear All,

I was trying out Splus NuOpt S-PLUS Version 1.4.6.3 with the following code:

I am wondering why minimize and maximize gives me exactly the same answer, I
know it shouldn't be, for example when p[1]=q[1]=1 and
p[2]=p[3]=q[3]=q[2]=0,
the objective would be 0, which is bigger than the -20/3 Splus NuOpt gave
me?

I have enclosed the code as below:

module(nuopt)
new.model()
I<-Set(1:3)
i<-Element(set=I)
p<-Variable(index=I)
q<-Variable(index=I)
C1<-Constraint()
C1<-Sum(p[i],i)==1
Sum(q[i],i)==1
p[i]>=0
q[i]>=0
f<-Objective("minimize")
f~(Sum(p[i]*q[i],i)-Sum(q[i]^2,i))*100+(Sum(q[i]^2,i)-1)*10
p[i]<-1
q[i]<-1
sys<-System()
solve(sys)






****************************************************************************
**********

 Steve Su (s.su@qut.edu.au)


 School of Accountancy
 Queensland University of Technology

 Postal Address: Steve Su, School of Accountancy, QUT, PO Box 2434,
Brisbane,
Queensland, Australia, 4001.

 Phone:  +61 7 3864 4357
 Fax:    +61 7 3864 1812
 Mobile: 0421  840  586
     .
   _--_|\
  /      QUT
  \_.--._/
        v

****************************************************************************
**********

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with the
BODY of the message:  unsubscribe s-news


<Prev in Thread] Current Thread [Next in Thread>
  • Re Splus NuOpt for S-PLUS Version 1.4.6.3, Steve Su <=