function p15_plant_tst(tstId)
% 12.5.2014, 6.5.2016 (v2), J. Gaspar

if nargin<1
    tstId= 0; %3; %2; %1;
end

switch tstId

    case 0
        % animation of various investment stop time
        open('p15_plant.mdl')
        global p15_plant_animation
        global p15_plant_tf
        p15_plant_animation= 1;
        p15_plant_tf= 15; %20;
        figure(201); clf;
        set(gcf, 'position', [586    40   434   294]);
        tRange= [1:.5:13.5 13.6:.1:15]; %20;
        tRange= [tRange tRange(end:-1:1) tRange];
        JSav= [];
        for t1= tRange
            JSav(end+1)= p15_plant_cost(t1);
            axis([0    p15_plant_tf   -10    60]);
            drawnow
            if max(abs(get(0,'PointerLocation')))<100, break; end
        end
        figure(202); clf
        plot(tRange(1:length(JSav)), -JSav, '.-')
        xlabel('step time [yr]')
        ylabel('Merit J')

    case 1
        assignin('base', 'p15_plant_t1', 14);
        [t,x,y]= sim('p15_plant', [0 15]);
        plot(t, y, '.-')
        
    case 2
        % find best time to stop investing :
        t1f= fminbnd('p15_plant_cost', 12, 14);
        %t1f= fminsearch('p15_plant_cost', 13);
        figure(201); clf; p15_plant_cost(t1f)

    case 3
        % show an animation of the numerical optimization :
        global p15_plant_animation
        p15_plant_animation= 2;
        figure(201); clf;
        t1f= fminbnd('p15_plant_cost', 10, 14);
        p15_plant_cost(t1f)

    otherwise
        error('inv tstId')
end

return
