Skip to content

Commit 1ea4752

Browse files
committed
update to last MWG, add NDArray structure
1 parent c716d74 commit 1ea4752

File tree

2 files changed

+40
-13
lines changed
  • org.mwg.experiments.smartgridprofiling

2 files changed

+40
-13
lines changed

org.mwg.experiments.smartgridprofiling/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
<properties>
5353
<gs.core.version>1.2</gs.core.version>
54-
<mwg.version>3-SNAPSHOT</mwg.version>
54+
<mwg.version>4-SNAPSHOT</mwg.version>
5555
</properties>
5656

5757
<dependencies>
@@ -108,6 +108,11 @@
108108
<artifactId>ml</artifactId>
109109
<version>3-SNAPSHOT</version>
110110
</dependency>
111+
<dependency>
112+
<groupId>org.kevoree.mwg.plugins</groupId>
113+
<artifactId>ml</artifactId>
114+
<version>4-SNAPSHOT</version>
115+
</dependency>
111116

112117
</dependencies>
113118
</project>

org.mwg.experiments.smartgridprofiling/src/main/java/org/mwg/experiments/smartgridprofiling/gmm/Graph3D.java

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.mwg.ml.ProgressReporter;
1414
import org.mwg.ml.algorithm.profiling.GaussianMixtureNode;
1515
import org.mwg.ml.algorithm.profiling.ProbaDistribution;
16+
import org.mwg.ml.algorithm.profiling.ProbaDistribution2;
17+
import org.mwg.ml.common.NDimentionalArray;
1618
import org.mwg.ml.common.matrix.Matrix;
1719
import org.mwg.ml.common.matrix.operation.MultivariateNormalDistribution;
1820

@@ -53,9 +55,11 @@ public class Graph3D extends JFrame implements PropertyChangeListener {
5355
private JLabel processinginfo;
5456
private JTextField textX;
5557
private JTextField textY;
58+
private JCheckBox fastCalc;
5659
private double[] err;
5760
private int[] xConfig = {0, 24, 48};
5861
private int[] yConfig = {0, 1000, 100};
62+
private double[] range;
5963
private boolean automaticMax = false;
6064
private boolean displayGraph = false;
6165

@@ -147,19 +151,18 @@ private Plot3DPanel generatePlot() {
147151
}
148152
}
149153

150-
double yrange;
151-
yrange = (yConfig[1] - yConfig[0]);
152-
yrange = yrange / yConfig[2];
154+
range= new double[2];
155+
range[1] = (yConfig[1] - yConfig[0]);
156+
range[1] = range[1] / yConfig[2];
153157

154-
double xrange;
155-
xrange = (xConfig[1] - xConfig[0]);
156-
xrange = xrange / xConfig[2];
158+
range[0] = (xConfig[1] - xConfig[0]);
159+
range[0] = range[0] / xConfig[2];
157160

158161
for (int i = 0; i < yArray.length; i++) {
159-
yArray[i] = i * yrange + yConfig[0];
162+
yArray[i] = i * range[1] + yConfig[0];
160163
}
161164
for (int i = 0; i < xArray.length; i++) {
162-
xArray[i] = i * xrange + xConfig[0];
165+
xArray[i] = i * range[0] + xConfig[0];
163166
}
164167

165168
double[][] featArray = new double[(xArray.length * yArray.length)][2];
@@ -243,7 +246,18 @@ private double[] calculateArray(double[][] features, double[] min, double[] max)
243246
CountDownLatch countDownLatch = new CountDownLatch(1);
244247
profiler.query(selectedCalcLevel, min, max, probabilities -> {
245248
if (probabilities != null) {
246-
res[0] = probabilities.calculateArray(features, this);
249+
250+
if(!fastCalc.isSelected()) {
251+
res[0] = probabilities.calculateArray(features, this);
252+
}
253+
else {
254+
ProbaDistribution2 newCalc = new ProbaDistribution2(probabilities.total, probabilities.distributions, probabilities.global);
255+
NDimentionalArray temp = newCalc.calculate(min, max, range, err, null);
256+
res[0]=new double[features.length];
257+
for(int i=0;i<features.length;i++){
258+
res[0][i]=temp.get(features[i]);
259+
}
260+
}
247261
updateProgress(100);
248262
countDownLatch.countDown();
249263
}
@@ -369,7 +383,7 @@ private void initUI() {
369383
spUp.setContinuousLayout(true);
370384
spUp.setDividerLocation(this.getWidth() - 300);
371385

372-
GridLayout experimentLayout = new GridLayout(8, 1, 0, 0);
386+
GridLayout experimentLayout = new GridLayout(9, 1, 0, 0);
373387
board.setLayout(experimentLayout);
374388

375389
Integer[] items = new Integer[MAXLEVEL + 2];
@@ -412,10 +426,20 @@ public void actionPerformed(ActionEvent e) {
412426
processinginfo = new JLabel("");
413427
board.add(processinginfo);
414428

429+
fastCalc = new JCheckBox("fast calculation");
430+
fastCalc.addActionListener(new ActionListener() {
431+
@Override
432+
public void actionPerformed(ActionEvent e) {
433+
feed(0, null);
434+
}
435+
});
436+
board.add(fastCalc);
415437

416438
getContentPane().add(spUp, BorderLayout.CENTER);
417439

418440

441+
442+
419443
setSize(1600, 1000);
420444
setLocationRelativeTo(null);
421445

@@ -696,8 +720,6 @@ public void actionPerformed(ActionEvent e) {
696720
});
697721

698722
menu.add(menuItem);
699-
700-
701723
setJMenuBar(menuBar);
702724

703725

0 commit comments

Comments
 (0)