Commit da5ce6ba authored by Simon Eismann's avatar Simon Eismann

implemented mars model

parent a36c835b
......@@ -42,20 +42,19 @@ package de.tud.cs.simqpn.kernel.loading.distributions;
public class MARS implements AbstractDistribution {
private static final long serialVersionUID = 1L;
private Function[] functions = null;
private double constant;
private double[] coefficients;
private double[] knots;
private int[] sides;
private Double constant;
private Double[] coefficients;
private Double[] knots;
private Integer[] sides;
private String[] colorIds;
public MARS(double constant, double[] coefficients, double[] knots, int[] sides, String[] colorIds) {
public MARS(double constant, Double[] doubles, Double[] doubles2, Integer[] integers, String[] strings) {
this.constant = constant;
this.coefficients = coefficients;
this.knots = knots;
this.sides = sides;
this.colorIds = colorIds;
this.coefficients = doubles;
this.knots = doubles2;
this.sides = integers;
this.colorIds = strings;
}
@Override
......
......@@ -41,27 +41,58 @@
*/
package de.tud.cs.simqpn.kernel.loading.distributions;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import de.tud.cs.simqpn.kernel.SimQPNException;
public class MARSCreator extends DistributionCreator {
double constant;
double[] coefficients;
double[] knots;
int[] sides;
String[] colorIds;
List<Double> coefficients = new LinkedList<Double>();
List<Double> knots = new LinkedList<Double>();
List<Integer> sides = new LinkedList<Integer>();
List<String> colorIds = new LinkedList<String>();
String marsFilename;
@Override
protected void loadParams() throws SimQPNException {
loadDoublesFromFile("marsfilename");
marsFilename = this.loadStringParam("marsfilename");
loadMARSModelFromFile("marsFile");
marsFilename = this.loadStringParam("marsFile");
}
private void loadMARSModelFromFile(String fileName) {
try (BufferedReader br = new BufferedReader(new FileReader(new File(fileName)))) {
String line = br.readLine();
constant = Double.valueOf(line);
while ((line = br.readLine()) != null) {
String[] segments = line.split(" ");
coefficients.add(Double.valueOf(segments[0]));
knots.add(Double.valueOf(segments[1]));
sides.add(Integer.valueOf(segments[2]));
colorIds.add(segments[3]);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public AbstractDistribution getDistribution()
throws SimQPNException {
return new MARS(constant, coefficients, knots, sides, colorIds);
Double[] coefficientsArray = new Double[coefficients.size()];
Double[] knotsArray = new Double[knots.size()];
Integer[] sidesArray = new Integer[sides.size()];
String[] colorArray = new String[colorIds.size()];
return new MARS(constant, coefficients.toArray(coefficientsArray), knots.toArray(knotsArray),
sides.toArray(sidesArray), colorIds.toArray(colorArray));
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment