------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This program is the Ada implementation of (1+1)-PAES. -- The original code of (1+1)-PAES is implemented in C -- available from: http://www.cs.man.ac.uk/~jknowles/multi/ -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ package Paes is --------------------- -- Constants -- --------------------- MAX_GENES : constant integer := 1000; -- change as necessary MAX_OBJ : constant integer := 10; -- change as necessary MAX_ARC : constant integer := 200; -- change as necessary MAX_LOC : constant integer := 1000000;--32768; -- number of locations in grid (set for a three-objective problem using depth 5) LARGE : constant integer := 2000000000; -- should be about the maximum size of an integer for your compiler --------------------- -- Types -- --------------------- -- This type used to define a chromosome of a solution type chrom_type is array(1..MAX_GENES) of integer; -- This type used to define objectives of a solution type obj_type is array(1..MAX_OBJ) of float; type string_type is new string(1..50); -- This is the main type used to define solutions type solution is record chrom : chrom_type; obj : obj_type; grid_loc : integer; end record; -- This type is used to define the archive of solutions type arc_type is array(1..MAX_ARC) of solution; ---------------------- -- Global variables -- ---------------------- c : solution; -- current solution m : solution; -- mutant solution arc : arc_type; -- archive of solutions ------------------------------------------------------------------------------------------------------ -- depth: this is the number of recursive subdivisions of the objective space carried out in order to -- divide the objective space into a grid for the purposes of diversity maintenance. Values of -- between 3 and 6 are useful, depending on number of objectives. -- objectives: the number of objectives to the problem. -- genes: the number of genes in the chromosome. (Only integer genes can be accepted). -- alleles: the number of values that each gene can take. -- archive: the maximum number of solutions to be held in the nondominated solutions archive. -- iterations: the program terminates after this number of iterations. -- minmax: set to 0 (zero) for minimization problems, 1 for maximization problems. ------------------------------------------------------------------------------------------------------ depth, objectives, genes, archive, iterations, minmax : integer; arclength : integer := 0; -- current length of the archive gl_offset : obj_Type; -- the range, offset etc of the grid gl_range : obj_Type; gl_largest : obj_Type; grid_pop : array(1..MAX_LOC) of integer; -- the array holding the population residing in each grid location change : integer := 0; ----------------------------- -- Non-generic subprograms -- ----------------------------- function compare_min(first : obj_type; second : obj_type; n : integer) return integer; function compare_max(first : obj_type; second : obj_type; n : integer) return integer; function equal(first : obj_type; second : obj_type; n : integer) return integer; procedure print_genome(s : solution); procedure print_eval(s : solution); procedure add_to_archive(s : solution); function compare_to_archive(s : solution) return integer; procedure update_grid(s : in out solution); procedure archive_soln(s : solution); function find_loc(eval : obj_type) return integer; ------------------------- -- Generic subprograms -- ------------------------- -- User should define mutate, evaluate and init procedures -- according to the MOO problem solved with PAES generic with procedure customize_mutate (s : in out solution); procedure mutate (s : in out solution); generic with procedure customize_evaluate(s : in out solution); procedure evaluate(s : in out solution); generic with procedure customize_init; procedure init; end Paes;