Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#15850 closed enhancement (fixed)

FiniteStateMachine: provide hook on_duplicate_transition

Reported by: cheuberg Owned by:
Priority: major Milestone: sage-6.2
Component: combinatorics Keywords: finite_state_machine
Cc: dkrenn, skropf, slabbe Merged in:
Authors: Clemens Heuberger, Daniel Krenn Reviewers: Daniel Krenn, Volker Braun
Report Upstream: N/A Work issues:
Branch: 12351e2 (Commits, GitHub, GitLab) Commit:
Dependencies: #15841, #15847, #15848 Stopgaps:

Status badges

Description (last modified by cheuberg)

Previously, when inserting a transition which is already present, this was simply ignored. By providing a hook on_duplicate_transition, user defined behaviour is now possible. As examples, three functions are provided (the default ignore, maintaining the previous behaviour; raise error or add input label). The latter may be used to model a Markov chain where the input labels are interpreted als transition probabilities.

Change History (6)

comment:1 Changed 8 years ago by cheuberg

  • Authors changed from Clemens Heuberger to Clemens Heuberger, Daniel Krenn
  • Branch set to u/cheuberg/fsm/on_duplicate_transition
  • Cc dkrenn skropf added
  • Commit set to 12351e2a78fa8bf3b6487495499826eacdf9ebdb
  • Dependencies set to #15841, #15847, #15848
  • Description modified (diff)
  • Status changed from new to needs_review

comment:2 Changed 8 years ago by dkrenn

  • Reviewers set to Daniel Krenn

During the review: Made some small changes. Code itself looks fine, doctests pass, docu checked, coverage checked. For me this is a positive review, but it would be good if someone else could have a look on it.

comment:3 Changed 8 years ago by cheuberg

  • Cc slabbe added

In #15078, comment 19, slabbe recommended having distinct classes FiniteStateMachine, Transducer, Automaton.

Therefore, I think it to be appropriate to briefly explain why I used a hook in this instance instead of having a new class MarkovChain:

  • first, I think that it gives us more flexibility to customize the behaviour slightly
  • second, having a class MarkovChain would probably require us to check whether the sum of the input weights of the transitions leaving a state adds up to 1. This would be quite cumbersome and inefficient. This checking is dealt with in #15961 (depending on this ticket).

comment:4 follow-up: Changed 8 years ago by vbraun

  • Reviewers changed from Daniel Krenn to Daniel Krenn, Volker Braun
  • Status changed from needs_review to positive_review

Would be nicer to collect stuff into a class/module `duplicate_transaction.raise_error', maybe in the future.

comment:5 Changed 8 years ago by vbraun

  • Branch changed from u/cheuberg/fsm/on_duplicate_transition to 12351e2a78fa8bf3b6487495499826eacdf9ebdb
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:6 in reply to: ↑ 4 Changed 8 years ago by cheuberg

  • Commit 12351e2a78fa8bf3b6487495499826eacdf9ebdb deleted

Replying to vbraun:

Would be nicer to collect stuff into a class/module `duplicate_transaction.raise_error', maybe in the future.

Sorry, I do not really understand your comment. What should be collected in duplicate_transaction.raise_error?

Note: See TracTickets for help on using tickets.