kep_solver.fileio module

This module contains file IO functions.

read_json(filename)

Read an instance in JSON format from the given file

Parameters:

filename (str) – The name of the file containing the JSON instance

Return type:

Instance

Returns:

the corresponding Instance

parse_json(jsonstring)

Read an instance in JSON format from the given string

Parameters:

jsonstring (str) – A string holding a JSON representation of the instance

Return type:

Instance

Returns:

the corresponding Instance

read_xml(filename)

Read an instance in XML format from the given file

Parameters:

filename (str) – The name of the file containing the XML instance

Return type:

Instance

Returns:

the corresponding Instance

parse_xml(xmlstring)

Read an instance in XML format from the given string

Parameters:

xmlstring (str) – A string holding a XML representation of the instance

Return type:

Instance

Returns:

the corresponding Instance

read_yaml(filename)

Read an instance in YAML format from the given file

Parameters:

filename (str) – The name of the file containing the YAML instance

Return type:

Instance

Returns:

the corresponding Instance

parse_yaml(yamlstring)

Read an instance in YAML format from the given string

Parameters:

xmlstring – A string holding a YAML representation of the instance

Return type:

Instance

Returns:

the corresponding Instance

read_file(filename)

Read a file containing a KEP instance. Will attempt to detect the correct file format if possible.

Parameters:

filename (str) – The name of the file containing the instance

Return type:

Instance

Returns:

the corresponding Instance

class UKJson(model, pool, solution)

Bases: object

A class for outputing JSON-formatted results in the style prescribed by the UK KEP and NHSBT.

__init__(model, pool, solution)
to_string()

Return a string representing the solution as a JSON object.

Return type:

str

Returns:

A string representing the JSON.

write(output)

Write the details to a JSON file, or file-like object.

Parameters:

output (TextIO) – A file-like object where output will be written.

class UKXML(model, pool, solution)

Bases: object

A class for outputing XML-formatted results in the style prescribed by the UK KEP and NHSBT.

__init__(model, pool, solution)
to_string()

Return a string representing the solution as a JSON object.

Return type:

str

Returns:

A string representing the JSON.

write(output)

Write the details to a XML file, or file-like object.

Parameters:

output (TextIO) – A file-like object where output will be written.