problem

Classes used to bundle the parameters, objectives and constraints, and to manage operations that involve all of them at once, such as converting data related to the problem to a DataFrame.

class problem.EHProblem(inputs=None, outputs=['total_cost'], constraints=None, converters=None, **kwargs)[source]

A problem that works with PyEHub models

class problem.EPProblem(inputs=None, outputs='Electricity:Facility', constraints=None, converters=None, **kwargs)[source]

A problem with defaults that are appropriate for EnergyPlus simulations

Strings for objectives/constraints become a MeterReader for the meter with that name.

Integers still become numbered Parameters.

class problem.Problem(inputs: Union[int, List[Union[str, besos.parameters.Parameter]]] = None, outputs: Union[int, List[Union[str, besos.IO_Objects.Objective]]] = None, constraints: Union[int, List[Union[str, besos.IO_Objects.Objective]]] = None, add_outputs: Union[int, List[Union[str, besos.IO_Objects.Objective]]] = None, *, constraint_bounds: List[str] = None, minimize_outputs: List[bool] = None, converters: Dict[str, Callable[[str], besos.IO_Objects.IOBase]] = None)[source]

A class that collects all of the inputs, outputs and constraints related to a model. Problems track what inputs are valid, and how to apply those inputs to a model.

It tracks constraint bounds. Automatically converts certain shortcut notation: - Strings become name only Parameters - Integers become that many numbered Parameters Gives access to names of all parts of the problem Resolves duplicate names Converts numpy arrays to a DataFrame matching the format of the problem or some combination pieces of the format (ex: only inputs and constraints) Can convert to a platypus Problem (which lacks an evaluation function).

Parameters:
  • inputs – A list of Parameters, or an integer. If a list is used, strings are converted to Parameters and this list determines the valid inputs. If an integer, this problem accepts that many inputs.
  • outputs – A list of Objectives, or an integer. If a list is used, strings are converted to Objectives and this list determines the valid inputs. If an integer, this problem requires that many outputs
  • constraints – A list of Objectives to be used as constraints, or an integer. If a list is used, strings are converted to Objectives and this list determines the valid inputs. If an integer, this problem requires that many constraints.
  • add_outputs – Outputs that don’t need to be optimized in optimization algorithm
  • constraint_bounds – a list of platypus-style constraint bounds, such as “<=750”. These are used when converting constraints for use with platypus. Check the platypus documentation for more details.
  • minimize_outputs – A list with true/false values corresponding to each output. Outputs having a corresponding value of True will be minimized, while outputs having a corresponding value of False will be maximized instead.
  • converters – A dictionary with keys from {“outputs”, “constraints”} where values indicate how to convert those kinds of values to appropriate objectives/constraints for this problem.
convert(io_object, part) → besos.IO_Objects.IOBase[source]
Parameters:
  • io_object – An object that should be converted to a parameter, objective or constraint
  • part – one of ‘inputs’, ‘outputs’ or ‘constraints’ describing what to convert io_object to
Returns:

the converted object

expand_parts(parts: Union[str, List[str]]) → List[str][source]

Expands ‘auto’ and ‘all’ to the correct lists of parts, and wraps single parts in a list

get_non_objective(df)[source]

Create a list for dataframe with add_outputs value

inputs

Deprecated since version 2.0.

Problem.inputs is ambiguous, use .value_descriptors or .parameters instead.

names(parts: Union[str, List[str]] = 'auto') → List[str][source]
Parameters:parts – one of {‘inputs’, ‘outputs’, ‘constraints’, ‘violation’, ‘all’, ‘auto’}
Returns:the names requested
overwrite_df(df)[source]

Insert add_outputs’ values to dataframe

pre_optimisation()[source]

Prepare optimisation for non objectives.

record_results(inputs, results)[source]

Record add_outputs results

to_df(table: Union[numpy.array, pandas.core.frame.DataFrame], parts: Union[str, List[str]] = 'auto') → pandas.core.frame.DataFrame[source]

Converts the given table to a DataFrame that matches this problem’s input/output format

Parameters:
  • table – a table to be converted to a DataFrame. Must have the right number of columns.
  • parts – inputs, outputs, constraints or all, depending on which data the DataFrame contains
Returns:

A DataFrame containing the same data as the original table.

to_platypus() → platypus.core.Problem[source]

Converts this problem to a platypus problem. No evaluator will be included.

Returns:A corresponding platypus problem