Add model validity check for folding models.(soloved issue #6)

  I have added a new model validity check after each optimalization step when new model is created from optimalized parameters.
  It controles if newly created model has the same count of verticies as the old one. If not than new model is invalid.