Yesterday I tried again and now it works.
Here the solution for everyone, who wants to do similar things.
To let the ModelExecutor understand the formulas, you need to setup a FunctionsLoader, which extends the AbstractFormulaFunctionsLoader:
| Code: |
public class FormulaFunctionsLoader extends AbstractFormulaFunctionsLoader {
@Override
public void loadFunctions() {
try {
clearFunctions();
InputStream stream = new FileInputStream("functions/functions_standard.xml");
loadFunctionsFromStream(stream);
} catch (FileNotFoundException e) {
}
}
}
|
The xml funcsions file is located in the sources.
Then you need to load it, before executing the model:
| Code: |
FormulaFunctionsLoader loader = new FormulaFunctionsLoader();
loader.loadFunctions();
FormulaFunctions.setFunctionsLoader(loader);
|
Now Sphinx knows how to handle with special functions.
Executing the model with following code works very well:
| Code: |
ModelExecutor executor = new ModelExecutor (model, executionSettings );
executor.init ();
executor.start ();
while (executor.getCurrentTime () < endTime ) {
executor.doTick ();
String elementName = model.getStocks ().get (0).getName ();
System.out.println (elementName + ": " + executor.getEntityExecutor (elementName ).getValue ());
}
executor.stop ();
|
Again the question:
1. Is there any documentation about running Sphinx directly from java?
2. Are there xml-Schema definitions for the xml-files?
Christian