Initializing help system before first use

User functions

If an analytic description of the model is not available, it is possible to use black box functions implemented either directly in Mosel or by any external application.

The area calculation of the example could be implemented in Mosel as

public function MoselArea(I: array(Indices: range, Types: set of string) of real): real
  returned := (sum (i in 2..N-1) (I(i,"rho")*I(i-1,"rho")*sin(I(i,"theta")-I(i-1,"theta")))) * 0.5
 end-function

The user function is linked to the model using a user function object

declarations
  AreaFunction : userfunc
 end-declarations
 AreaFunction := userfuncMosel("MoselArea")

The arguments, which can be any expression are passed down using an array of expressions

declarations
  FunctionArg: array(RN,{"rho","theta"}) of nlctr
 end-declarations
 forall (i in 1..N) do
  FunctionArg(i, "rho")   := rho(i)
  FunctionArg(i, "theta") := theta(i)
 end-do

Once the user function is declared and the arguments built, the user function is added to the model using F:

Area := F(AreaFunction,FunctionArg)

The function arguments are copied at the point when the F function is used, any later changes to the arrays holding the arguments are ignored.


© 2001-2022 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.