~ubuntu-branches/ubuntu/vivid/elki/vivid

« back to all changes in this revision

Viewing changes to src/de/lmu/ifi/dbs/elki/index/lsh/hashfamilies/AbstractHashFunctionFamily.java

  • Committer: Package Import Robot
  • Author(s): Erich Schubert
  • Date: 2014-01-22 16:23:20 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140122162320-dtqtgcdiki8t9unc
Tags: 0.6.0-1
* New upstream final.
* 3DPC extension is not included, but may be uploaded as a separate
  package when there is actual need (it is a demo software, not meant
  for use outside of research, so just get the source code!)
* Upgrade to policy 3.9.5.0 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
import de.lmu.ifi.dbs.elki.utilities.RandomFactory;
38
38
import de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizer;
39
39
import de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionID;
40
 
import de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.GreaterConstraint;
 
40
import de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.CommonConstraints;
41
41
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization;
42
42
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.DoubleParameter;
43
43
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.IntParameter;
89
89
  public ArrayList<? extends LocalitySensitiveHashFunction<? super NumberVector<?>>> generateHashFunctions(Relation<? extends NumberVector<?>> relation, int l) {
90
90
    int dim = RelationUtil.dimensionality(relation);
91
91
    ArrayList<LocalitySensitiveHashFunction<? super NumberVector<?>>> ps = new ArrayList<>(l);
92
 
    final Random rnd = random.getRandom();
93
 
    for (int i = 0; i < l; i++) {
 
92
    final Random rnd = random.getSingleThreadedRandom();
 
93
    for(int i = 0; i < l; i++) {
94
94
      RandomProjectionFamily.Projection mat = proj.generateProjection(dim, k);
95
95
      ps.add(new MultipleProjectionsLocalitySensitiveHashFunction(mat, width, rnd));
96
96
    }
144
144
    protected void makeOptions(Parameterization config) {
145
145
      super.makeOptions(config);
146
146
      RandomParameter randP = new RandomParameter(RANDOM_ID, RandomFactory.DEFAULT);
147
 
      if (config.grab(randP)) {
 
147
      if(config.grab(randP)) {
148
148
        random = randP.getValue();
149
149
      }
150
150
 
151
151
      DoubleParameter widthP = new DoubleParameter(WIDTH_ID);
152
 
      widthP.addConstraint(new GreaterConstraint(0.0));
153
 
      if (config.grab(widthP)) {
 
152
      widthP.addConstraint(CommonConstraints.GREATER_THAN_ZERO_DOUBLE);
 
153
      if(config.grab(widthP)) {
154
154
        width = widthP.doubleValue();
155
155
      }
156
156
 
157
157
      IntParameter lP = new IntParameter(NUMPROJ_ID);
158
 
      lP.addConstraint(new GreaterConstraint(0));
159
 
      if (config.grab(lP)) {
 
158
      lP.addConstraint(CommonConstraints.GREATER_EQUAL_ONE_INT);
 
159
      if(config.grab(lP)) {
160
160
        k = lP.intValue();
161
161
      }
162
162
    }