@Override public Object run() throws Exception { OutputStragegy st = getOutput().getOutputStrategy(getName()); File lastFolder = st.nextOutputFolder(); if (log.isLoggable(Level.CONFIG)) { log.config("Simulation output folder: " + lastFolder); } lastFolder.mkdirs(); Logger.getLogger("oms3.model").setLevel(Level.WARNING); ObjFunc.adjustWeights(ofs); run(getModel(), getOut(), lastFolder, getName()); return null; }
private double run_model(Model model, List<Output> out, File folder, String simName, double[] x) throws Exception { Map<String, Object> parameter = model.getParameter(); Object comp = model.getComponent(); // spatial params ParameterData[] pd = Step.create(params, parameter); for (int i = 0; i < pd.length; i++) { pd[i].generateValues(x[i]); } for (int i = 0; i < pd.length; i++) { String name = pd[i].getName(); double[] val = pd[i].getDataValue(); parameter.put(name, toValue(name, val, parameter)); } ComponentAccess.callAnnotated(comp, Initialize.class, true); // setting the input data; boolean success = ComponentAccess.setInputData(parameter, comp, log); if (!success) { throw new RuntimeException("There are Parameter problems. Simulation exits."); } ComponentAccess.adjustOutputPath(folder, comp, log); for (Output e : out) { e.setup(comp, folder, simName); } // execute phases and be done. log.config("Exec ..."); ComponentAccess.callAnnotated(comp, Execute.class, false); log.config("Finalize ..."); ComponentAccess.callAnnotated(comp, Finalize.class, true); for (Output e : out) { e.done(); } return ObjFunc.calculateObjectiveFunctionValue( ofs, startMonthOfYear, sens_start, sens_end, folder); }