Displaying differences for changeset
 
display as  

nbproject/genfiles.properties

@@ -5,7 +5,7 @@
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=16fcfe9f
 nbproject/build-impl.xml.script.CRC32=5d2b7162
-nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.90.0.1
+nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.92.0.1
 nbproject/rest-build.xml.data.CRC32=bff4a8fe
 nbproject/rest-build.xml.script.CRC32=4734534b
 nbproject/rest-build.xml.stylesheet.CRC32=5f13befe@1.21

nbproject/private/private.properties

@@ -1,7 +1,7 @@
-deploy.ant.properties.file=/home/od/.netbeans/14/tomcat80.properties
-j2ee.server.home=/opt/apache-tomcat-8.5.57
-j2ee.server.instance=tomcat80:home=/opt/apache-tomcat-8.5.57
+deploy.ant.properties.file=/home/od/.netbeans/16/tomcat90.properties
+j2ee.server.home=/opt/apache-tomcat-9.0.59
+j2ee.server.instance=tomcat90:home=/opt/apache-tomcat-9.0.59
 javac.debug=true
 javadoc.preview=true
 selected.browser=default
-user.properties.file=/home/od/.netbeans/14/build.properties
+user.properties.file=/home/od/.netbeans/16/build.properties

nbproject/private/private.xml

@@ -63,9 +63,6 @@
             <file>file:/od/projects/csip-all/csip-example/web/WEB-INF/csip-defaults.json</file>
             <file>file:/od/projects/csip-all/csip-example/src/java/m/example/stats/V2_0.java</file>
         </group>
-        <group name="work">
-            <file>file:/od/projects/csip-all/csip-example/src/java/m/example/solitaire/SolitaireBitSet.java</file>
-            <file>file:/od/projects/csip-all/csip-example/src/java/m/example/solitaire/Solitaire.java</file>
-        </group>
+        <group name="work"/>
     </open-files>
 </project-private>

nbproject/project.properties

@@ -1,6 +1,6 @@
 file.reference.commons-math3-3.6.1.jar=lib/commons-math3-3.6.1.jar
 file.reference.guava-23.5-jre.jar=lib/guava-23.5-jre.jar
-j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.6.3.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
+j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-ssi.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.20.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
 #Mon Nov 09 10:36:44 MST 2015
 javadoc.splitindex=true
 lib.dir=${web.docbase.dir}/WEB-INF/lib

src/java/m/example/solitaire/Solitaire.java

@@ -16,7 +16,7 @@
   static final int OVER = 1;
   static final int TO = 2;
 
