Fortran-like Modeling Language for Evaluating Functions and Specifying Optimization Problems at Runtime

A new application programming interface for evaluating functions and specifying optimization problems at runtime has been developed. The new interface, named FEFAR, uses a simple language named LEFAR. Compared with other modeling languages such as AMPL or OSil, LEFAR is Fortran- like hence easy to learn and use, in particular for Fortran programmers. FEFAR itself is a Fortran subroutine hence easy to be linked to user's main programs in Fortran language. With FEFAR a developer of optimization solver can provide pre- compiled, self-executable and directly usable software products. FEFAR and LEFAR are already used in some optimization solvers and should be a useful addition to the toolbox of programmers who develop solvers of optimization problems of any type including constrained/unconstrained, linear/nonlinear, smooth/nonsmooth optimization. Keywords-programming language; Fortran computing language; Fortran subroutine; Application programming interface; Runtime function evaluation; Mathematical programming; Optimization problem; Optimization modeling language. I. INTRODUCTION In this paper we introduce to readers a new application programming interface for evaluating functions and specifying optimization problems at runtime. FEFAR is a Fortran subroutine For Evaluating Functions At Runtime. It can be linked to a programmer's main program to provide a way to evaluate a function or solve an optimization problem at runtime. The functions or optimization problems must be written in a new language called LEFAR I developed together with FEFAR, for evaluating functions or specifying optimization problems at runtime. LEFAR is similar to but much simpler than Fortran, and that is a big merit as it is easy to learn and use and yet powerful enough and complex enough to be able to specify any functions and optimization problems at runtime. FEFAR and LEFAR are already used in USsolver (1) and UNsolver (2), two binary machine code programs for solving unconstrained smooth or nonsmooth optimization problems.


INTRODUCTION
In this paper we introduce to readers a new application programming interface for evaluating functions and specifying optimization problems at runtime.FEFAR is a Fortran subroutine For Evaluating Functions At Runtime.It can be linked to a programmer's main program to provide a way to evaluate a function or solve an optimization problem at runtime.The functions or optimization problems must be written in a new language called LEFAR I developed together with FEFAR, for evaluating functions or specifying optimization problems at runtime.LEFAR is similar to but much simpler than Fortran, and that is a big merit as it is easy to learn and use and yet powerful enough and complex enough to be able to specify any functions and optimization problems at runtime.FEFAR and LEFAR are already used in USsolver [1] and UNsolver [2], two binary machine code programs for solving unconstrained smooth or nonsmooth optimization problems.
This paper is organized as following.Section II gives the background and related works, section III explains the FEFAR interfaces and parameters, and give some examples, section IV explains the rules of the LEFAR language with comparison to Fortran language, and section V gives some other resources and a near future work scope.

II. BACKGROUND AND RELATED WORKS
Advanced computing languages such as Fortran [3] and C are compiled language [4].Unlike interpreted languages [5] such as the S language [6] in SPLUS and R, and the MATLAB language [7], compiled languages must first compile the main program and all other subroutines and functions into a binary machine code program.Programmers of such compiled languages often want to be able to evaluate functions at runtime after the source code of the program has been compiled into a binary machine code program.They may also want to be able to specify/describe optimization problems at runtime by using a modeling language similar to, or, ideally the same, advanced computing language they use, such as Fortran.They may want to keep the source codes of their programs to themselves for commercial reasons but still want others to be able to use or test their software products by giving them a self-executable, directly usable binary machine code program.On the user's end, the binary machine code programs are self-executable and usable immediately; hence the users, in particular the ordinary users but not programmers, are eased from the troubles of finding or purchasing a compiler and compiling the source code programs into binary machine code programs.There are some available modeling languages such as AMPL [8] and OSiL [9] for modeling and specifying optimization problems at runtime though, it is still better to have another modeling language and application programming interface that meet the abovementioned needs better, and that is why I have developed FEFAR and LEFAR, a new application programming interface and modeling language for evaluating functions and specifying optimization problems at runtime, in particular for Fortran programmers.FEFAR is a Fortran subroutine For Evaluating Functions At Runtime.It can be linked to a programmer's main program to provide a way to evaluate a function or solve an optimization problem at runtime.The functions or optimization problems must be written in a new language called LEFAR I developed together with FEFAR, for evaluating functions or specifying optimization problems at runtime.LEFAR is similar www.ijacsa.thesai.org to but much simpler than Fortran, and that is a big merit as it is easy to learn and use.Another reason I made it simple is to shorten the processing and running time of LEFAR codes at runtime, subject to yet being powerful enough and complex enough to be able to specify any functions and optimization problems.

