Research »

Main

Research Reports

29 April 2008

Mapping of Gestalts

Once gestalts of a particular situation are found, the problem of mapping these into each other emerges.

Suppose situations A, B and C are as follows:

Situation A
   P1
   P1
   P1P1P1
Situation B
   C1
   C1
   C1
   C1C1C1C1
Situation C
   D1
   D1
   D1D1D1

The problem is to find a situation D that satisfies A:B::C:D in an analogy problem. In other words, if there is an analogy relation between A and B, the same relation must hold between C and D too.

Gestalt finding algorithm finds the following gestalts in these situations

A
      P1

A1 = P1

      P1

and

A2 = P1P1P1

B
      C1

B1 = C1

      C1
      C1

and

B2 = C1C1C1C1

C
      D1

C1 = D1

      D1

and

C2 = D1D1D1

Now, a mapping between these gestalts is necessary in order to find D. This mapping should match elements of A with elements of B and C and find a plausible answer for D. For such a matching, there might be several strategies:

  • Maximizing total similarity searches a matching between most similar elements in all situations. This kind of matching uses previously discussed similarity metrics to calculate a similarity value between gestalts of situations.
  • Select forward max matches each gestalt in A with its most similar counterpart in B and C. This strategy does not check whether the selected matching maximizes the total similarity and this mapping may not result in 1-1 mapping.
  • Select backward max matches each gestalt in B and C with its most similar counterpart in A. Backward and forward mapping may result in different mappings due to their "source".

We can add 1-1 criteria for these strategies as this is orthogonal to selection. However, there may not be equal number of gestalts in each situation so a 1-1 mapping may not be possible. This will be discussed in detail later.

Along with matching strategies, similarity metric may also be variable. Following are possible:

  • Matching importance "finds" most important elements of A to most important elements of B as most "similar." Similarity is only done according to the rank in importance.
  • Matching object pattern tries to map only the gestalt pattern superficially and does not check whether length, breadth or location has any role in similarity calculation.
  • Matching size tries to rank gestalts according to their sizes and matches largest gestalts in A with gestalts elements in B. This is more or less same with importance matching, because size has a role in it.
  • Matching location tries to map gestalts according to their relative location in a situation. This requires to find relative locations (above, below, right to, left to) of each gestalt with each other.
  • Matching relations tries to find all possible relations between gestalts and (in some cases) standalone objects and calculates similarity by a criteria of "standing in a similar relation". This may result in a fruitful analysis of "relation skeleton" of a situation or a rather misleading noise.
  • Matching all considers all above conditions to find a mapping between elements. It either employs each similarity strategy once to check whether a "really good" mapping exists, or combines all these by weight and tries to find a hybrid solution.

Suppose gestalts of situations A and B have similarities (calculated by "matching all" strategy) like this:

 A1A2A3A4
B13527121
B2123851
B367183
B415276

A total maximization strategy will select the bold items below.

 A1A2A3A4
B13527121
B2123851
B367183
B415276

However, as this instance illustrates, this matching strategy has duplicate matching for A3 and no matching for A4.

If a 1-1 constraint is imposed for "maximize total" strategy, following results are taken.

 A1A2A3A4
B13527121
B2123851
B367183
B415276

However, in this case A4 and B3 are matched against their similarity is very low.

Also, 1-1 constraint leads to problems if the number of gestalts in each side is not equal. Suppose instead of the above, situation B has only 3 gestalts.

 A1A2A3A4
B13527121
B2123851
B367183

In this case, A4's matching should be arbitrary.

21 March 2008

Gestalt Tiling Algorithm

Gestalt tiling is a process to define a gestalt with a minimal Object pattern, which means the Gestalt uses Ex and Ey constructs rather than writing whole gestals as a single element.

Example:

A gestalt of the form

   P1P1P1 

can be represented in two ways:

   Obj "P1P1P1" Mx 0 My 0

and

   Obj "P1" Mx 0 My 0 Ex 2

For better comparisons and pattern finding, we need the second form. Moreover, the number of candidates raise as the complexity in situation increases.

In order to achieve this succint form for a given string, I model a "tiling algorithm" which tries to write a gestalt form as succintly as possible. Note that, since a gestalt may span more than one line, tiles may also be multilined.

Example:

   P1P1P1
   P2P2P2

should be represented like

  Obj "P1\nP2" Mx 0 My 0 Ex 2

I begin with a single line version and use this to solve the multiline version.

tiledLine function takes a string in the form

  P1P1P1

and returns a list of patterns which fill this string. It can be used on any string.

The resulting list, at least contains the input string, since any string can be composed by itself.

> tiledLine :: Eq a => [a] -> [[Research/a]]
> tiledLine inStr = let                   --inStr = "P1P1P1"
>                   len = length inStr    --len = 6
>                   strGroups = flip makeGroup inStr --strGroups 2 = ["P1", "P1", "P1"]
>                   allGroups = [strGroups ln | ln <- [1..(len-1)]]
>                   --allGroups = [["P", "1", "P", "1"...], ["P1", "P1", "P1"], ...]
>                   equalGroups = map (\x -> head x) $ filter (\(h:t) -> all (h ==) t) allGroups
>                   in
>                     equalGroups ++ [inStr]
>

For a situation to be composed of tiles, its lines should be composed of tiles that have the same length. Hence, the program should first find tiles of each line and find a minimum length where all tiles of each line meet.

For example:

  P1P2P1P2
  C1C1C1C1 

is sent to tiledLine and two lists of

  ["P1P2", "P1P2P1P2"]

and

  ["C1", "C1C1", "C1C1C1C1"]

are retrieved. From these, since the minimum common length is 2 in these lists, the pattern of

  P1P2
  C1C1

is selected as the tile.

When a vertical pattern is found, a check to reduce also this is applied to it. Hence a pattern of the form

  P1P2
  C1C2
  P1P2
  C1C2

is reduced to

  P1P2
  C1C2

by checking also the vertical tiles.

> tiledSituation :: String -> String
> tiledSituation inSit = let
>                        lineTiles = map tiledLine $ lines inSit :: [[Research/String]]
>                        -- [["P1P1", "P1P1P1P1"], ...]
>                        lenlst = map (map length) lineTiles :: [[Research/Int]]
>                        -- [[4, 8], [4, 6, 8]...]
>                        findCommons :: Ord a => [a] -> [a] -> [a]
>                        findCommons [] _ = []
>                        findCommons _ [] = []
>                        findCommons (h1:t1) (h2:t2)  
>                            | h1 == h2 = h1:(findCommons t1 t2)
>                            | h1 > h2 = findCommons (h1:t1) t2
>                            | otherwise = findCommons t1 (h2:t2)
>                        
>                        commonLength  = foldr1 findCommons lenlst
>                        minlen = minimum commonLength :: Int
>                        res = map (\lst -> filter (\el -> length el == minlen) lst) lineTiles
>                        singleLine = (concat . concat) res
>                        pattern = makeGroup minlen $ head $ tiledLine singleLine
>                        in
>                        unlines pattern
>

12 March 2008

Gestalt Recognition

The show / read debugging of Gestalt.lhs completed.

Along the way I have modified readGestalt and showGestalt a bit. In current versions type signatures are:

 showGestalt :: [Gestalt] -> String

and

 readGestalt :: String -> [Gestalt]

because:

  • I saw that Pin notation for combining Gestalts is superfluous, given that Obj can take a parameter of any pattern, including combined patterns, having a Pin notation to combine patterns was not very meaningful.

Before this change, a situation of the form

  C1C1C1
  C1____

could be written by

  Obj "C1" `Mx` 0 `My` 0 `Ex` 3 `Pin` Obj "C1" `Mx` 0 `My` 0 `Ey` 2

but this led to a recursion in description which is hard to control the limits. Instead, in the current version

  Obj "C1C1C1\nC1____" `Mx` 0 `My` 0 

is preferred to above. In initial reading, however, elements should be separate, and there is no way to achieve this in current notation.

  • Current representation gives way to limit the measure similarity up to predefined number of recursive steps. The whole situation itself is a gestalt defined as: (non-strict syntax)
    sit = "C1__C1__C1__C1__
      	 P1__P1__P1__P1__
D1__D1__D1__D1__"
  Obj sit `Mx` 0 `My` 0 

hence making each pattern in sit as a subsituation.

