agpl_1.0.0_b5da3320/obsolete/t009_tsp.adb

 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
with Text_Io; use Text_Io;
with Ada.Exceptions; use Ada.Exceptions;

with Agpl.Optimization.Concorde;
use  Agpl.Optimization.Concorde;

procedure T009_tsp is
   C : constant Cost_Matrix :=
         (1 => (0, 1, 2, 1),
          2 => (1, 0, 1, 2),
          3 => (2, 1, 0, 1),
          4 => (1, 2, 1, 0));
begin
   declare
      Sol : constant Result_Matrix :=
              Solve_TSP ((1 .. 1 => 3),
                         C);
   begin
      for Salesman in Sol'Range (1) loop
         Put_Line ("Salesman" & Salesman'Img);
         for City in Sol'Range (2) loop
            Put (Sol (Salesman, City)'Img);
         end loop;
         New_Line;

         Put_Line ("Total cost:   " & Get_Total_Cost (C, Sol)'Img);
         Put_Line ("Min-max cost: " & Get_Min_Max_Cost (C, Sol)'Img);
      end loop;
   end;
exception
   when E : others =>
      Put_Line ("Exception: " & Exception_Information (E));
end T009_tsp;