def model_init(self, policy, kwargs): '''initializes the model''' try: self.modelFile = policy['file'] except KeyError: EMAlogging.warning("key 'file' not found in policy") super(SalinizationModel, self).model_init(policy, kwargs)
def model_init(self, policy, kwargs): """initializes the model""" try: self.modelFile = policy["file"] except KeyError: logging.warning("key 'file' not found in policy") super(FluModel, self).model_init(policy, kwargs)
def model_init(self, policy, kwargs): """ Method to initialize the model, it is called just prior to running the model its main use is to initialize aspects of the model that can not be pickled. In this way it is possible to run a model in parallel without having to worry about having only pickleable attributes (for more details read up on the multiprocessing library """ if not jpype.isJVMStarted(): classpath = r'-Djava.class.path=C:\workspace\ElectTransEMA\bin;C:\workspace\Repast3.1\bin;C:\workspace\Repast3.1\lib\asm.jar;C:\workspace\Repast3.1\lib\beanbowl.jar;C:\workspace\Repast3.1\lib\colt.jar;C:\workspace\Repast3.1\lib\commons-collections.jar;C:\workspace\Repast3.1\lib\commons-logging.jar;C:\workspace\Repast3.1\lib\geotools_repast.jar;C:\workspace\Repast3.1\lib\ibis.jar;C:\workspace\Repast3.1\lib\jakarta-poi.jar;C:\workspace\Repast3.1\lib\jep-2.24.jar;C:\workspace\Repast3.1\lib\jgap.jar;C:\workspace\Repast3.1\lib\jh.jar;C:\workspace\Repast3.1\lib\jmf.jar;C:\workspace\Repast3.1\lib\jode-1.1.2-pre1.jar;C:\workspace\Repast3.1\lib\log4j-1.2.8.jar;C:\workspace\Repast3.1\lib\joone.jar;C:\workspace\Repast3.1\lib\JTS.jar;C:\workspace\Repast3.1\lib\junit.jar;C:\workspace\Repast3.1\lib\OpenForecast-0.4.0.jar;C:\workspace\Repast3.1\lib\openmap.jar;C:\workspace\Repast3.1\lib\plot.jar;C:\workspace\Repast3.1\lib\ProActive.jar;C:\workspace\Repast3.1\lib\trove.jar;C:\workspace\Repast3.1\lib\violinstrings-1.0.2.jar;C:\workspace\Repast3.1\repast.jar' jpype.startJVM(r'C:\Program Files (x86)\Java\jdk1.6.0_22\jre\bin\client\jvm.dll', classpath) logging.debug("jvm started") logging.debug("trying to find package") try: modelPackage = jpype.JPackage("org").electTransEma # testPkg = jpype.JPackage("org").test except RuntimeError as inst: logging.debug("exception " + repr(type(inst))+" " + str(inst)) except TypeError as inst: logging.debug("TypeEror " +" " + str(inst)) except Exception as inst: logging.debug("exception " + repr(type(inst))+" " + str(inst)) else: logging.debug("modelPackage found") self.modelInterfaceClass = modelPackage.ElectTransInterface # testClass = testPkg.jPypeTestClass logging.debug("class found") try: directory = self.workingDirectory.replace("\\", "/") self.modelInterface = self.modelInterfaceClass(directory) # self.testObject = testClass() logging.debug("class loaded succesfully") except TypeError as inst: logging.warning("failure to instantiate the model") raise inst