Skip to content
Snippets Groups Projects
Commit e4b49d0d authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Update on arrow haeds for include/extend in ucd

parent c245b5c2
No related branches found
No related tags found
No related merge requests found
...@@ -57,12 +57,14 @@ public class AvatarRandom extends AvatarStateMachineElement { ...@@ -57,12 +57,14 @@ public class AvatarRandom extends AvatarStateMachineElement {
public final static int RANDOM_TRIANGULAR_LAW = 1; public final static int RANDOM_TRIANGULAR_LAW = 1;
public final static int RANDOM_GAUSSIAN_LAW = 2; public final static int RANDOM_GAUSSIAN_LAW = 2;
public final static int RANDOM_LOG_NORMAL_LAW = 3; public final static int RANDOM_LOG_NORMAL_LAW = 3;
public final static String[] DISTRIBUTION_LAWS = {"Uniform", "Triangular", "Gaussian", "Log normal"}; public final static int RANDOM_EXPONENTIAL_LAW = 4;
public final static String[] DISTRIBUTION_LAWS_SHORT = {"", " ^", "ĝ", "ln"}; public final static int RANDOM_WEIBULL_LAW = 5;
public final static String[] DISTRIBUTION_LAWS = {"Uniform", "Triangular", "Gaussian", "Log normal", "Exponential", "Weibull"};
public final static int[] NB_OF_EXTRA_ATTRIBUTES = {0, 1, 1, 2}; public final static String[] DISTRIBUTION_LAWS_SHORT = {"", " ^", "ĝ", "ln", "e^", "w"};
public final static String[] LABELS_OF_EXTRA_ATTRIBUTES_1 = {"", "triangle top", "standard deviation", "standard deviation"};
public final static String[] LABELS_OF_EXTRA_ATTRIBUTES_2 = {"", "", "", "mean"}; public final static int[] NB_OF_EXTRA_ATTRIBUTES = {0, 1, 1, 2, 1, 2};
public final static String[] LABELS_OF_EXTRA_ATTRIBUTES_1 = {"", "triangle top", "standard deviation", "standard deviation", "mean", "shape"};
public final static String[] LABELS_OF_EXTRA_ATTRIBUTES_2 = {"", "", "", "mean", "", "scale"};
protected int functionId; protected int functionId;
protected String extraAttribute1; protected String extraAttribute1;
protected String extraAttribute2; protected String extraAttribute2;
......
...@@ -755,6 +755,20 @@ public class AvatarSimulationBlock { ...@@ -755,6 +755,20 @@ public class AvatarSimulationBlock {
TraceManager.addDev("Exception on log normal: " + e.getMessage()); TraceManager.addDev("Exception on log normal: " + e.getMessage());
return minV; return minV;
} }
case AvatarRandom.RANDOM_EXPONENTIAL_LAW:
try {
return (int) (Math.floor(MyMath.exponentialDistribution( (double) (minV), (double) (maxV), extra1) ));
} catch (Exception e) {
TraceManager.addDev("Exception on exponential distribution: " + e.getMessage());
return minV;
}
case AvatarRandom.RANDOM_WEIBULL_LAW:
try {
return (int) (Math.floor(MyMath.weibullDistribution( (double) (minV), (double) (maxV), extra1, extra2) ));
} catch (Exception e) {
TraceManager.addDev("Exception on weibull distribution: " + e.getMessage());
return minV;
}
} }
return minV; return minV;
} }
......
...@@ -145,12 +145,12 @@ public final class GraphicLib { ...@@ -145,12 +145,12 @@ public final class GraphicLib {
g2.drawLine(x1, y1, x2, y2); g2.drawLine(x1, y1, x2, y2);
g2.setStroke(normalStroke); g2.setStroke(normalStroke);
// extremite 1 // end 1
if ((type == 0) || (type == 2)) { if ((type == 0) || (type == 2)) {
drawArrow(g, x1, y1, x2, y2, head, length, full); drawArrow(g, x1, y1, x2, y2, head, length, full);
} }
// extremite 2 // end 2
if ((type == 0) || (type == 1)) { if ((type == 0) || (type == 1)) {
drawArrow(g, x2, y2, x1, y1, head, length, full); drawArrow(g, x2, y2, x1, y1, head, length, full);
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
package myutil; package myutil;
import java.util.Random; import java.util.Random;
import org.apache.commons.math3.distribution.LogNormalDistribution; import org.apache.commons.math3.distribution.*;
/** /**
* Class MyMath * Class MyMath
...@@ -142,6 +142,27 @@ public class MyMath { ...@@ -142,6 +142,27 @@ public class MyMath {
return val; return val;
} }
public static double exponentialDistribution(double a, double b, double mean) {
ExponentialDistribution ed = new ExponentialDistribution(mean);
double val = ed.sample();
val += a;
if (val > b) {
return exponentialDistribution(a, b, mean);
}
return val;
}
public static double weibullDistribution(double a, double b, double shape, double scale) {
WeibullDistribution wd = new WeibullDistribution(shape, scale);
double val = wd.sample();
val += a;
if (val > b) {
return weibullDistribution(a, b, shape, scale);
}
return val;
}
......
...@@ -68,7 +68,7 @@ public abstract class TGConnectorUC extends TGConnector { ...@@ -68,7 +68,7 @@ public abstract class TGConnectorUC extends TGConnector {
@Override @Override
protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){
//g.drawLine(x1, y1, x2, y2); //g.drawLine(x1, y1, x2, y2);
GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); GraphicLib.dashedArrowWithLine(g, 1, 1, 12, x1, y1, x2, y2, false);
// Indicate semantics // Indicate semantics
w = g.getFontMetrics().stringWidth(value); w = g.getFontMetrics().stringWidth(value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment