add experimental optimo into project

This commit is contained in:
Jonathan Shook 2020-09-10 09:37:07 -05:00
parent 9e4551a7cf
commit 43f41caecd
2 changed files with 14 additions and 6 deletions

View File

@ -7,27 +7,33 @@ public class MVResult {
private final double[] vars;
private final MVParams params;
private final double[][] datalog;
public MVResult(double[] vars, MVParams params, double[][] datalog) {
this.params = params;
this.vars = vars;
this.datalog = datalog;
}
public double[] getVarArray() {
return vars;
}
public Map<String,Double> getVarMap() {
Map<String,Double> result = new HashMap<>(params.size());
public double[][] getDatalog() {
return datalog;
}
public Map<String, Double> getVars() {
Map<String, Double> result = new HashMap<>(params.size());
for (int i = 0; i < vars.length; i++) {
result.put(params.get(i).name,vars[i]);
result.put(params.get(i).name, vars[i]);
}
return result;
}
public String toString() {
StringBuilder sb = new StringBuilder();
int pos=0;
int pos = 0;
for (MVParams.MVParam param : params) {
sb.append(param.name).append("=").append(vars[pos])
.append(" [").append(param.min).append("..").append(param.max)

View File

@ -13,7 +13,7 @@ public class PolyglotMultivariateObjectScript implements MultivariateFunction {
private final MVParams params;
private final Object function;
private Logger logger;
private final Logger logger;
public PolyglotMultivariateObjectScript(Logger logger, MVParams params, Object function) {
this.logger = logger;
@ -37,10 +37,12 @@ public class PolyglotMultivariateObjectScript implements MultivariateFunction {
if (result instanceof Double) {
return (Double) result;
} else if (result instanceof Integer) {
return (double) ((Integer) result);
} else {
throw new RuntimeException(
"Unable to case result of polyglot function return value as a double:" +
result.getClass().getCanonicalName()+", toString=" + result.toString());
result.getClass().getCanonicalName() + ", toString=" + result.toString());
}
}
}