# lolimotDemo1 Demo 1: Static process with 1 input and 1 output

    LoLiMoT - Nonlinear System Identification Toolbox
    Torsten Fischer, 20-October-2011
    Institute of Mechanics & Automatic Control, University of Siegen, Germany
    Copyright (c) 2012 by Prof. Dr.-Ing. Oliver Nelles

    % Training
    LMN = lolimot;                   % Generate an empty net and data set structure

    % Create training data
    u = linspace(0,1,15)';
    y = 1 ./ (0.1 + u);

    % Assign training data
    LMN.input = u;
    LMN.output = y;

    LMN.xRegressorDegree = 1;       % use 1st order polynoms for local models (default: 1)
    LMN.maxNumberOfLM = 15;         % Termination criterion for maximal number of LLMs
    LMN.minError = 0.05;            % Termination criterion for minimal error
    LMN.kStepPrediction = 0;        % Static model
    LMN.smoothness = 1;             % Less overlap between the validity functions
    LMN.history.displayMode = true; % display information

    % Train net
    LMN = LMN.train;

    % Generalization
    uG = linspace(-0.05,1.2,270)';
    yG = 1 ./ (0.1 + uG);

    % Simulate net
    yGModel = calculateModelOutput(LMN, uG, yG);
    JG = calcGlobalLossFunction(LMN ,yG, yGModel);

    figure
    LMN.plotModel

    figure
    LMN.plotPartition

    xInputDelay is empty, defaults are used: xInputDelay(1:p) = {0}
    zInputDelay is empty, defaults are used: zInputDelay(1:p) = {0}
    xOutputDelay is empty, defaults are used: xOutputDelay(1:p) = {[]}
    zOutputDelay is empty, defaults are used: zOutputDelay(1:p) = {[]}

    Initial net has 1 local linear model(s): J = 0.602127.

    1. Iteration. Number of local linear models = 1. Checking for split of model 1 ...
       Testing split in dimension 1 with ratio 0.50: J = 0.390072.
    -> Splitting in dimension 1 with ratio 0.50: J = 0.390072 and penalty = 0.580313.

    2. Iteration. Number of local linear models = 2. Checking for split of model 2 ...
       Testing split in dimension 1 with ratio 0.50: J = 0.198680.
    -> Splitting in dimension 1 with ratio 0.50: J = 0.198680 and penalty = 0.348564.

    3. Iteration. Number of local linear models = 3. Checking for split of model 5 ...
       Split in dimension 1 with ratio 0.50 is forbidden!

    3. Iteration. Model 5 can not be splitted. Try another model...

    3. Iteration. Number of local linear models = 3. Checking for split of model 3 ...
       Testing split in dimension 1 with ratio 0.50: J = 0.198358.
    -> Splitting in dimension 1 with ratio 0.50: J = 0.198358 and penalty = 0.434220.

    4. Iteration. Number of local linear models = 4. Checking for split of model 7 ...
       Split in dimension 1 with ratio 0.50 is forbidden!

    4. Iteration. Model 7 can not be splitted. Try another model...

    All leaf models are locked. No further splitting possible. Training accomplished.

    Final net has 4 local models and 8 parameters: J = 0.198358

    Net 3 with 3 LMs and 6 parameters is suggested as the model with the best complexity trade-off.
    Plot model for dimension 1.

    ans =

      1×7 cell array

        []    []    [1×1 Line]    [1×1 Line]    [1×1 Line]    []    []