An Extended Heuristic Algorithm to Settle Reacting Objects on a Planar Surface 281

Graph theory is a key subject for both mathematics and computer science. It is used for modelling many problems such as maximal independent set, minimum covering and matching. In our study, we have extended the previous work on placing materials that may react with each other on a 2-D warehouse. We have modelled the problem using graph theory. Then, we have developed extensions on the heuristic algorithm which is using Paull-Unger method that finds Maximal Independent Sets. First two of these extensions include finding solutions with gaps for specific graphs, and meanwhile capability of performing replacement in any desired rectangle surface. The last and most effective extension is pruning unnecessary backtracking steps with the help of smarter heuristics in the algorithm. Key WordsGraph Theory, Independent Set Problem, Storage Problem, Heuristic Algorithms.


I TRODUCTIO
Placing the chemically reacting and interfering objects in an appropriate way is an important issue for many sectors.Finding a compact placement solution can be hard for materials that mostly react with others.We have modelled this problem with the graph data model.In this model, materials are mapped to vertices and the reaction interferences are mapped to edges.A graph G = (V(G), E(G)) is composed of nonempty V(G) set of vertices and E(G) set of edges that connects unordered pair of vertices.
In a graph G, if there is an edge between vertices u and v, this shows that these two materials react with each other.In a graph G, if there is always a path between any pair of vertices, then this graph is called Connected Graph [1,2].Let S ⊆ V(G) be a subset of a set of vertices in a graph G.For any pair of vertices, if there is no edge existing between them, then this subset is called Independent Set [1,2].If an independent set is not a subset of any other independent sets, then this set is called Maximal Independent Set [1,3,4].A graph G may have more than one maximal independent sets.The number of elements in the independent set that has the biggest number of vertices, is called Independence umber.It is denoted by β (G) [1, 2].
Definition 1.1.The adjacency matrix of a n-vertices G = (V(G), E(G)) graph is shown as A(G).This matrix is of n x n structure, and the vertices forms the rows and columns of the matrix.
The elements of a A(G) matrix is defined as below [4].
A sample 6 vertice graph and its adjacency matrix representation can be seen on Figure 1.The basic graph definitions and how the problem can be modelled with graph was shown on the introduction section.The Section 2 will be about the full details of the problem and the Paull-Unger algorithm which is related to our work.The details of our new algorithm will be introduced on Section 3, and algorithm analysis and comparations will be on Section 4. The last section will be about conclusion and future works that may improve our algorithm.

PAULL-U GER ALGORITHM
Paull-Unger algorithm finds all maximal independent sets and independence number of a graph.Definition 2.1.[5] By using an alphabet of , we can create words

=
(ε is a word of zero length).∑ * denotes the all words that can be generated from the ∑ alphabet.
* For all these words, a union operator can be defined.Let x be as above and

=
. We put the symbols of the second word after we write the first word.
binary alphabet, is shown on Figure 2. As shown on the figure, we label the edges that seem as directed branches, from left to right.This will be necessary if we need to look for the order which indicates B*.The first node is called root node.This is also the word null in the set of Σ * .
V is a finite subset of B*, and T is in form T = (V,E) and it is an infinite digraph binary tree, (i) , (i) guarantees that there is a path that connects every other node to the root node.(ii) is an edge connection that is mentioned before.The subset that shows the sets that belong to leaves can be defined as below.3 shows a binary tree.The equation (i) can be tested as below.
It is guaranteed from the equation (i) that, for the word x (x∈Σ * ) that each vertex represents, the all words that come before them will already exist on the tree.For example, in Figure 3, 1101 node is made of 110.1 and the node that comes before it is 110 , and it already exists in the tree.This special tree T has the set of vertices as below.,E) can be used in algorithmic operations, for only finite number of vertices in V⊆B *.For this, the most suitable data type for T is data structure.
T: array B * of A A is the algebra that is used for labelling the vertices.B * is an infinite set, so labelling all vertices in the algorithm is impossible.Only the V⊆B * subset will be labelled.Because of the top to bottom ordering of the vertice labelling, we can say that the V subset provides the (i) situation.After the operation finishes, we have a labelled binary tree.
Labelled binary trees are used to find all maximal independent sets and find β independence number for a graph G.These calculations were first made by M.C.Paull and S.H.Unger.The solution can be shown by the algorithm below [5].
T: array B * of P (V) β, i, j, n: positive integer E: This algorithm finds the β independence number for a graph G, and finds all sets of maximal independent sets.There will not be a bigger independent set.
Example.In a military warehouse, it is known that some materials react with each other when they are placed adjacently.In Figure 4, the materials are mapped to vertices, and reactions are mapped to edges.In the graph above, a and b may react with each other, but a and d don't react.This means that a and d can be put together.The problem is to find a compact solution that will place these materials together in a warehouse.Figure 5(a) and Figure 5(b) are some solutions for this problem.However, the solutions in Figure 5 are not feasible.The base and extended algorithms on the next section will find feasible solutions on the platform.

THE BASE ALGORITHM WITH EW EXTE SIO S
In order to solve the problem, we need to put some rules that seperates feasible and infeasible solutions.According to this, for n number of materials and minimum t integer that provides n t > 2 , we can say that a solution which can fit into t t × square matrix is a feasible solution.Thus, we can make an algorithm for generating feasible solutions in a reasonable time.
There is no way to find an algoritm which will find the best solution logically, like many graph theoretic problems.Therefore, brute force [6] methods are more suitable to this type of problems.An heuristic approach to brute force that finds feasible solutions in a short time was introduced in study [7].We have made extensions to this heuristic which improve the performance.

