summaryrefslogtreecommitdiff
path: root/modules/optimization/demos/icse/icsuq.sci
blob: 590420ad29c4a8d5c096f9d0cdd15693e674dc54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
// Copyright (C) 2010 - DIGITEO - Yann COLLETTE
//
// This file is distributed under the same license as the Scilab package.
//

function [co,u,g,itv,dtv,cof]=icsuq(u,simu,nap,imp,obs,ytob)
    // Computation of the optimal control with weighting of the initial control
    // and geometric weighting of the observation weights.
    // A scaling bring all the componant of the control to 1.
    // The componant initially null will stay null.
    // Only works if the lower bound is positive.
    // Weighting formula :
    // cof(i,j) = 1/2*[(ytob(i,j)-ob(1,j,i))**2+..+(ytob(i,j)-ob(nex,j,i)**2]
    //
    // Syntax
    // [co,u,g,itv,dtv,cof]=icsuq(u,nap,imp,obs,ytob)
    // input variables :
    // u(nu)         : initial parameters
    // simu          : string which contains the name of the sub program
    //                 which describes the problem (second member,
    //                 criterion and initial state)
    // nap           : maximum number of call to the simulator
    // imp           : debug value during optimization
    // obs(nob,ny)   : observation matrix
    // ytob(ny,ntob) : initial value of the state at measure time instants
    //                 obtained by icob after using icse,icsu,icsua or icsuq
    // output variables :
    // co            : final cost
    // u(nu)         : final parameters
    // g(nu)         : final gradient
    // itv(nitv)     : work area (fortran integers)
    // dtv(ndtv)     : work area (fortran double precision)
    // cof(nob,ntob) : weighting coefficients of the cost
    // Use the macros icot and icob to extract the state

    df0 = 1;
    if min(binf) <=0 then
        error("call to icsuq with binf not strictly positive");
    end
    for i=1:nu
        u(1,i)=max([ binf(1,i),min([u(1,i),bsup(1,i)])] );
    end
    ech  = u;
    binf = binf./u;
    bsup = bsup./u;
    u    = ones(1,nu);
    ico  = 2;
    yob  = obs*ytob;
    ob   = don;

    [cof] = fort("icscof",ico,1,"i",ntob,2,"i",nex,3,"i",...
    nob,4,"i",yob,5,"d",ob,6,"d","sort",[1,nob*ntob],7,"d");

    [co,u,g,itv,dtv] = icsegen(u,simu,nap,imp);

    u = ech.*u;
endfunction