SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DigitalNetSearch.java
1/*
2 * Class: DigitalNetSearch
3 * Description:
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2018 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author Maxime Godin and Pierre Marion
9 * @since August 2018
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25
26package umontreal.ssj.latnetbuilder;
27
28import umontreal.ssj.hups.DigitalNetBase2;
29import java.util.ArrayList;
30
34public class DigitalNetSearch extends Search {
35
39 protected class DigitalNetBase2FromLatNetBuilder extends DigitalNetBase2 {
40
41 public DigitalNetBase2FromLatNetBuilder(int numRows, int numCols, int dim, int interlacing, int[][][] matrices) {
42 if (numRows > MAXBITS || numCols > MAXBITS)
43 throw new RuntimeException(
44 String.format("SSJ cannot handle matrices with more than %d rows or columns.", MAXBITS));
45 this.numCols = numCols;
46 this.numRows = numRows;
47 this.numPoints = 1 << this.numCols;
48 this.dim = dim;
49 this.outDigits = MAXBITS;
50 this.normFactor = 1.0 / ((double) (1L << this.outDigits));
51 this.interlacing = interlacing;
52
54 }
55 }
56
57 String construction;
58 int interlacing;
59
66 public DigitalNetSearch(String construction) {
67 super();
68 this.construction = construction;
69 this.interlacing = 1;
70 }
71
75 @Override
76 public DigitalNetBase2 search() throws RuntimeException {
77 ArrayList<String> res = executeCommandLine();
78 int numCols = Integer.parseInt(res.get(0).split(" //")[0]);
79 int numRows = Integer.parseInt(res.get(1).split(" //")[0]);
80 int interlacing = Integer.parseInt(res.get(4).split(" //")[0]);
81 int dimension = Integer.parseInt(res.get(3).split(" //")[0]);
82
83 int[][][] mats = new int[dimension][numRows][numCols];
84 for (int coord = 0; coord < dimension; ++coord) {
85 for (int row = 0; row < numRows; ++row) {
86 String[] tmp = res.get(coord * (numRows + 1) + row + offsetForParsingGeneratingMatrix(dimension))
87 .split(" ");
88 for (int col = 0; col < numCols; ++col) {
89 mats[coord][row][col] = Integer.parseInt(tmp[col]);
90 }
91 }
92 }
93
94 this.merit = Double.parseDouble(res.get(res.size() - 2).split(" //")[0]);
95 this.time = Double.parseDouble(res.get(res.size() - 1).split(" //")[0]);
96 this.successful = true;
97
98 return new DigitalNetBase2FromLatNetBuilder(numRows, numCols, dimension, interlacing, mats);
99 }
100
104 private int offsetForParsingGeneratingMatrix(int dimension) {
105 if (construction.equals("sobol")) {
106 return 7 + dimension;
107 } else if (construction.equals("explicit")) {
108 return 7;
109 } else {
110 return 8 + dimension;
111 }
112 }
113
117 @Override
118 public String pointSetType() {
119 return "net";
120 }
121
125 @Override
126 public String interlacing() {
127 return String.valueOf(interlacing);
128 }
129
135 public void setInterlacing(String interlacing) {
136 this.interlacing = Integer.parseInt(interlacing);
137 }
138
142 @Override
143 public String construction() {
144 return construction;
145 }
146
153 public void setConstruction(String construction) {
154 this.construction = construction;
155 }
156
157}
A special case of DigitalNet for the base .
void genMatricesFromBitByBitFormat(int[][][] matrices)
Reverse of the previous function.
static final int MAXBITS
Since Java has no unsigned type, the 32nd bit cannot be used efficiently, so we have only 31 bits.
int dim
Dimension of the points.
DigitalNetBase2 search()
Executes the search and returns the corresponding point set.
String interlacing()
Returns the interlacing factor of the search.
DigitalNetSearch(String construction)
Constructor.
void setConstruction(String construction)
Sets the construciton method of the searched digital net.
String pointSetType()
Returns the type of the searched point set.
void setInterlacing(String interlacing)
Sets the interlacing factor of the searched digital net.
ArrayList< String > executeCommandLine()
Executes the command-line and reads the content of the outputMachine.txt file.
Definition Search.java:139