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
- 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.
- 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.
- 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.
- class problem.Problem(inputs: Optional[Union[int, List[Union[str, Parameter]]]] = None, outputs: Optional[Union[int, List[Union[str, Objective]]]] = None, constraints: Optional[Union[int, List[Union[str, Objective]]]] = None, add_outputs: Optional[Union[int, List[Union[str, Objective]]]] = None, *, constraint_bounds: Optional[List[str]] = None, minimize_outputs: Optional[List[bool]] = None, converters: Optional[Dict[str, Callable[[str], 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) 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
- property 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
- to_df(table: Union[array, DataFrame], parts: Union[str, List[str]] = 'auto') 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.