Skip to content

Heuristic approach for pizza cutting

seajer edited this page Jan 22, 2017 · 4 revisions

Lets start from begining:

  • Read file and transform it to out pizza (List<Cell> pizza).
  • While we read file, founding Сells, which ingradien is minority.

Second step : generate all available methods for pizza cuting (using data from file about max cells in one sliece)

  • now we shoud hawe bunch of methods:
  1. We have minimum one minority ingradient in all available positions and from one to (max - 1) other ingradients in all other pisitions.
  2. Methods shoud return from 2 to max Cells in slice.

Third step: start generating all wariants of slices

  • For 6 cells in piece we shoud have 60 variants of difference slices.
  • Start brute forcing for get all variants of slices with start in minor ingradient cell.

Forth step: one cycle of brute forse

  • Found first minority ingradient.
  • Use it as start for geting slice.
  • Check if method, that we gona use are available (did we have enough cells?).
  • If prevoius condition are true - go next, else - use next method.
  • Cut slice from pizza.
  • Continue until pizza have at least one minority ingradient.

Fifth step: analyse what we have in the end

  • We have List<List<List<Cell>>> - it's means that we hawe all variants of transposal all available variants for cutting pizza.
  • For each variant checks cells that left in main pizza and wasn't cutted.
  • Found variant with minimun cells in pizza (in ideal it shoud be zero value).
  • Mark this variant as optimal and get his List<List<Cells>>.
  • Use founded List<List<Cell>> as base object for output file formater.
  • Enjoy your work.