Help with Heuristics in Haskell

Asked

Viewed 108 times

0

Good afternoon, folks I’m having a problem here to be solved in Askell, his description is as follows:

"Original Cutting Problem is the One-Dimensional Cutting Problem, which consists of cutting a single bar of material into smaller pieces, always following patterns of pre-defined sizes. Objective is to make the most of the material, that is, to minimize the leftovers.

Develop in Haskell a heuristic to solve the One-dimensional Cut Problem. As a basic input for the heuristic to be developed receive the following parameters: •t: size of the bar to be cut into smaller pieces; •[P1,P2,...,Pn]: list of the set of cutting patterns. The heuristics to be developed should be based on the random choice of cut patterns. That is, while the leftover material is larger than the smallest of the standards, a new cutting pattern should be selected and added to the solution of the problem. "

Then to generate the random values will be used the Random library, and I’m a few days trying to figure out how to do that and I don’t get anywhere, I don’t know where to start. Could someone please shed some light? Thank you truly =)

  • 2

    Did you ever make any code already? Post what you’ve done.

  • We try to do something like this here: import System.Random (randomRIO) randomSimples x = randomRIO(1,x) processes list value = value <-randomSimples(legth list) choose list value max = if value > max then processes list value Else value selects list value max= choose list value max, size <- list !! value, print(size) max x list | (minimum list) <= x = selects list value max, max(x-size) list | otherwise = putStrLn "Rest: ",print(x) .

  • If you’re going to add something to the question, like code, edit it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.