III. FEFAR INTERFACES
In the following we use gfortran [12] to illustrate how to use FEFAR, but other compilers work as well.There are several interfaces of FEFAR: FEFAR1.obj,FEFAR2.obj,FEFAR3.obj,etc.The following is a simple test program of FEFAR1.objlinked to the main program at compiling and linking stage.In calling each FEFAR, a file name is prompted to be inputted at runtime.The value of the integer variable "if123" will be passed to the first integer variable in the runtime file to control which statements in the runtime to be executed or not.For example, initial value assignment statements only need to be executed once, and most other statements need to be executed each time the subroutine is called.Another example is "if123==3" can be used for only displaying values without executing many other statements.Of course, the integer variable "if123" can take any integer value for more complex controls.The argument "b" is a real data type array of dimension 1 for getting initial values of the function from the source code at runtime or setting from the main program the next step x values of the function for solving an optimization problem .The argument "f" is a real variable of the value of the function.In FEFAR2 and FEFAR3 argument "g" is a real data type array of dimension 1 for getting array values of dimension 1 returned from the runtime function, with the only difference being that FEFAR3 returns an integer "kg" for the actual number of array values calculated and returned from the runtime function file which are to be used by the main program www.ijacsa.thesai.orgwhile FEFAR2 assumes implicitly kg=k.Argument "g" can be used to return gradients of a differentiable function, for example.It can also be used to return values of constraints.

IV. RULES OF LEFAR LANGUAGE
LEFAR is a very simple language similar to but far simpler than Fortran language, so in many cases below we just give the Fortran equivalence of most LEFAR statements.

D. Arrays
Arrays are specified and used the same way as in Fortran.

E. Operators, mathematical expressions and the assignment
All operators in Fortran work the same way in LEFAR.The assignment and mathematical expressions have the same rules as Fortran.For example, x(2,1)=2*(3.4+5)**2-5*x(1,2)**2 is valid in LEFAR and evaluated the same way as in Fortran.Additionally, "^" is also used for exponentiation, the same as "**".

F. Do loop
There is only one construct of do looping: They are equivalent to Fortran's IF-THEN constructs.In LEFAR, however, the word "then" is not necessary, hence the following are also valid: by which listed values between are read into x starting from the most right array index then the second array index from the right until the first array index from the left hand side.www.ijacsa.thesai.org where 'fmin' is the value of the function to be returned to the main program, 'x' is the vector input of the function passed to and from the main program, and 'if123' is a working integer variable passed from the main program.Important: the first 'real ::' variable is the one to be returned, the first 'real, dimension(k) ::' vector is the input variable of the function, where 'k' is a positive integer like 2, 3, etc., which is the dimension of the function, while the first 'integer ::' variable is a special integer variable come from the main program (that is, the value of the variable is set in the main program and passed to the function for controlling which blocks to be executed).They can use different names such as 'f', 'b', 'iw'.Generally, within the block "if(if123==1) … end if" are statements to be processed only once.For example, 'data … end data' statements, to specify initial values for an optimization problem, etc.Within the block "if(if123<=2) … end if" are statements to be processed repeatedly like in optimization program.Within the block "if(if123==3) … end if" are statements to be processed only once in the final stage.For example, after a minimum x* has been found, it can be used in this block to evaluate values of other variables or functions depending on it.Two other rules are: ♦ In Fortran, ';' is used to put and separate two statements in one line.In LEFAR, however, there is no way to separate two one-line statements in one line.♦ There should not be a ';' nor any other separator at the end of any statement.
A side note of the above two rules, they make the processing and running time of the codes shorter.

V. RESOURCES AND FUTURE WORK
More codes, examples and future work are available at http://sites.google.com/site/SoftSome.Future work may include a C computing language version of FEFAR for easy linking of optimization solver programs in C language to FEFAR.