Skip to content

Ask-tell: Be explicit about allowed number of asks() #996

@MichaelClerx

Description

@MichaelClerx

Currently the MCMC methods operate in one of two ways:

Form 1:

def ask():
    if self._proposed is None:
        self._proposed = ...
    return self._proposed

def tell(fx):
    if self._proposed is None:
        raise RuntimeError('No proposal set / expecting ask')
    ...
    self._proposed = None

In this method you can call ask() as often as you like between tells, it will just return the same proposal again and again and again. So ask tell ask tell is the same as ask ask ask tell ask ask tell ask ask. Two tells are never allowed ask tell tell = error.

Form 2:

def ask():
    if self._ready_for_tell:
        raise RuntimeError('Expecting tell()')
    do_complex_stuff()
    set_a_proposal()
    self._ready_for_tell = True

def tell():
    if not self._ready_for_tell:
        raise RuntimeError('Expecting ask()')
    self._ready_for_tell = False

In this method you're only allowed one ask() per tell. So ask ask tell is an error, as is ask tell tell.

So what

Form 2 is easier for complex methods. And we don't have a use case where form 1 is really necessary. So... should we explicitly disallow form 1?

@ben18785 @martinjrobins ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions