|
Building the external function evaluator |
Top Previous Next |
|
The user must write a custom DLL to evaluate the functions. It must be callable as the function
GEFUNC (icntr, x, f, d, msgcb)
This code is created in a programming language (C, Delphi, Fortran etc.). The GEFUNC parameters are
Also the function must return a control code indicating whether any problems were encountered. In doing this care must be taken to insure that the derivatives and functions are continuous. Notes:
file mydll /targetname.dll/; model m /eq1,eq2,mydll/;
where targetname.dll becomes the active name for the DLL. Example: Suppose I use an example from the GAMS web page. Namely suppose I wish to specify the objective function of a quadratic model via an external function. In such a case one would define the objective function as follows (external.gms)
zdefX .. sum(i, ord(i)*x(i) ) + (card(i)+1)* z =X= 1;
and would also define an external DLL which evaluates this function. A Delphi version of this is in extern.zip. |