s-news
[Top] [All Lists]

Re: Changing a Parameter value in a NUOPT System

To: <s-news@lists.biostat.wustl.edu>
Subject: Re: Changing a Parameter value in a NUOPT System
From: "Quinn, David" <David.Quinn@nrgenergy.com>
Date: Mon, 28 Oct 2002 09:52:26 -0600
Thread-index: AcJ8hjRc9JLd9Z6FTlGrHCUIbwy9BQAA0huwAIQAxkA=
Thread-topic: How to change a Parameter value in a NUOPT System
It's a bug in the docs that they've entered a problem report to fix.  The " 
should be replaced with the usual SIMPLE assignment operator ~ .  Thanks to 
Sherry Lamonica of Insightful for her help.

function()
{
        a       <- Set(1:10)
        i       <- Element(set=a)
        p       <- Parameter(list(1:10, 1:10), index=i, changeable=T)
        x       <- Variable(list(1:10, rep(30,10)), index=i)
        x[i]    >= p[i]
        f       <- Objective(minimize)
        f       ~ Sum(-1/(x[i]-50), i)
}

s1              <- System(initVal)
sol1    <- solve(s1, f)
current(s1, x)

current(s1,p)~list(1:10,21:30)
#current(s1, x)                 # this will return the old values still
sol1    <- solve(s1, f) # but this solution reflects the new values
current(s1, x)          # and this will print the new values

David

-----Original Message-----
From: Quinn, David 
Sent: Friday, October 25, 2002 8:12 PM
To: s-news@lists.biostat.wustl.edu
Cc: Quinn, David
Subject: [S] Changing a Parameter value in a NUOPT System


Greetings,

The NUOPT User's Guide version 1.4, Chapter 4, p.36 gives the following example 
of changing the value of a Parameter in an already created System:

function()
{
        a       <- Set(1:10)
        i       <- Element(set=a)
        p       <- Parameter(list(1:10, 1:10), index=i, changeable=T)
        x       <- Variable(list(1:10, rep(30,10)), index=i)
        x[i]    >= p[i]
        f       <- Objective(minimize)
        f       ~ Sum(-1/(x[i]-50), i)
}

s1              <- System(initVal)
sol1    <- solve(s1, f)
current(s1, x)

current(s1,p)"list(1:10,21:30)

 The latter statement is supposed to assign a new list value to the Parameter 
p.  However, on my computer that statement causes the error:

Problem in parse(text = "script.run(exprs.literal={..: Syntax error: illegal 
string ("list(1:10,21:30)\n\n})\n\n") on input line 2 
Use traceback() to see the call stack

 > traceback()
4: eval(action, sys.parent())
3: doErrorAction("Problem in parse(text = \"script.run(exprs.literal={..: 
Syntax error: illegal string (\"list(1:10,21:30)\\n\\n})\\n\\n\") on input line 
2",
2: parse(text = 
"script.run(exprs.literal={\ncurrent(s1,p)\"list(1:10,21:30)\n\n})\n"
1: 
Message: Problem in parse(text = "script.run(exprs.literal={..: Syntax error: 
illegal string ("list(1:10,21:30)\n\n})\n\n") on input line 2 

Does anyone know an updated syntax or is this a bug?  I have S-Plus 6.0 Release 
4, and I am not sure what the NUOPT version number is (don't see how to get it 
from the help menu) but it's about 6 months old.

Thanks,
David
--------------------------------------------------------------------
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>