NumaWWW: Numerical Mathematics in the World Wide Web

How to fill a program textarea

  • The optimization codes allow you to define the objective and the constraint functions (if any) yourself. In this case you are expected to write a piece of code in the given textarea. The function header and the tail of this subprogram are provided automatically and you are restricted to use the provided variables. It is in no case possible to define variables yourself. The variables are listet on the input form, hence you don't need to remember them.
  • It is necessary here to obey the (old) fortran formatting rules and some language restrictions, since your code will then be input to the automatic differentiator JAKEF. I.e. we provide the optimizers with analytical derivatives and you are dispensed from providing the derivatives yourself.
  • You type a program text as you would do in your editor. We recommend you do this in a separate window at your computer and use ''cut and paste'' to the text area. This avoids the loss of your typing effort in case you go back to the theory page, which clears the input form.
  • You must remember that the first 6 columns of each line have a special meaning: A nonnumeric character in column 1 makes this line a comment line. Otherwise, there may be: 5 blanks, or a positive integer unique in this window, which makes it a ''label'' and you can change instruction flow by a ''goto label''. 5 blanks and a character not equal blank in column 6 make this line a continuation line of a previous one, and this of course can have no label. Here in addition you must remember that no more than 72 characters are allowed for a line. The windows are formatted correspondingly, hence never write beyond the visible area and this will be okay.
  • Examples are filled in these fields which show you the expected format, hence this should be easier for you than this text suggests.
  • You find more specifications of the input format in the following sections - Function name, variables and parameters, FORTRAN instructions as well as examples of an implementation.
 

Function names, variables and parameters

  • As variable names we provide: x or sometimes t , with multiple variables x(j), j=1,...,n, where n is the dimension.
  • function names are f(1),...,f(n) for vector functions, and f, fx, gxi, hxi, .. for scalar ones.
  • Sometimes you can use predefined local variables x1h,....,x9h (not necessarily meant to be equal to x(1) etc) or others, this is mentioned explicitly where applicable.
  • In many cases you can use the variable pi (really 4*tan-1(1)), sqrt2(=1.414...) and e=exp(1). This is explictly stated from case to case.
  • It is impossible to define variables yourself or to make use of f77's ''implicitly defined'' variables. Unadvertently you will get an error message in doing so.
 

f77 commands

  • How to format your input is described above. Here follow some more tips.
    1. Most of the applications allow you to specify an identifying text for your run, since you may want to ''cut and paste'' the output to your local window. Having multiple runs in one session may make it hard to identify the results otherwise. In this text no blank and no comma must be inserted, use underscore instead, but you may leave this blank.
    2. In writing code for functions, you may want to use loops and
      if constructs.
      you must restrict yourself to the standard form
      do label counting_variable=first value,last value, step
      sequence of instructions
      labelcontinue
      with ''label'' a numeric label as described above and
      if ( logical expression ) goto label
 

Examples

A function computation:
fx=0
do 100 j=1,20
if ( x(j) .le. 0.d0 ) goto 200
fx=fx+(x(j)+dble(j))*dlog(x(j))
100 continue
return
200 err=.true.
A constraint function :
Normally where will be many equality and inequality constraints. The codes here compute these individually, using subroutines which get the function number always as a variable i. You must use this, but never must change it! The function variable will always be a vector x with components whose number goes from 1 to n, with n being globally defined for the problem. you compute the result, which always takes the same name, hxi for an equality and gxi for an inequality, using the ''computed goto'' , a jump going to the i-th label in the list of labels. Let us assume we have n=4, 2 equality and 5 inequality constraints: and Then this is expressed as two textarea's :
for the equalities you write

For the inequalities this must read
 
Back to the top!

23.06.2010