-  static final int[][] MOVES = new int[][]{
+  static final int[][] JUMPS = {
     {0, 2, 5},
     {0, 1, 3},
     {1, 4, 8},
@@ -55,15 +55,24 @@
     {14, 9, 5}
   };
 
+  int numBoards = 0;
+  int[] solutions = new int[15];
+  boolean[] initialBoard = {
+    true,
+    true, true,
+    true, true, true,
+    true, true, true, true,
+    true, true, true, true, true
+  };
 
-  static void init() {
-    boards = 0;
-    solutions = new int[15];
+  int missing;
+
+
+  public Solitaire(int missing) {
+    initialBoard[missing] = false;
+    this.missing = missing;
   }
 
-  static int boards = 0;
-  static int[] solutions = new int[15];
-
   static class Board {
 
     boolean[] board;
@@ -77,7 +86,6 @@
       this.from = from;
       this.to = to;
       this.prev = prev;
-      boards++;
     }
 
 
@@ -95,8 +103,8 @@
     List<Board> allJumps() {
       List<Board> bs = new LinkedList<>();
       Board b;
-      for (int[] mv : MOVES) {
-        if ((b = jump(mv[FROM], mv[OVER], mv[TO])) != null)
+      for (int[] j : JUMPS) {
+        if ((b = jump(j[FROM], j[OVER], j[TO])) != null)
           bs.add(b);
       }
       return bs;
@@ -118,34 +126,52 @@
       return new StringBuffer().append(from)
           .append('\u2192').append(to).toString();
     }
-
   }
 
 
-  static void solve(Board b) {
-    List<Board> moves = b.allJumps();
-    if (moves.isEmpty()) {
+  void solve(Board b) {
+    List<Board> boards = b.allJumps();
+    if (boards.isEmpty()) {
+
       // no more moves
       // if (b.getCount() == 1)
       //   System.out.println(allMoves(b));
-
       solutions[b.getCount()]++;
       return;
     }
 
-    for (Board board : moves) {
-      solve(board);
+    numBoards += boards.size();
+
+    for (Board b1 : boards) {
+      solve(b1);
     }
   }
 
 
-  static StringBuffer allMoves(Board b) {
+  void solveAll() {
+    solve(new Board(initialBoard, 0, 0, null));
+  }
+
+
+  StringBuffer allMoves(Board b) {
     if (b.prev == null)
       return new StringBuffer();
     return allMoves(b.prev).append(b).append(", ");
   }
 
 
+  public void stats() {
+    System.out.println("Start pos: " + missing);
+    System.out.println("# of Solutions per remaining pins (0..14): " + Arrays.toString(solutions));
+    System.out.println("total # Solutions: " + Arrays.stream(solutions).sum());
+    System.out.println("# of 'One remaining pin' Solutions: " + solutions[1]);
+    System.out.println("% of 'One remaining pin' per total: " + (double) solutions[1]
+        / Arrays.stream(solutions).sum());
+    System.out.println("# Boards: " + numBoards);
+    System.out.println();
+  }
+
+
   // layout
   // 
   //       x
@@ -154,46 +180,24 @@
   //    x x x x
   //   x x x x x
   //
+  // Board position ids (for moves):
+  // 
   //        0
-  //       1 2
-  //      3 4 5
-  //     6 7 8 9 
+  //       1  2
+  //     3  4  5
+  //   6  7  8  9 
   // 10 11 12 13 14
   //
   public static void main(String[] args) {
     CheckPointing cp = new CheckPointing();
     cp.check("start");
-    for (int i = 0; i < 15; i++) {
-      m(i);
+    for (int missing = 0; missing < 15; missing++) {
+      Solitaire s = new Solitaire(missing);
+      s.solveAll();
+      s.stats();
     }
     cp.check("done");
     System.out.println(cp);
   }
 
-
-  public static void m(int i) {
-
-    boolean[] start = new boolean[]{
-      true,
-      true, true,
-      true, true, true,
-      true, true, true, true,
-      true, true, true, true, true
-    };
-
-    start[i] = false;
-
-    init();
-    Board b = new Board(start, 0, 0, null);
-    solve(b);
-
-    System.out.println("start pos: " + i);
-    System.out.println("# of Solutions per remaining pins (0..14): " + Arrays.toString(solutions));
-    System.out.println("total # Solutions: " + Arrays.stream(solutions).sum());
-    System.out.println("# of 'One remaining pin' Solutions: " + solutions[1]);
-    System.out.println("% of 'One remaining pin' per total: " + (double) solutions[1] / (double) Arrays.stream(solutions).sum());
-    System.out.println("Boards created on the way: " + boards);
-    System.out.println();
-  }
-
 }

src/java/m/example/stats/V1_0.java

@@ -20,44 +20,47 @@
 @Path("m/stats/1.0")
 public class V1_0 extends csip.ModelDataService {
 
-    // this is comment.
-  
-    @Override
-    protected void doProcess() throws Exception {
-        
-        List<Double> l = new ArrayList<>();
-        
-        JSONArray v = parameter().getJSONArray("result");
-        JSONObject ts = v.getJSONObject(0);
-        JSONArray a = ts.getJSONArray("data");
-        for (int i = 0; i < a.length(); i++) {
-            JSONArray elem = a.getJSONArray(i);
-            l.add(elem.getDouble(1));
-        }
-        
-        double[] vals = toDoubleArray(l);
-        System.out.println(l);
-        
-        Stats s = Stats.of(vals);
-        Map<Integer, Double> uncertResult = Quantiles.quartiles().indexes(0, 1, 2, 3, 4).compute(vals);
-        double min = uncertResult.get(0);
-        double q1 = uncertResult.get(1);
-        double med = uncertResult.get(2);
-        double q3 = uncertResult.get(3);
-        double max = uncertResult.get(4);
-        
-        results().put("mean", s.mean(),"Mean");
-        results().put("count", s.count(),"Count");
-        results().put("pop_stdev", s.populationStandardDeviation(), "populationStandardDeviation");
-        results().put("pop_var", s.populationVariance(), "populationVariance");
-        results().put("min", min,"minimum");
-        results().put("q1", q1,"1st Quartile");
-        results().put("median", med,"Median");
-        results().put("q3", q3,"3nd Quartile");
-        results().put("max", max,"maximum");
+  // this is comment.
+  @Override
+  protected void doProcess() throws Exception {
+
+    List<Double> l = new ArrayList<>();
+
+    JSONArray v = parameter().getJSONArray("result");
+    JSONObject ts = v.getJSONObject(0);
+    JSONArray a = ts.getJSONArray("data");
+    for (int i = 0; i < a.length(); i++) {
+      JSONArray elem = a.getJSONArray(i);
+      l.add(elem.getDouble(1));
     }
-    
-    public static double[] toDoubleArray(List<Double> data) {
-        return data.stream().mapToDouble(Double::doubleValue).toArray();
-    }
+
+    double[] vals = toDoubleArray(l);
+    System.out.println(l);
+
+    Stats s = Stats.of(vals);
+    Map<Integer, Double> uncertResult = Quantiles.quartiles().indexes(0, 1, 2, 3, 4).compute(vals);
+    double min = uncertResult.get(0);
+    double q1 = uncertResult.get(1);
+    double med = uncertResult.get(2);
+    double q3 = uncertResult.get(3);
+    double max = uncertResult.get(4);
+
+    int i = 0;
+//    for (i = 0; i < 100000; i++) {
+      results().put("mean" + i , s.mean(), "Mean");
+      results().put("count"+ i, s.count(), "Count");
+      results().put("pop_stdev+ i", s.populationStandardDeviation(), "populationStandardDeviation");
+      results().put("pop_var"+ i, s.populationVariance(), "populationVariance");
+      results().put("min"+ i, min, "minimum");
+      results().put("q1"+ i, q1, "1st Quartile");
+      results().put("median"+ i, med, "Median");
+      results().put("q3"+ i, q3, "3nd Quartile");
+      results().put("max"+ i, max, "maximum");
+//    }
+  }
+
+
+  public static double[] toDoubleArray(List<Double> data) {
+    return data.stream().mapToDouble(Double::doubleValue).toArray();
+  }
 }