Command file standard

Command file standard#

It is possible to predefine all SHOP commands to be executed in a single text file. This is most useful when running SHOP as a standalone program, since commands also can be specified directly in pyshop or as part of the JSON and YAML files.

The command file is a plain text file where commands can be specified in sequence on each new line. Commands are written in the format:

command /option1 /option2 ... value1 value2 ...

As in the ASCII files, the # symbol at the start of a line in the command file is interpreted as a comment. The example below reads in some input data files, performs an optimization, dumps results to YAML, and exits:

# Read in data
read model my_model.ascii
add model more_data.ascii
read yaml even_more_data.yaml

# Run the optimization
start sim 3
set code /incremental
start sim 3

# Dump results to YAML
print yaml /output_only /compress_txy results.yaml

# Exit SHOP
quit

The quit command is only used when running SHOP as a standalone program.

It is also possible to read in the command file in pyshop with the function run_command_file. This function also accepts optional arguments to stop executing commands when the first start sim command is encountered, and to skip commands that read in ASCII and YAML input model files.