Did you know ... Search Documentation:
Pack lbfgs -- prolog/lbfgs.pl
PublicShow source
 optimizer_initialize(+N, +Module, +Evaluate, +Progress, +ExtraArg, -Environment) is det
Create space to optimize a function with N variables (N has to be integer). Module is the name of the module where the call back predicates can be found, Evaluate is the call back predicate (arity 5) to evaluate the function math F, Progress is the call back predicate invoked (arity 10) after every iteration. ExtraArg can be used to pass a term that will be further passed to Evaluate and Progress in case these functions need extra information. Environment is returned by the predicate and is a pointer to a data structure storing the information regarding the current optimization session. It must be used in further calls to the library predicates to operate on the session.

Example optimizer_initialize(1,user,evaluate,progress,[],Env)

The evaluate call back predicate has to be of the type evaluate(+Environment,-F,+N,+Step,+ExtraArg). It has to calculate the current function value F. N is the size of the parameter vector (the value which was used to initialize LBFGS) and Step is the current state of the line search. The call back predicate can access the current values of x[i] by calling optimizer_get_x(+Environment,+I,-Xi). Finally, the call back predicate has to calculate the gradient of F and set its value by calling optimizer_set_g(+Environment,+I,+Gi) for every 1<=I<=N. Environment needs to be passed to further calls to the library predicates. ExtraArg can be used to pass data to evaluate/5.

The progress call back predicate has to be of the type progress(+Environment,+F,+X_Norm,+G_Norm,+Step,+N,+Iteration,+LS,+Continue,+ExtraArg). It is called after every iteration. The call back predicate can access the current values of X and of the gradient by calling optimizer_get_x(+Environment,+I,-Xi) and optimizer_get_g(+Environment+I,-Gi) respectively. Howver, it must not call the setter predicates for X or G. If it tries to do so, the optimizer will terminate with an error. If Continue is set to 0 (int) the optimization process will continue for one more iteration, any other value will terminate the optimization process.

 optimizer_initialize(+N, +Evaluate, +Progress, -Environment) is det
Same as optimizer_initialize(+N,user,+Evaluate,+Progress,[],-Environment)
 optimizer_finalize(+Environment) is det
Clean up the memory. Environment must take a value returned by a call to optimizer_initialize/4-6.
 optimizer_parameters(+Environment) is det
Prints a table with the current parameters.
 interpret_return_value(+Status, -String) is det
Given a status code returned by optimizer_run/3, it returns a descriptive string

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 optimizer_run(Arg1, Arg2, Arg3)
 optimizer_get_x(Arg1, Arg2, Arg3)
 optimizer_set_x(Arg1, Arg2, Arg3)
 optimizer_get_g(Arg1, Arg2, Arg3)
 optimizer_set_g(Arg1, Arg2, Arg3)
 optimizer_set_parameter(Arg1, Arg2, Arg3)
 optimizer_get_parameter(Arg1, Arg2, Arg3)