function transportation_test ( )

%*****************************************************************************80
%
%% transportation_test() tests transportation().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 April 2026
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../transportation' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'v_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test transportation().\n' );

  clc;
  clear;

  m = 3;
  n = 4;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  There are %d sources and %d destinations.\n', m, n );
%
%  Define the cost matrix (m sources x n destinations)
%
  C = [ ...
    2, 3, 1, 4; ...
    3, 2, 5, 1; ...
    4, 3, 2, 2 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The cost matrix:\n' );
  disp ( C );
%
%  The supply vector.
%
  supply = [ 20, 30, 25 ];
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The supply vector:\n' );
  disp ( supply );
%
%  Demand vector.
%
  demand = [ 10, 25, 30, 10 ];
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The supply vector:\n' );
  disp ( demand );
%
%  Seek a transportation plan.
%
  X = transportation ( supply, demand, C );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Transportation matrix:\n' );
  disp ( X );
%
%  Compute transportation cost.
%
  cost = sum ( sum ( X .* C ) );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Transportation Cost %g\n', cost );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'transportation_test()\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../transportation' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

