I want to write exponential function in AMPL

1,954 views
Skip to first unread message

Sachin Argade

unread,
May 7, 2012, 6:03:43 PM5/7/12
to AMPL Modeling Language, sachin...@gmail.com
Hello,

I want to write exponential function. For example suppose I have to
write e^([15000/383-15000/(H-273)]) in AMPL, Can I write like this
subject to constr2{i in 1..24}:TLAF[i]>=e^((15000/383)-(15000/
((detlathetaor[i])?
Is e^(......) is the right syntax or right way to write exponential ?
Please let me know,

Thanks,
Sachin.

Robert Fourer

unread,
May 8, 2012, 11:38:57 AM5/8/12
to am...@googlegroups.com
The exponential function in AMPL is exp(...), where ... is replaced by any
expression that evaluates to a number.

You can write e^(...), but only if you define a parameter e and set it to
exp(1). The exp function is very slightly more accurate, however.

Bob Fourer
4...@ampl.com

Sachin Argade

unread,
May 8, 2012, 12:53:32 PM5/8/12
to am...@googlegroups.com
oh ok thanks Bob.

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to am...@googlegroups.com.
To unsubscribe from this group, send email to ampl+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ampl?hl=en.




--
Sachin Argade

rim...@gmail.com

unread,
Jul 11, 2015, 4:52:46 PM7/11/15
to am...@googlegroups.com, sachin...@gmail.com
Hi,
I have a problem in defining an Exponential parameter,
here is the problem,
param Emrg {r in 1..R} Exponential ()

I do not know how can I define this parameter in a way that it follows a exponential function with Lamda=8?
How should I write this parameter Emrg in .dat form?

Any help would be highly appreciated!
Amir

victor.z...@gmail.com

unread,
Jul 12, 2015, 3:47:06 PM7/12/15
to am...@googlegroups.com, sachin...@gmail.com
The function you are looking for is called exp. Please see here for the list of built-in AMPL functions.

HTH,
Victor

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.

To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

rim...@gmail.com

unread,
Sep 14, 2015, 4:52:32 PM9/14/15
to AMPL Modeling Language, sachin...@gmail.com
Can you please give an example how to define a parameter that follows exponential distribution in .mod and then how can I assign value to the mean of exp function in .dat file.
Thank you!

Robert Fourer

unread,
Sep 15, 2015, 10:53:31 AM9/15/15
to am...@googlegroups.com
You can write

param emean > 0;
param a = exp(emean);

Then you can assign a value to param emean in the data file. Note however that the "param a = ..." statement will only assign a random sample from the exponential distribution (with mean of emean) to the parameter a. Currently it is not possible to define a "random" parameter that has an exponential distribution but no particular value.

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of rim...@gmail.com
Sent: Monday, September 14, 2015 12:27 PM
To: AMPL Modeling Language
Cc: sachin...@gmail.com
Reply all
Reply to author
Forward
0 new messages