cofi.InversionOptions#

class cofi.InversionOptions[source]#

Class for specification on how an inversion will run, including which backend tool to use and solver-specific parameters.

Tip

A typical workflow of InversionOptions:

Step 1 (optional): let the Guidance Methods to walk you through available solving methods in a hierarchical way.

Step 2: Use the Set/Unset Backend Tools to fix your choice on which backend tool to use.

Step 3: Set solver-specific parameters using the Solver Params related methods.

Warning

Methods that guide users through available solvers tree is still under consideration - we are working on deciding how such APIs are named and used. Ideally, we have a tree in the backend, with the root level branching into sampling, direct search and optimization and further categorisations that lead to lists of backend tools as the leaves.

Guidance Methods

Here are how you can walk through our solvers tree as a guidance. Note that this step is optional, and you can always jump to Set/Unset Backend Tools directly.

InversionOptions.set_solving_method(method)

Sets the solving method

InversionOptions.unset_solving_method()

Unsets the chosen solving approach

back to top

Set/Unset Backend Tools

To select/unselect a backend tool, use the following methods

InversionOptions.set_tool(tool)

Sets the tool that will be the backend solver for your inversion problem

InversionOptions.unset_tool()

Unsets the chosen backend tool

InversionOptions.get_tool()

Get the backend tool chosen so far, or the default tool if not chosen

InversionOptions.get_default_tool()

Get the default tool based on the chosen solving method

InversionOptions.suggest_tools()

Prints a list of tools based on the solving method chosen

back to top

Solver Params

To set tool-specific parameters, use the following methods

InversionOptions.set_params(**kwargs)

Sets solver-specific parameters

InversionOptions.get_params()

Get solver-specific parameters defined so far

InversionOptions.suggest_solver_params()

Prints required and optional solver-specific parameters

back to top

Reference Details

get_default_tool() str[source]#

Get the default tool based on the chosen solving method

Returns:

the name of the default backend tool

Return type:

str

get_params() dict[source]#

Get solver-specific parameters defined so far

Returns:

a Python dictionary that maps solver-specific parameter name to the value you’ve set.

Return type:

dict

Examples

get_tool() str | Type[source]#

Get the backend tool chosen so far, or the default tool if not chosen

Returns:

the name of the backend tool (if it’s supported by us), or the class name of your own solver

Return type:

Union[str, Type]

set_params(**kwargs)[source]#

Sets solver-specific parameters

Use InversionOptions.suggest_solver_params to get a list of parameters required and optional.

To set the parameters, use argument keyword to specify directly which parameter you refer to.

Examples

set_solving_method(method: str)[source]#

Sets the solving method

Warning

The current version is a flattened version of our inference tools tree, we are going to change this interface very soon.

Use InversionOptions.suggest_solving_methods to get a list of solving methods to choose from.

Parameters:

method (str) – the string that represents a solving approach

Raises:

ValueError – when the solving method you attempt to set is invalid

Examples

set_tool(tool: str | Type)[source]#

Sets the tool that will be the backend solver for your inversion problem

This can be:

Parameters:

tool (Union[str, Type]) – either the name of a backend tool or your custom tools.BaseInferenceTool class

Raises:

ValueError – when the string you pass in isn’t in our supported tools list, or when the inference tool class you pass in doesn’t implement the __call__(self,) method.

Examples

suggest_solver_params()[source]#

Prints required and optional solver-specific parameters

Examples

suggest_solving_methods()[source]#

Prints a list of solving methods to choose from

Examples

suggest_tools()[source]#

Prints a list of tools based on the solving method chosen

Examples

summary()[source]#

Helper method that prints a summary of current InversionOptions object to console

Examples

unset_solving_method()[source]#

Unsets the chosen solving approach

unset_tool()[source]#

Unsets the chosen backend tool

back to top