The problem of mapping can be represented in both bottom-up (current) and top-down methods. In bottom-up method, a list of the most basic elements are retrieved and united if a similarity occurs. In top-down approach, "strikingly different" patterns in the situation are found and divided from current one. A hybrid approach may yield better results but since modelling even one of "bottom-up" and "top-down" methods seems diffucult, a hybrid approach should wait.

  • The refactoring of Gestalt idea from a recursive one to a flat one made previous reasoning about combining them obsolote. Especially ~+ operator which combines gestalts became meaningless.

A Mapping Language

I started to think the overall methodology to solve the mapping problem.

My initial idea is to represent the situation and hypothesize about them in a Genetic Programming fashion. In GP, a program (parse tree) on a problem is built and evaluated.

A small language that defines gestalts and mappings can be built. This language, supposedly a Monad in Haskell, can be used to evaluate the success of mapping.

An example might be something like:

   A = 

   P1P1____
   ________


   B = 

   ________
   __C1C1__


   C =

   C1C1______
   __________


   D = 

   ?   

represented and solved as

   do 
      Obj "P1P1" `Mx` 0 `My` 0 OfSituation` "A" `Maps` Obj "C1C1" `Mx` 1 `My` 1 OfSituation` "B"
      Obj "P1P1" `Mx` 0 `My` 0 OfSituation` "A" `Maps` Obj "C1C1" `Mx` 0 `My` 0 OfSituation` "C"
      BuildSituation Obj "P1P1" `Mx` 1 `My` 1 OfSituation` "D"

and modifications can be done to this "program" to increase its utility.

5 February 2008

Gestalt Recognition Algorithm

In today's study session, I've thought about converting Strings to Gestalts. Following are the functions that should give this. (I didn't test these yet.)

I'll need the following operator definitions beforehand.


infixl `Mx` 7
infixl `My` 7
infixl `Ex` 7
infixl `Ey` 7
infix  `Pin` 6
 

First of all, a redefinition of the data structure. This is basically the same with the structure I've recently told.

data Gestalt = Obj String
              | Gestalt `Mx` Int
              | Gestalt `My` Int
              | Gestalt `Ex` Int
              | Gestalt `Ey` Int
              | Gestalt `Pin` Gestalt
 

I need a utility function that groups elements of a list by predefined numbers. Maybe there is something like this in the libraries but I didn't want to look it up, writing is more interesting.

makeGroup :: Int -> [a] -> [[Research/a]]
 makeGroup n []  = []
 makeGroup n lst = (take n lst) : (makeGroup n $ drop n lst)
 

Next is to change a line like P1P2P3 into a list of Gestalts.

convertLine :: String -> [Gestalt]
 convertLine = convertLine' $ makeGroup 2
          where
     convertLine' :: [String] -> [Gestalt]
     convertLine' lst = foldl (\prevList, nextEl -> (Obj nextEl `Mx` (length prevList)):prevList) [] lst

And finally a function to change a situation described by a string to a list of Gestalts.

convertSit :: String -> [Gestalt]
 convertSit str = foldl convertSit' ([], 1) (lines str)
   where
     convertSit' :: ([Gestalt], Int) -> String -> ([Gestalt], Int)
     convertSit' (lst, lineNo) nextLine = let lst' = (map (\el -> el `My` lineNo) $ convertLine nextLine) : lst
                                              in
                                          (lst', lineNo+1)
 

In the next session, I expect to combine these into a recognition algorithm.

Hofstadter' Epilogue to the Analogical Mind

I read a few pages from Hofstadter's chapter in the book. His writing flow is not easy to follow. Content is wide and large, but instead of a true picture, he gives anecdotes here and there which makes the entire writing even more ahrd to grasp.

  • There are differences in languages for their selection of categories. shade/shadow for English, different to know words for different languages.
  • Even the particular pronunciation of words may be specific to situations. See author's "probab-lee" example.
  • Simple concepts are concepts much later learned, like hypebola and photosynthesis. Clear cut definitions are usually harder for the concepts we learned in the childhood.
  • High level mental chunks that lacks labels: Memories and memoires.
  • Central Cognitive Loop: (AFAIK) Constantly moving in a web of memories (LTM) associating with each other and fitting the memory to current situation by analogy. ???

I'm continuing to read.

Online Papers

Links

Son Değişiklikler

İletişim - (e-mail)

Türkçe

English

İzlediğim Bloglar

edit SideBar

Page last modified on November 17, 2007, at 12:25 AM EST - Powered by PmWiki

^