How is effective iterative deepening searching effective in haskell?

I have an optimization problem that I want to solve. You have some data structure:

data Foo =
  { fooA :: Int
  , fooB :: Int
  , fooC :: Int
  , fooD :: Int
  , fooE :: Int
}

and rating function:

rateFoo :: myFoo -> Int

I need to optimize the result rateFooby changing the values ​​in the structure. In this particular case, I decided to use the search for iterative deepening to solve the problem. The search tree (infinite) for better optimization is created by another function that simply recursively applies all possible changes to the tree:

fooTree :: Foo -> Tree

My search function looks something like this:

optimize :: Int -> Foo -> Foo
optimize threshold foo = undefined

The question I had before starting was this:

, , ? , , ( n O(n), n , , )?

? ( )? ?

+3
2

:

  • .
  • .
  • .

, / , , GHC . , , , , , , , , , ..

" " Haskell , 2 3.


, IDDFS, f , p , x .

search :: (a -> [a]) -> (a -> Bool) -> a -> Bool
search f p x = any (\d -> searchTo f p d x) [1..]
  where
    searchTo f p d x
      | d == 0    = False
      | p x       = True
      | otherwise = any (searchTo f p $ d - 1) (f x)

"abbaaaaaacccaaaaabbaaccc" children x = [x ++ "a", x ++ "bb", x ++ "ccc"] f. ( , ). - , , ?

+3

.

, .

, - . node , , .. node, ( node ), ( , node ). , "" .

+4

Source: https://habr.com/ru/post/1765766/


All Articles