Sei sulla pagina 1di 9

Tabu search, created by Fred W. Glover in 1986 and formalized in 1989.

Tabu Search is a
Global Optimization algorithm and a Metaheuristic or Meta-strategy for controlling an
embedded heuristic technique. Tabu Search is a parent for a large family of derivative
approaches that introduce memory structures in Metaheuristics, such as Reactive Tabu Search
and Parallel Tabu Search.
Strategy:The objective for the Tabu Search algorithm is to constrain an embedded heuristic from
returning to recently visited areas of the search space, referred to as cycling. The strategy of
the approach is to maintain a short term memory of the specific changes of recent moves
within the search space and preventing future moves from undoing those changes. Additional
intermediate-term memory structures may be introduced to bias moves toward promising
areas of the search space, as well as longer-term memory structures that promote a general
diversity in the search across the search space.
It can be divided in three type of strategy:Forbidding strategy: control what enters the tabu list.
Freeing strategy: control what exits the tabu list and when.
Short-term strategy: manage interplay between the forbidding strategy and freeing strategy to
select trial solutions.
Pseudocode:Algorithm (below) provides a pseudocode listing of the Tabu Search algorithm for
minimizing a cost function. The listing shows the simple Tabu Searc h algorithm with short
term memory, without intermediate and long term memory management.

Algorithm:

Step 1: Choose an initial solution i in S. Set i* = i and k=0.

Step 2: Set k=k+1 and generate a subset V* of solution in N(i,k ) such that either one
of the Tabu conditions is violated or at least one of the aspiration conditions holds.

Step 3: Choose a best j in V* and set i=j.

Step 4: If f(i) < f(i*) then set i* = i.

Step 5: Update Tabu and aspiration conditions.

Step 6: If a stopping condition is met then stop. Else go to Step 2.

Flow chart:-

Example(Minimum spanning tree problem with constraints):Objective: Connects all nodes with minimum costs

Constraints 1: Link AD can be included only if link DE also is included. (penalty:100)


Constraints 2: At most one of the three links AD, CD, and AB can be included.
(Penalty of 100 if selected two of the three, 200 if all three are selected.)

Iteration 4:-

Advantages: Allows non- improving solution to be accepted in order to escape from a local optimum
The use of Tabu list can be applied to both discrete and continuous solution spaces
For larger and more difficult problems (scheduling, quadratic assignment and vehicle
routing), tabu search obtains solutions that rival and often surpass the best solutions
previously found by other approaches.
Disadvantages:
Too many parameters to be determined
Number of iterations could be very large
Global optimum may not be found, depends on parameter settings

VHDL Code:Tabusearch.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use ieee.numeric_std.all;
use work.pkg.all;
entity tabusearch is
port(clk : in std_logic;
output_f_1 : out std_logic_vector(3 downto 0);
output_f_2 : out std_logic_vector(3 downto 0);
output_f_3 : out std_logic_vector(3 downto 0);
output_f_4 : out std_logic_vector(3 downto 0));
end tabusearch;
architecture Behavioral of tabusearch is
--link cost
--signal ab_1:integer := 20;
--signal ac_2:integer := 10;
--signal ad_3:integer := 15;
--signal be_4:integer := 30;
--signal ce_5:integer := 5;
--signal cd_6:integer := 25;
--signal de_7:integer := 40;
shared variable output_n,output_o :int_array_out;
shared variable output : int_array_out := (1,2,3,5);
shared variable cost_penlt,rem_s : int_array_cost;
shared variable remaining : int_array_remains;
shared variable cost_temp : integer:=0;
shared variable cost_o : integer:=250;
shared variable penalty_1,penalty_2 : integer := 0;
--link penalty
--Constraints 1: Link AD can be included only if link DE also is included. (penalty:100)
--Constraints 2: At most one of the three links AD, CD, and AB can be included.
--(Penalty of 100 if selected two of the three, 200 if all three are selected.)
begin
process(clk)
variable k: integer;
variable remx : int_array_remx;
begin
cost_penlt := (20,10,15,30,5,25,40);
remaining := (4,6,7);

if clk'event and clk='1' then


output_o := (1,2,3,5);
for z in 1 to 3 loop
k:=1;
for i in 1 to 7 loop
if ((output_o(1)/=i) and (output_o(2)/=i) and (output_o(3)/=i) and (output_o(4)/=i)) then
rem_s(k) := i;
k:=k+1;
else
null;
end if;
end loop;
remaining:=(rem_s(1),rem_s(2),rem_s(3));
for i in 1 to 4 loop
if i=1 then
remx := (2,3,4);
elsif i=2 then
remx := (1,3,4);
elsif i=3 then
remx := (1,2,4);
elsif i=4 then
remx := (1,2,3);
else
null;
end if;
for j in 1 to 3 loop
if z=1 then
output := (remaining(j),output_o(remx(1)),output_o(remx(2)),output_o(remx(3)));
elsif z=2 then
if j=1 then
output := (remaining(1),remaining(2),output_o(remx(2)),output_o(remx(3)));
elsif j=2 then
output := (remaining(1),remaining(3),output_o(remx(2)),output_o(remx(3)));
elsif j=3 then
output := (remaining(3),remaining(2),output_o(remx(2)),output_o(remx(3)));
else
null;
end if;
elsif z=3 then
output := (remaining(1),remaining(2),remaining(3),output_o(remx(3)));
else
null;
end if;
penalty_1:=0;

