Skip to content

Commit 7074fbc

Browse files
committed
#111 Fix output of LCG to be in the desired range
1 parent 7781ef5 commit 7074fbc

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/main/java/org/encog/mathutil/LinearCongruentialGenerator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public LinearCongruentialGenerator(final long theModulus,
117117
this.modulus = theModulus;
118118
this.multiplier = theMultiplier;
119119
this.increment = theIncrement;
120-
this.seed = theSeed;
120+
this.seed = theSeed%MAX_RAND;
121121
}
122122

123123
/**
@@ -188,7 +188,7 @@ public final double range(final double min, final double max) {
188188
* The seed value.
189189
*/
190190
public final void setSeed(final long theSeed) {
191-
this.seed = theSeed;
191+
this.seed = theSeed%MAX_RAND;
192192
}
193193

194194
}

src/main/java/org/encog/ml/prg/extension/StandardExtensions.java

+24
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ public ExpressionValue evaluate(ProgramNode actual) {
126126
}
127127
};
128128

129+
/**
130+
* Standard boolean binary and operator.
131+
*/
132+
public static ProgramExtensionTemplate EXTENSION_NOT = new BasicTemplate(3, "!", NodeType.Unary, false, 0, 1) {
133+
@Override
134+
public ExpressionValue evaluate(ProgramNode actual) {
135+
return new ExpressionValue(
136+
!actual.getChildNode(0).evaluate().toBooleanValue());
137+
}
138+
};
139+
129140
/**
130141
* Standard boolean binary or operator.
131142
*/
@@ -148,6 +159,19 @@ public ExpressionValue evaluate(ProgramNode actual) {
148159
return new ExpressionValue( diff<Encog.DEFAULT_DOUBLE_EQUAL);
149160
}
150161
};
162+
163+
/**
164+
* Standard boolean binary equal operator.
165+
*/
166+
public static ProgramExtensionTemplate EXTENSION__NOT_EQUAL = new BasicTemplate(9, "<>", NodeType.OperatorRight, false, 0, 2) {
167+
@Override
168+
public ExpressionValue evaluate(ProgramNode actual) {
169+
double diff = Math.abs(actual.getChildNode(0).evaluate().toFloatValue() - actual.getChildNode(1).evaluate().toFloatValue());
170+
return new ExpressionValue( diff>Encog.DEFAULT_DOUBLE_EQUAL);
171+
}
172+
};
173+
174+
151175
/**
152176
* Standard boolean binary greater than operator.
153177
*/

0 commit comments

Comments
 (0)