with Ada.text_IO; use Ada.text_IO; with Pipe_Commands; use Pipe_Commands; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with unbounded_strings; use unbounded_strings; with Ada.Strings; use Ada.Strings; with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; with Ada.Directories; use Ada.Directories; with task_clustering_rules; use task_clustering_rules; package body Hypervolume_computation is procedure Normalize_Archive (arc : in arc_type) is --Znad1, Znad2 : float; obj1_norm, obj2_norm : float; F : Ada.Text_IO.File_Type; Data,line : unbounded_string; begin --if arclength > 1 then --Znad1 := arc(1).obj(1); --Znad2 := arc(1).obj(2); Z1_ideal := arc(1).obj(1); Z2_ideal := arc(1).obj(2); for i in 2 .. arclength loop --if arc(i).obj(1) > Znad1 then -- Znad1 := arc(i).obj(1); --end if; if arc(i).obj(1) < Z1_ideal then Z1_ideal := arc(i).obj(1); end if; --if arc(i).obj(2) > Znad2 then -- Znad2 := arc(i).obj(2); --end if; if arc(i).obj(2) < Z2_ideal then Z2_ideal := arc(i).obj(2); end if; end loop; for i in 1 .. arclength loop obj1_norm := (arc(i).obj(1) - Z1_ideal) / (Z1_anti_ideal - Z1_ideal); obj2_norm := (arc(i).obj(2) - Z2_ideal) / (Z2_anti_ideal - Z2_ideal); Append (Data, obj1_norm'img & " " & obj2_norm'img & ASCII.LF); end loop; --else -- f1_norm := arc(1).obj(1); -- f2_norm := arc(1).obj(2); -- Append (Data, f1_norm'img & " " & f2_norm'img & ASCII.LF); --end if; Create(F,Ada.Text_IO.Out_File,"Normalized_Archive_"); Unbounded_IO.Put_Line(F, Data); Close(F); end Normalize_Archive; function Call_hv return float is FileStream : stream; --command : constant string := "./../../../../../hv Normalized_Archive_ -s Hypervolume.txt"; command : constant string := "./../../../../../../required_packages/hypervolume/hv " & "-r ""1.0 1.0""" & " Normalized_Archive_ -s Hypervolume.txt"; F1 : Ada.Text_IO.File_Type; line : unbounded_String; Buffer : unbounded_String; begin FileStream := execute(command, read_file); loop begin Buffer := read_next(FileStream); exception when Pipe_Commands.End_of_file => exit; end; end loop; close(FileStream); Open(F1, Ada.Text_IO.In_File,"Normalized_Archive_Hypervolume.txt"); line := To_Unbounded_String(get_line(F1)); Put_Line ("The hypervolume =" & To_string(line)); return float'Value(To_string(line)); end Call_hv; end Hypervolume_computation;