penalty_2:=0;
if (((3=output(1)) or (3=output(2)) or (3=output(3)) or (3=output(4))) and ((7 /=output(1)) or
(7 /=output(2)) or (7/=output(3)) or (7/=output(4)))) then
penalty_1 := 100;
else
null;
end if;
if (((3=output(1)) or (3=output(2)) or (3=output(3)) or (3=output(4))) and ((6=output(1)) or
(6=output(2)) or (6=output(3)) or (6=output(4)))) then
penalty_2 := 100;
elsif (((3=output(1)) or (3=output(2)) or (3=output(3)) or (3=output(4))) and ((1=output(1)) or
(1=output(2)) or (1=output(3)) or (1=output(4)))) then
penalty_2 := 100;
elsif (((6=output(1)) or (6=output(2)) or (6=output(3)) or (6=output(4))) and ((1=output(1)) or
(1=output(2)) or (1=output(3)) or (1=output(4)))) then
penalty_2 := 100;
elsif (((6=output(1)) or (6=output(2)) or (6=output(3)) or (6=output(4))) and ((1=output(1)) or
(1=output(2)) or (1=output(3)) or (1=output(4))) and ((3=output(1)) or (3=output(2)) or
(3=output(3)) or (3=output(4)))) then
penalty_2 := 200;
else
null;
end if;
if ((output(1)=1 or output(2)=1 or output(3)=1 or output(4)=1) and (output(1)=2 or
output(2)=2 or output(3)=2 or output(4)=2) and (output(1)=3 or output(2)=3 or output(3)=3
or output(4)=3) and (output(1)=6 or output(2)=6 or output(3)=6 or output(4)=6)) then
penalty_1:=1000;
elsif ((output(1)=4 or output(2)=4 or output(3)=4 or output(4)=4) and (output(1)=5 or
output(2)=5 or output(3)=5 or output(4)=5) and (output(1)=6 or output(2)=6 or output(3)=6
or output(4)=6) and (output(1)=7 or output(2)=7 or output(3)=7 or output(4)=7)) then
penalty_1:=1000;
elsif ((output(1)=1 or output(2)=1 or output(3)=1 or output(4)=1) and (output(1)=2 or
output(2)=2 or output(3)=2 or output(4)=2) and (output(1)=4 or output(2)=4 or output(3)=4
or output(4)=4) and (output(1)=5 or output(2)=5 or output(3)=5 or output(4)=5)) then
penalty_1:=1000;
elsif ((output(1)=5 or output(2)=5 or output(3)=5 or output(4)=5) and (output(1)=2 or
output(2)=2 or output(3)=2 or output(4)=2) and (output(1)=3 or output(2)=3 or output(3)=3
or output(4)=3) and (output(1)=7 or output(2)=7 or output(3)=7 or output(4)=7)) then
penalty_1:=1000;
elsif ((output(1)=5 or output(2)=5 or output(3)=5 or output(4)=5) and (output(1)=2 or
output(2)=2 or output(3)=2 or output(4)=2) and (output(1)=6 or output(2)=6 or output(3)=6
or output(4)=6) and (output(1)=7 or output(2)=7 or output(3)=7 or output(4)=7)) then
penalty_1:=1000;

elsif ((output(1)=5 or output(2)=5 or output(3)=5 or output(4)=5) and (output(1)=2 or


output(2)=2 or output(3)=2 or output(4)=2) and (output(1)=3 or output(2)=3 or output(3)=3
or output(4)=3) and (output(1)=6 or output(2)=6 or output(3)=6 or output(4)=6)) then
penalty_1:=1000;
elsif ((output(1)=5 or output(2)=5 or output(3)=5 or output(4)=5) and (output(1)=7 or
output(2)=7 or output(3)=7 or output(4)=7) and (output(1)=3 or output(2)=3 or output(3)=3
or output(4)=3) and (output(1)=6 or output(2)=6 or output(3)=6 or output(4)=6)) then
penalty_1:=1000;
elsif ((output(1)=2 or output(2)=2 or output(3)=2 or output(4)=2) and (output(1)=7 or
output(2)=7 or output(3)=7 or output(4)=7) and (output(1)=3 or output(2)=3 or output(3)=3
or output(4)=3) and (output(1)=6 or output(2)=6 or output(3)=6 or output(4)=6)) then
penalty_1:=1000;
end if;
cost_temp := cost_penlt(output(1))+ cost_penlt(output(2))+ cost_penlt(output(3))+
cost_penlt(output(4)) + penalty_1+penalty_2;
if cost_temp < cost_o then
cost_o := cost_temp;
output_n := output;
end if;
end loop;
end loop;
output_o := output_n;
end loop;
output_f_1 <= std_logic_vector(to_unsigned(output_n(1),4));
output_f_2 <= std_logic_vector(to_unsigned(output_n(2),4));
output_f_3 <= std_logic_vector(to_unsigned(output_n(3),4));
output_f_4 <= std_logic_vector(to_unsigned(output_n(4),4));
end if;
end process;
end Behavioral;
pkg.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.all;
package pkg is
type int_array_out is array(1 to 4) of integer range 1 to 15;
type int_array_cost is array(1 to 7) of integer range 1 to 2047;
type int_array_remains is array(1 to 3) of integer range 1 to 15;
type int_array_remx is array(1 to 3) of integer range 1 to 15;
end pkg;

output:-

Potrebbero piacerti anche