outputs#
Write output files.
- wip.modules.outputs.define_optimization_results(solver_path: str, scalers: Dict[str, MinMaxScaler], datasets: Dict[str, DataFrame], solver)[source]#
- wip.modules.outputs.get_pisystem_tag_name(pims_tag_name: str) str [source]#
Get the PI System tag name from the PIMS tag name.
This function starts by cleaning the
pims_tag_name
string. The cleaning process performs the following operations:- If the
pims_tag_name
has the “@” symbol, then the string is split into two parts: the first part is the prefix and the second part is the rest of the string. Then all ‘_’ are replaced with ‘-‘ for the second part of the string. Finally, the prefix and the second part of the string are rejoined together with the ‘@’ symbol between them.
- If the
All ‘___’ are replaced with ‘ - ‘.
All ‘__’ are replaced with ‘_’.
Function removes leading ‘_’.
After the cleaning process, the function checks if the
pims_tag_name
is in thepims_to_pisystem_dict
dictionary. If it’s, then the corresponding PI System tag name is returned. If it’s not, then the function tries to find the key in thepims_to_pisystem_dict
dictionary that’s the most similar to thepims_tag_name
. If a similar key is found, then the corresponding PI System tag name is returned. If a similar key isn’t found, then the function logs an error message and returns the cleaned tag name.- Parameters
pims_tag_name (
str
) – Tag name in the PIMS format.- Returns
PI System tag name or clean tag name if the PI System tag name isn’t found in the
pims_to_pisystem_dict
dictionary.- Return type
Notes
This function is intended to be used to convert the variables’ names post-optimization, to include them in the final results file.
- wip.modules.outputs.lp_variables_to_excel(lp_problem: LpProblem, output_path: str, format: str = 'xlsx')[source]#
Save the LP variables to an Excel file.
- wip.modules.outputs.replace_symbols(name: str) str [source]#
Replace certain words in a string with mathematical symbols.
This function takes a string and replaces occurrences of the words ‘equal’, ‘div’, and ‘mult’ with the mathematical symbols ‘=’, ‘/’, and ‘*’, respectively.
- Parameters
name (
str
) – Input string which may contain the words ‘equal’, ‘div’, and ‘mult’ that need to be replaced with their corresponding mathematical symbols.- Returns
Output string after replacing the words with the corresponding mathematical symbols.
- Return type
Examples
>>> replace_symbols("x mult y div z equal 10") 'x * y / z = 10'