def read_cin_file(file): ''' read a .cin file :param file: location of the .cin file. :exception: raises a :class:`~EMAExceptions.VensimWarning` if the cin file cannot be read. ''' ema_logging.debug("executing COMMAND: SIMULATE>READCIN|"+file) try: command(r"SIMULATE>READCIN|"+file) except VensimWarning as w: ema_logging.debug(str(w)) raise w
def load_model(file): ''' load the model :param file: the location of the .vpm file to be loaded. :exception: raises a :class:`~EMAExceptions.VensimError` if the model cannot be loaded. .. note: only works for .vpm files ''' ema_logging.debug("executing COMMAND: SIMULATE>SPECIAL>LOADMODEL|"+file) try: command(r"SPECIAL>LOADMODEL|"+file) except VensimWarning as w: ema_logging.warning(str(w)) raise VensimError("vensim file not found")
def run_simulation(file): ''' Convenient function to run a model and store the results of the run in the specified .vdf file. The specified output file will be overwritten by default :param file: the location of the outputfile :exception: raises a :class:`~EMAExceptions.VensimError` if running the model failed in some way. ''' try: ema_logging.debug(" executing COMMAND: SIMULATE>RUNNAME|"+file+"|O") command("SIMULATE>RUNNAME|"+file+"|O") ema_logging.debug(r"MENU>RUN|o") command(r"MENU>RUN|o") except VensimWarning as w: ema_logging.warning((str(w))) raise VensimError(str(w))
def set_value(variable, value): ''' set the value of a variable to value current implementation only works for lookups and normal values. In case of a list, a lookup is assumed, else a normal value is assumed. See the DSS reference supplement, p. 58 for details. :param variable: name of the variable to set. :param value: the value for the variable. **note**: the value can be either a list, or an float/integer. If it is a list, it is assumed the variable is a lookup. ''' if type(value) == types.ListType: command(r"SIMULATE>SETVAL|"+variable+"("+ str(value)[1:-1] + ")") else: try: command(r"SIMULATE>SETVAL|"+variable+"="+str(value)) except VensimWarning: ema_logging.warning('variable: \'' +variable+'\' not found')