Scilab Function

fsqp - FSQP solver

Calling Sequence

x=fsqp(x0,ipar,rpar,[bl,bu],obj,cntr,grob,grcn)
x=fsqp(x0,ipar,rpar,[bl,bu],obj,cntr,"grob","grcn")
x=fsqp(x0,ipar,rpar,[bl,bu],"obj","cntr","grob","grcn", [cd])
x=fsqp(x0,ipar,rpar,[bl,bu],"obj","cntr","grobfd","grcnfd", [cd])
[x,inform]=fsqp(...)
[x,inform,f,g,lambda]=fsqp(...)

Parameters

Description

fsqp interface. This interface uses the notations of the cfsqp user's guide. See doc/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 obj and cntr by finite difference. Notations:

ipar=[nf,nineqn,nineq,neqn,neq,modefsqp,miter,iprint];
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.

Examples

//This is example 1 of the doc.
deff("fj=obj32(j,x)","fj=(x(1)+3*x(1)+x(2))^2+4*(x(1)-x(2))^2")

deff("gj=cntr32(j,x)",[
"select j";
"case 1"
  "gj=x(1)^3-6*x(2)-4*x(3)+3;"
"case 2"  
  "gj=1-sum(x);"
"end"]);

deff("gradf=grob32(j,x)",...
"fa=2*(x(1)+3*x(2)+x(3));fb=8*(x(1)-x(2));gradf=[fa+fb;3*fa-fb;fa]");

deff("gradgj=grcn32(j,x)",[
"select j";
"case 1"
"gradgj=[3*x(1)^2;-6;-4];"
"case 2"
"gradgj=[-1;-1;-1];"
"end"]);
x0=[0.1;0.7;0.2];

nf=1; nineqn=1; nineq=1; neqn=0; neq=1; modefsqp=100; miter=500; iprint=1;
ipar=[nf,nineqn,nineq,neqn,neq,modefsqp,miter,iprint];

bigbnd=1.e10; eps=1.e-8; epsneq=0.e0; udelta=0.e0;
rpar=[bigbnd,eps,epsneq,udelta];

bl=[0;0;0];
bu=[bigbnd;bigbnd;bigbnd];

x=fsqp(x0,ipar,rpar,[bl,bu],obj32,cntr32,grob32,grcn32)
 

See Also