function test06 ( )

%*****************************************************************************80
%
%% test06() computes optimal control for case #6.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 October 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'test06():\n' );
  fprintf ( 1, '  Optimal control for case #6.\n' );
  fprintf ( 1, '  Fish Harvesting:\n' );

  A = 5.0;
  k = 10;
  m = 0.2;
  x0 = 0.4;
  M = 1.0;
  T = 10.0;
  N = 1000;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Parameters:\n' );
  fprintf ( 1, '  A  = %g\n', A );
  fprintf ( 1, '  k  = %g\n', k );
  fprintf ( 1, '  m  = %g\n', m );
  fprintf ( 1, '  x0 = %g\n', x0 );
  fprintf ( 1, '  M  = %g\n', M );
  fprintf ( 1, '  T  = %g\n', T );
  fprintf ( 1, '  N  = %d\n', N );

  [ t, x, u, lambda, cost ] = opt06 ( A, k, m, x0, M, T, N );

  clf ( );
  plot ( t, x, 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- X(t) -->' );
  title ( 'State variable X(t)' );
  filename = 'test06_x.png';
  print ( '-dpng', filename );
  fprintf ( 1, '    Graphics saved as "%s"\n', filename );

  clf ( );
  plot ( t, u, 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- U(t) -->' );
  title ( 'Control U(t)' );
  filename = 'test06_u.png';
  print ( '-dpng', filename );
  fprintf ( 1, '    Graphics saved as "%s"\n', filename );

  clf ( );
  plot ( t, lambda, 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- t -->' );
  ylabel ( '<-- \lambda(t) -->' );
  title ( 'Adjoint \lambda(t)' );
  filename = 'test06_lambda.png';
  print ( '-dpng', filename );
  fprintf ( 1, '    Graphics saved as "%s"\n', filename );

  clf ( );
  plot ( cost, 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- iteration -->' );
  ylabel ( '<-- cost -->' );
  title ( 'Cost function' );
  filename = 'test06_cost.png';
  print ( '-dpng', filename );
  fprintf ( 1, '    Graphics saved as "%s"\n', filename );

  return
end

