Subversion Repositories distributed

Compare Revisions

No changes between revisions

Ignore whitespace Rev 48 → Rev 49

/ViaThinkSoft Distributed/test/de/viathinksoft/marschall/raumplan/formula/FormulaProbeTest.java
0,0 → 1,68
package de.viathinksoft.marschall.raumplan.formula;
 
import static org.junit.Assert.*;
 
import org.junit.Test;
 
public class FormulaProbeTest {
 
@Test
public void GeneralTests() throws SelfTestException, InvalidValException {
assertTrue(nearlyEquals(FormulaProbe.b_star(), 0.6823278038280193));
assertTrue(nearlyEquals(FormulaProbe.g_star(), 0.3819660112501051));
assertTrue(nearlyEquals(FormulaProbe.w_star(), 0.2838458789785244));
 
assertTrue(nearlyEquals(FormulaProbe.w_star(), FormulaProbe.w23(
FormulaProbe.b_star(), FormulaProbe.g_star())));
assertTrue(nearlyEquals(FormulaProbe.w_star(), FormulaProbe.w3(
FormulaProbe.b_star(), FormulaProbe.g_star())));
 
assertTrue(nearlyEquals(0.0, FormulaProbe.K2(0.5, 0.5, 0.5)));
assertFalse(nearlyEquals(0.0, FormulaProbe.K3(0.5, 0.5, 0.5)));
 
assertTrue(nearlyEquals(0.0, FormulaProbe.K2(0.0, 0.5, 0.375)));
assertFalse(nearlyEquals(0.0, FormulaProbe.K3(0.0, 0.5, 0.375)));
 
assertTrue(nearlyEquals(0.0, FormulaProbe.K2(FormulaProbe.b_star(),
FormulaProbe.g_star(), FormulaProbe.w_star())));
assertTrue(nearlyEquals(0.0, FormulaProbe.K3(FormulaProbe.b_star(),
FormulaProbe.g_star(), FormulaProbe.w_star())));
 
for (double i = 0; i < 0.99; i += 0.01) {
assertTrue(nearlyEquals(0.0, FormulaProbe.K2(FormulaProbe.b_star(),
FormulaProbe.g_star(), i)));
assertFalse(nearlyEquals(0.0, FormulaProbe.K3(
FormulaProbe.b_star(), FormulaProbe.g_star(), i)));
}
 
// w23test(0.2, 0.7); // TODO
w23test(FormulaProbe.b_star(), FormulaProbe.g_star());
w3test(FormulaProbe.b_star(), FormulaProbe.g_star());
w2test(0.5, 0.5);
w3test(0.6, 0.6);
}
 
private static void w23test(double b, double g) throws SelfTestException,
InvalidValException {
double w = FormulaProbe.w23(b, g);
assertTrue(nearlyEquals(0.0, FormulaProbe.K2(b, g, w)));
assertTrue(nearlyEquals(0.0, FormulaProbe.K3(b, g, w)));
}
 
private static void w2test(double b, double g) throws SelfTestException,
InvalidValException {
double w = FormulaProbe.w2(b, g);
assertTrue(nearlyEquals(0.0, FormulaProbe.K2(b, g, w)));
}
 
private static void w3test(double b, double g) throws SelfTestException,
InvalidValException {
double w = FormulaProbe.w3(b, g);
assertTrue(nearlyEquals(0.0, FormulaProbe.K3(b, g, w)));
}
 
private static boolean nearlyEquals(double a, double b) {
return Math.abs(Math.abs(a) - Math.abs(b)) < 0.0000000000001;
}
 
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/ViaThinkSoft Distributed/src/de/viathinksoft/marschall/raumplan/formula/InvalidValException.java
0,0 → 1,7
package de.viathinksoft.marschall.raumplan.formula;
 
public class InvalidValException extends Exception {
 
private static final long serialVersionUID = 7819713196701732155L;
 
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/ViaThinkSoft Distributed/src/de/viathinksoft/marschall/raumplan/formula/SelfTestException.java
0,0 → 1,7
package de.viathinksoft.marschall.raumplan.formula;
 
public class SelfTestException extends Exception {
 
private static final long serialVersionUID = 4402817473129146410L;
 
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/ViaThinkSoft Distributed/src/de/viathinksoft/marschall/raumplan/formula/FormulaProbe.java
2,44 → 2,19
 
public class FormulaProbe {
 
protected static double round(double value, int decimalPlace) {
if (value < 0) {
// positive value only.
return -round(-value, decimalPlace);
}
 
double power_of_ten = 1;
// floating point arithmetic can be very tricky.
// that's why I introduce a "fudge factor"
double fudge_factor = 0.05;
while (decimalPlace-- > 0) {
power_of_ten *= 10.0d;
fudge_factor /= 10.0d;
}
return Math.round((value + fudge_factor) * power_of_ten) / power_of_ten;
}
 
protected static String roundu(double value) {
if (Math.abs(value) < 0.000000000000001) {
// return "<0.000000000000001";
return "0";
}
return "" + round(value, 17);
}
 
protected static boolean nearlyEqual(double a, double b) {
private static boolean nearlyEqual(double a, double b) {
return Math.abs(Math.abs(a) - Math.abs(b)) < 0.0000000000001;
}
 
protected static double pow(double x, double y) {
private static double pow(double x, double y) {
return Math.pow(x, y);
}
 
protected static double sqrt(double x) {
private static double sqrt(double x) {
return Math.pow(x, 1.0 / 2.0);
}
 
protected static double sqrt3(double x) {
private static double sqrt3(double x) {
if (x >= 0)
return Math.pow(x, 1.0 / 3.0);
else
57,16 → 32,16
+ sqrt3(0.5 - sqrt(31.0 / 108.0));
}
 
public static double w2(double b, double g) {
public static double w2(double b, double g) throws InvalidValException {
if (nearlyEqual(b, b_star())) {
System.out.println("FATAL: w2(b*) is Lambda!");
return Double.NaN;
throw new InvalidValException();
}
 
if (!((g <= g_star()) && (b > b_star()) || (g >= g_star())
&& (b < b_star()))) {
System.out.println("w ist nicht definiert für b=" + b + "; g=" + g);
return Double.NaN;
throw new InvalidValException();
}
 
return (double) ((1 - b) * (g + 1) * (pow(g, 2) - 3 * g + 1))
73,7 → 48,8
/ (2 * (1 - g) * (pow(b, 3) + b - 1));
}
 
public static double K2(double b, double g, double w) {
public static double K2(double b, double g, double w)
throws SelfTestException {
// Vor Umstellung
double res = (double) (3 - g) / (1 - g) - g + pow(g, 2) - 4 + 2 * w
* (b / (1 - b) - b - pow(b, 2) - 1);
87,7 → 63,7
System.out.println("Fatal in K2");
System.out.println(res);
System.out.println(res2);
System.exit(1);
throw new SelfTestException();
}
 
return res;
96,10 → 72,10
 
// Seite 2
 
public static double X(double b, double g) {
public static double X(double b, double g) throws InvalidValException {
if (nearlyEqual(b, b_star())) {
System.out.println("FATAL: X(b,g) may not have b*");
return Double.NaN;
throw new InvalidValException();
}
 
return (g + 1) * (pow(g, 2) - 3 * g + 1) * (1 - b + pow(b, 4)) - 2
112,7 → 88,12
* pow((pow(b, 3) + b - 1), 2);
}
 
public static double w23(double b, double g) {
public static double b_star_star() {
return 0.724492; // TODO
}
 
public static double w23(double b, double g) throws SelfTestException,
InvalidValException {
if (nearlyEqual(b, b_star()))
return w3(b, g);
 
121,24 → 102,34
 
if (dec1 != dec2) {
System.out.println("FATAL: X(b,g) ist falsch");
System.exit(1);
return Double.NaN;
throw new SelfTestException();
}
 
if (!dec1) {
System.out.println("w23 ist nicht definiert für b=" + b + "; g="
+ g);
return Double.NaN;
throw new InvalidValException();
} else {
return w3(b, g); // == w2(b,g)
}
}
 
public static double w3(double b, double g) {
return (double) (pow(g, 3) * (1 - b)) / ((1 - g) * (1 - b + pow(b, 4)));
public static double w3(double b, double g) throws InvalidValException {
if (nearlyEqual(b, b_star_star())) {
System.out.println("FATAL: w3(b**) is Lambda!");
throw new InvalidValException();
}
 
if (b > b_star_star()) {
System.out.println("FATAL: w3(b B b**) < 0!");
throw new InvalidValException();
}
 
return (double) (pow(g, 3) * (1 - b)) / ((1 - g) * (1 - b - pow(b, 4)));
}
 
public static double K3(double b, double g, double w) {
public static double K3(double b, double g, double w)
throws SelfTestException {
// Vor Umstellung
double res = (1.0 / (1 - g)) - g - pow(g, 2) - 1 - w + b * w
* ((1.0 / (1 - b)) - b - pow(b, 2) - 1);
153,80 → 144,29
System.out.println("Fatal in K3");
System.out.println(res);
System.out.println(res2);
System.exit(1);
throw new SelfTestException();
}
 
return res;
}
 
public static double w_star() {
public static double w_star() throws SelfTestException, InvalidValException {
double res = (double) (pow(3 - sqrt(5), 3) * (1 - sqrt3(0.5 + sqrt(31.0 / 108.0)) - sqrt3(0.5 - sqrt(31.0 / 108.0))))
/ (8 * (1 - (double) (3 - sqrt(5)) / 2) * (1
- sqrt3(0.5 + sqrt(31.0 / 108.0))
- sqrt3(0.5 - sqrt(31.0 / 108.0)) + pow(
- sqrt3(0.5 - sqrt(31.0 / 108.0)) - pow(
sqrt3(0.5 + sqrt(31.0 / 108.0))
+ sqrt3(0.5 - sqrt(31.0 / 108.0)), 4)));
double res2 = w3(b_star(), g_star());
 
if (!nearlyEqual(res, w3(b_star(), g_star()))) {
if (!nearlyEqual(res, res2)) {
System.out.println("Self test for w_star() failed!");
System.exit(1);
return Double.NaN;
System.out.println(res);
System.out.println(res2);
throw new SelfTestException();
}
 
return res;
}
 
/**
* @param args
*/
public static void main(String[] args) {
// vereinfachte K2 prüfen
// vereinfachte K3 prüfen (???)
// Die Formel w2 prüfen
// Die Formel w3 prüfen
// Die Formeln w2,3 numerisch prüfen: Ist 2D=3D=0?
// für b=b*
// für b!=b*
// b* g* lambda prüfen: Ist 2D=3D=0
// b* g* [irgendwas] prüfen: ist 2D=0 und 3D!=0?
 
System.out.println("b* = " + roundu(b_star()));
System.out.println("g* = " + roundu(g_star()));
System.out.println("w* = " + roundu(w_star()));
System.out.println("w23(b*, g*) = " + roundu(w23(b_star(), g_star())));
System.out.println("w3(b*, g*) = " + roundu(w3(b_star(), g_star())));
System.out.println("K2(.5 .5 .5) = " + roundu(K2(0.5, 0.5, 0.5)));
System.out.println("K3(.5 .5 .5) = " + roundu(K3(0.5, 0.5, 0.5)));
System.out.println("K2(0 .5 .375) = " + roundu(K2(0.0, 0.5, 0.375)));
System.out.println("K3(0 .5 .375) = " + roundu(K3(0.0, 0.5, 0.375)));
System.out.println("K2(b*, g*, 0.0) = "
+ roundu(K2(b_star(), g_star(), 0.0)));
System.out.println("K2(b*, g*, 0.1) = "
+ roundu(K2(b_star(), g_star(), 0.1)));
System.out.println("K2(b*, g*, 0.3) = "
+ roundu(K2(b_star(), g_star(), 0.3)));
System.out.println("K2(b*, g*, 0.5) = "
+ roundu(K2(b_star(), g_star(), 0.5)));
System.out.println("K2(b*, g*, 0.7) = "
+ roundu(K2(b_star(), g_star(), 0.7)));
System.out.println("K2(b*, g*, 0.99) = "
+ roundu(K2(b_star(), g_star(), 0.99)));
System.out.println("K2(b*, g*, w*) = "
+ roundu(K2(b_star(), g_star(), w_star())));
System.out.println("K3(b*, g*, w*) = "
+ roundu(K3(b_star(), g_star(), w_star())));
 
// w23test(0.2, 0.7);
w23test(b_star(), g_star());
}
 
protected static void w23test(double b, double g) {
double w = w23(b, g);
System.out.println("w23(" + b + " " + g + ") = " + roundu(w));
System.out.println("K2(" + b + " " + g + " " + w + ") = "
+ roundu(K2(b, g, w)));
System.out.println("K3(" + b + " " + g + " " + w + ") = "
+ roundu(K3(b, g, w)));
}
 
}
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/InvalidLengthException.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/ImmortableWriter.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/Gen2Test.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/ImmortableTest.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/Immortable.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/erkenntnisse
File deleted
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/CoPrimeExpectedException.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/CRTNotSolveableException.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/CRTException.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/ExtEuclResult.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/RemainderNotSmallerThanModulusException.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/MathUtils.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/MathUtils2Test.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/MathUtils2.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/immortable/gen2/math/DivisionAndRemainderResult.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/test/pirnd/TranszedentRnd.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/test/pirnd/EDigits.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/test/pirnd/DigitIterator.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/test/pirnd/TestRndPi.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property
/ViaThinkSoft Distributed/bin/de/viathinksoft/test/pirnd/PiDigits.class
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Deleted: svn:mime-type
-application/octet-stream
\ No newline at end of property