Classical Brute Force Approach
The most basic method to solve this problem will be to try every material to the square matrice randomly or in straight order, and backtrack when there is a conflict.
A basic order of trying to place materials to the corner by preserving the square shape can be as in Figure 6.According to this order, the materials are randomly placed as long as there are no conflicts.If the last material causes a conflict, then the material is changed with another available.If any of available material is suitable, then the previous material is also removed and another material is tried(backtracking).This method allows trying all n! combinations.
Searching the whole n! combinations becomes impossible for bigger n values.Because of this, another method that will help coming across a solution much faster, is needed.

Base Heuristic Approach
According to the previous work [7], the base idea of this approach is to make mistakes as early as possible in trial-error stages.In order to do this, Paull-Unger algorithm is used to find maximal independent sets.Then, the elements in the sets are ordered according to the number of repetitions in these sets from the smallest to biggest.By doing this, we get a list of materials that are ordered from the most problematic to place, to the easiest one.
Then, starting with the most problematic material, the materials are placed to the left top corner in the order that is shown in Figure 7.The aim of this order is to detect a probable conflict as early as possible, and minimize the time spent on backtracking.
As an example, the situation in Figure 7 after placing the 9 th material, can be observed.The following placements will have the risk of conflicting with the placement 5, 6, 7, 8 and 9.If backtracking is inevitable, then this should be done as early as possible, so the sides of the earliest placements should be covered first.In the figure, sides of 5, 6, 7, 8 and 9 are filled in the order.The recursive algorithm for this method is shown below.The Paull Unger order that helps the speedup is taken as input.The Is odeUsed function checks that if the material is used before.extLoc function returns the next location to place, according to our order.SetUsed and SetFree functions marks that materials in the Paull Unger order, according to if they are used or not.Control function checks if the material that will be placed causes a conflict.N Number of materials.T Row number of the square matrix.L The location of the platform that will be filled.PUList The list of materials in the Paull Unger order.

Find(Loc L, int field[T][T], list
It is observed that this algorithm finds solutions in much less steps with the help of Paull Unger material ordering and the specific placement order.

Extensions to Heuristic Approach
Three extensions are added into the base algorithm in this paper.These extensions are as below.

Extension 1-Adding Blanks
Heuristic approach finds solutions that fit into a minimum suitable square matrix.Total node number is generally smaller than the available places in the matrix, so there will usually be empty places.The heuristic always attempts to find fully filled solutions, and leaves empty spaces in only the lower right end of the matrix.This approach will not find solutions with blanks inside, as can be seen on the next figure.
This extension helps the algorithm to start finding the solutions first without any blanks, if there is any.But some graphs can have no such a solution; therefore it tries to find solutions with one blank in them, two blanks and so on.According to this extension, algorithm can do placement in any rectangular area, while the base heuristic algorithm finds solutions for only square surface.This is achieved by limiting the dimensions and omitting unwanted solutions (placements).This extension provides flexibility for the heuristic.The method for the extension is shown below.The last and the most effective extension is about building a smarter heuristic which prunes unnecessary steps in backtracking.
While placing materials in the described heuristic, backtracking is made when there is no suitable material for placing to the current location.Some parts of those backtracking movements are redundant and those movements lead to unnecessary trials which will not affect the conflict on the current location.The idea is to backtrack directly to the source of the conflict, which is the neighbour location that causes conflict on the current place.Using these shortcuts to the conflict sources prunes the mostly redundant branches on the tree of possibilities.The pseudo code with the extension is as below.Figure 9.The number of steps for finding solutions with different orderings

Find(Loc L, int field[T][T], list
Figure 10 shows the comparation of orderings in means of time in graphics.As seen on figure, the base algorithm has a linear graphic, while the other orderings tend to exponentially increase.We have observed that the time of a random ordering lies between the two orderings.
Our backtracking extension prunes unnecessary steps in backtracking in the case of a conflict.The effects of this extended algorithm can be seen on the rightmost column of Figure 9, and graphically on Figure 11.This improvement yields to an average of 8% decrease on the time needed to find a solution.

CO CLUSIO S A D FUTURE WORKS
According to previous work on this subject [7], a practical algorithm which approaches the settling problem with graph modelling and solves in much shorter time, has been made.The key ideas behind the speedup were that the materials are placed in an order generated by Paull Unger ordering, and locations are filled in a special order.The effect of Paull Unger ordering can be seen on Figure 10.
Three extensions have been made on this paper.There may be no gapless solution exist for some special graphs.Using the base algorithm will not return results for those graphs.For this case, the first extension is made to try several blanks in locations when there is no gapless result.The second extension has been made to add ability of situating materials in any type of arbitrary rectangles.Finally, the third and the biggest extension has been made to reduce backtracking steps by pruning unnecessary recursions during backtracks.This leads to using 8% less time to find a feasible solution, which is a notable performance improvement considering the problem is an NP-Complete replacement problem.
As a future work, we plan to design an algorithm for non-planar 3D environments, with dynamic programming methods.

Figure 1 .
Figure 1.A Sample Graph and its adjacency matrix ∑ * = (∑ * ,⋅,ε) is a monoid.∑ * can be denoted as a free monoid that is extracted from ∑ alphabet.With the vertice set of infinite digraph G=(Σ * , E) that is combined with x ∈ y ⇔ y = xσ (σ∈Σ) equation, lets denote the set of all words that can be generated from the vertice alphabet of graph G, as Σ *[5].

Figure 6 .
Figure 6.A probable brute force order for placing materials to corner.

Figure 7 .
Figure 7. New order for placing materials to corner

Figure 10 .
Figure 10.The time comparation of the new algorithm ordering and other orderings