main.io.github.moonlightsuite.moonlight.offline.signal.SignalCreatorDouble Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moonlight-engine Show documentation
Show all versions of moonlight-engine Show documentation
MoonLight is a light-weight Java-tool for monitoring temporal, spatial and spatio-temporal properties of distributed complex systems, such as Cyber-Physical Systems and Collective Adaptive Systems.
The newest version!
package io.github.moonlightsuite.moonlight.offline.signal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
@Deprecated
public class SignalCreatorDouble {
// private Map> functionalMap;
//
// public SignalCreatorDouble(Map> functionalMap) {
// this.functionalMap = functionalMap;
// }
//
// public VariableArraySignal generate(double timeInit, double timeEnd, double timeStep) {
// List> varTypes = new ArrayList<>();
// List varName = new ArrayList<>();
// for (Map.Entry> stringFunctionEntry : functionalMap.entrySet()) {
// Function value = stringFunctionEntry.getValue();
// varTypes.add(value.apply(timeInit).getClass());
// varName.add(stringFunctionEntry.getKey());
// }
//
// Class>[] classes = varTypes.toArray(new Class>[0]);
// String[] names = varName.toArray(new String[0]);
// VariableArraySignal result = new VariableArraySignal(names, new AssignmentFactory(classes));
// for (double t = timeInit; t < timeEnd; t += timeStep) {
// result.add(t, applyFunctions(functionalMap.entrySet().iterator(), classes, t));
// }
// result.add(timeEnd, applyFunctions(functionalMap.entrySet().iterator(), classes, timeEnd));
//
// return result;
// }
//
// public double[] generateTime(double timeInit, double timeEnd, double timeStep) {
// int length = (int) Math.round(Math.floor((timeEnd - timeInit) / timeStep));
// double[] time = new double[length];
// for (int i = 0; i < time.length; i++) {
// time[i] = timeInit + i * timeStep;
// }
// return time;
// }
//
// public double[][] generateValues(double[] time) {
// double[][] values = new double[functionalMap.keySet().size()][time.length];
// for (int i = 0; i < time.length; i++) {
// Iterator> iterator = functionalMap.values().iterator();
// for (int j = 0; j < functionalMap.keySet().size(); j++) {
// Function next = iterator.next();
// values[j][i] = next.apply(time[i]);
// }
// }
// return values;
// }
//
//
// private Assignment applyFunctions(Iterator>> iterator, Class>[] classes, double t) {
// Object[] values = new Object[classes.length];
//
// for (int i = 0; i < classes.length; i++) {
// Map.Entry> next = iterator.next();
// Function value = next.getValue();
// values[i] = value.apply(t);
// }
// return new Assignment(classes, values);
// }
//
// public String[] getVariableNames() {
// return functionalMap.keySet().toArray(new String[0]);
//
// }
}