fsqp interface for SR problems. This interface uses the notations of the cfsqp user's guide (see c_manual.ps). The four functions (objective, constraints, gradient-of-objective, gradient-of-constraints) can be given either as C-functions dynamically linked with Scilab or as Scilab functions (mixtures are allowed). If a Scilab function is given as argument of fsqp, just use its name (without quotes). If a C function is to be called, use a character string to define it. For instance fsqp(...,obj,...) invokes fsqp with the Scilab function obj and fsqp(...,"obj",...) invokes fsqp with the C function obj, linked with Scilab by e.g. link("obj.o", "obj") .
The chains "grobfd" and "grcnfd" can be used as C functions to compute the gradients of the functions grob and cntr by finite difference. Notations:
ipar=[nf,nineqn,nineq,neqn,neq,modefsqp,miter,iprint]; srpar=[nfsr,ncsrl,ncsrn]; rpar=[bigbnd,eps,epsneq,udelta];
function fj=obj(j,x) function gj=cntr(j,x) function gradf=grob(j,x) function gradgj=grcn(j,x)
obj(j,x) returns the value of the jth objective, given x. cntr(j,x) returns the value of the jth constraint, given x. grob(j,x) (resp. grcn(j,x)) is the value at x of the gradient of the function x->obj(j,x) (resp. x->cntr(j,x)).
It may be useful to make use of the fsqp C variable x_is_new and to evaluate these functions in a vector way. For instance the function cntr can be replaced by the following cntr2 function:
function cj=cntr2(j,x) if x_is_new() then all_objectives=allobj(x); all_constraints=allcntr(x); all_gradobjectives=allgrob(x); all_gradconstraints=allgrcn(x); cj=all_constraints(j); set_x_is_new(0); //Use resume to define global Scilab variables [all_objectives,all_constraints,all_gradobjectives,all_gradconstraints]=.... resume(all_objectives,all_constraints,all_gradobjectives,all_gradconstraints); else cj=all_constraints(j); end
Here, the function allcntr(x) returns a vector all_constraints whose jth component all_constraints(j) is cntr(j). A typical example comes from discretized semi-infinite program. See example5.sci.
//See the script file example2.sce |