]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.history/test/org/simantics/history/test/TestClassDistribution.java
Update structure and value cache when refreshing variable
[simantics/platform.git] / bundles / org.simantics.history / test / org / simantics / history / test / TestClassDistribution.java
1 package org.simantics.history.test;
2
3 import org.simantics.databoard.Bindings;
4 import org.simantics.databoard.serialization.Serializer;
5 import org.simantics.history.util.ClassDistribution;
6
7 /*******************************************************************************
8  * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
9  * All rights reserved. This program and the accompanying materials
10  * are made available under the terms of the Eclipse Public License v1.0
11  * which accompanies this distribution, and is available at
12  * http://www.eclipse.org/legal/epl-v10.html
13  *
14  * Contributors:
15  *     VTT Technical Research Centre of Finland - initial API and implementation
16  *******************************************************************************/
17
18
19
20 public class TestClassDistribution {
21
22         public static void main(String[] args) throws Exception {
23                                 
24                 ClassDistribution ib = new ClassDistribution(1.1); 
25                 
26                 System.out.println( ib.getClassIndex(0.001) );
27                 System.out.println( ib.getClassIndex(0.01) );
28                 System.out.println( ib.getClassIndex(0.1) );
29                 System.out.println( ib.getClassIndex(1) );
30                 System.out.println( ib.getClassIndex(10) );
31                 System.out.println( ib.getClassIndex(100) );
32                 
33                 ib.addValue(0.00001);
34                 ib.addValue(0.000015);
35                 ib.addValue(0.001);
36                 ib.addValue(0.001);
37                 ib.addValue(0.001);
38                 ib.addValue(0.01);
39                 ib.addValue(0.1);
40                 ib.addValue(1);
41 //              ib.addInterval(10);
42                 ib.addValue(100);
43                 ib.addValue(1000);
44                 
45                 System.out.println(ib);
46                 
47                 System.out.println("Largest Class = "+ ib.getClassAvg( ib.getLargestClassIndex() ) );
48                 System.out.println("Median        = "+ ib.getMedian() );
49
50                 System.out.println( Math.log(2) );              
51                 System.out.println( Math.sqrt(0.5) );
52                 
53                 System.out.println("Test Serializer");
54                 Serializer s = Bindings.getSerializer( Bindings.getBinding( ClassDistribution.class ) );
55                 byte[] data = s.serialize( ib );
56                 ib = (ClassDistribution) s.deserialize(data);
57                 
58                 System.out.println();
59                 System.out.println("Deserialized:");
60                 System.out.println(ib);
61                 System.out.println("Largest Class = "+ ib.getClassAvg( ib.getLargestClassIndex() ) );
62                 System.out.println("Median        = "+ ib.getMedian() );
63                 
64         }
65         
66 }
67