diff --git a/ea/Ub7/PBIL/src/PBIL.java b/ea/Ub7/PBIL/src/PBIL.java index f24cd26..0b99483 100644 --- a/ea/Ub7/PBIL/src/PBIL.java +++ b/ea/Ub7/PBIL/src/PBIL.java @@ -48,10 +48,6 @@ this.m_Mu = mu; this.m_OptimizationSteps = optimizationSteps; this.m_MultiRuns = multiRuns; - this.propVector = new double[m_GenotypeLength]; - for (int i = 0; i < propVector.length; i++) { - propVector[i] = 0.5; - } // this.learnrate = 1 / lambda; this.learnrate = 0.05; @@ -64,6 +60,10 @@ public void initialize() { m_OptimizationStepsNeeded = 0; + this.propVector = new double[m_GenotypeLength]; + for (int i = 0; i < propVector.length; i++) { + propVector[i] = 0.5; + } } @@ -82,11 +82,7 @@ Collections.sort(population, Collections.reverseOrder()); // comparable // implemente // in - // PBilIndividual m_population = - // m_population.subList(0, m_Mu); - // for (int j = 0; j < population.size(); j++) { - // System.out.println(population.get(j).getStringRepresentation()); - // } + List m_Best = population.subList(0, m_Mu); // System.out.println("Print best:"); // System.out.println(m_Best.get(0).getStringRepresentation()); @@ -101,10 +97,12 @@ for (double p : propVector) { fitnessPV += p; } - meanFitness = fitnessPV; - if (fitnessPV != propVector.length) { + double oldFitness = meanFitness; + meanFitness = propVector.length - fitnessPV; + if (oldFitness != meanFitness) { m_OptimizationStepsNeeded++; } + // System.out.println(i + " " + meanFitness); } } @@ -123,7 +121,7 @@ int lambda = 50; int optimizationSteps = 1000; // int optimizationSteps = 100; - int multiRuns = 1000; + int multiRuns = 100; PBIL program = new PBIL(genotypeLength, mu, lambda, optimizationSteps, multiRuns); int TmpMeanCalls = 0, TmpMeanFitness = 0; diff --git a/ea/Ub7/PBIL/src/gen/GeneticAlgorithm.java b/ea/Ub7/PBIL/src/gen/GeneticAlgorithm.java index a331e20..7c5d84e 100644 --- a/ea/Ub7/PBIL/src/gen/GeneticAlgorithm.java +++ b/ea/Ub7/PBIL/src/gen/GeneticAlgorithm.java @@ -122,7 +122,7 @@ if (m_Best.evaluateAsMaxiBits() != 0) { m_OptimizationStepsNeeded++; } - + System.out.println(i + " " + (m_Best.evaluateAsMaxiBits())); } } @@ -140,7 +140,7 @@ int lambda = 50; // int optimizationSteps = 100000; int optimizationSteps = 1000; - int multiRuns = 1000; + int multiRuns = 1; GeneticAlgorithm program = new GeneticAlgorithm(genotypeLength, mu, lambda, optimizationSteps, multiRuns); int TmpMeanCalls = 0, TmpMeanFitness = 0; diff --git a/ea/Ub7/PBIL/src/gen/HillClimbing.java b/ea/Ub7/PBIL/src/gen/HillClimbing.java new file mode 100644 index 0000000..86c07bf --- /dev/null +++ b/ea/Ub7/PBIL/src/gen/HillClimbing.java @@ -0,0 +1,94 @@ +package gen; + +public class HillClimbing { + /** The length of the genotype of the individuals **/ + private int m_GenotypeLength; + /** The number of single optimization steps to be evaluated **/ + private int m_OptimizationSteps; + /** The number of times the experiment is repeated **/ + private int m_MultiRuns; + /** Number of steps needed to reach best result **/ + private int m_OptimizationStepsNeeded = 0; + /** Current best individual **/ + private GAIndividual m_Best; + + /** + * This constructor sets up HillClimber + * + * @param genotypeLength + * The length of the genotype of the individuals + * @param optimizationSteps + * The number of single optimization steps to be evaluated + * (adjust as necessary) + * @param multiRuns + * The number of times the experiment is repeated (at least 10) + */ + public HillClimbing(int genotypeLength, int optimizationSteps, int multiRuns) { + assert multiRuns > 9; + this.m_GenotypeLength = genotypeLength; + this.m_OptimizationSteps = optimizationSteps; + this.m_MultiRuns = multiRuns; + } + + /** + * This method will initialize the HillClimber + */ + public void initialize() { + m_Best = new GAIndividual(m_GenotypeLength); + m_OptimizationStepsNeeded = 0; + } + + /** + * This method will optimize the defaultEvaulateAsMiniBits Problem. Use + * m_FitnessCallsNeeded to return the number of FitnessCalls (e.g., calling + * evaluateAsMaxiBits()) needed to find the optimum. The optimization should + * terminate after m_FitnessCalls. + */ + public void optimize() { + // nur mutieren oder auch crossover? + + // TODO implement this + // use GAIndividual.evaluateAsMaxiBits() to evaluate the fitness of an + // individual and call it m_OptimizationSteps times before terminating + for (int i = 0; i < m_OptimizationSteps; i++) { + GAIndividual clone = (GAIndividual) m_Best.clone(); + clone.mutate(); + m_Best = clone.evaluateAsMaxiBits() <= m_Best.evaluateAsMaxiBits() ? clone + : m_Best; + + if (m_Best.evaluateAsMaxiBits() != 0) { + m_OptimizationStepsNeeded++; + } + } + } + + /** + * This main method will start a simple hill climber. No arguments + * necessary. + * + * @param args + */ + public static void main(String[] args) { + // TODO: parameters for the HillClimber, adjust these values as + // necessary + int genotypeLength = 50; + int optimizationSteps = 1000; + int multiRuns = 100; + HillClimbing program = new HillClimbing(genotypeLength, + optimizationSteps, multiRuns); + int TmpMeanCalls = 0, TmpMeanFitness = 0; + // perform repeated optimization + for (int i = 0; i < program.m_MultiRuns; i++) { + program.initialize(); + program.optimize(); + TmpMeanCalls += program.m_OptimizationStepsNeeded; + TmpMeanFitness += program.m_Best.evaluateAsMaxiBits(); + + } + TmpMeanCalls = TmpMeanCalls / program.m_MultiRuns; + TmpMeanFitness = TmpMeanFitness / program.m_MultiRuns; + System.out.println("(" + program.m_MultiRuns + "/" + + program.m_OptimizationSteps + ") Mean Fitness : " + + TmpMeanFitness + " Mean Calls needed: " + TmpMeanCalls); + } +} diff --git a/ea/Ub7/PBIL/src/genTwin/HillClimbingTwin.java b/ea/Ub7/PBIL/src/genTwin/HillClimbingTwin.java new file mode 100644 index 0000000..1918455 --- /dev/null +++ b/ea/Ub7/PBIL/src/genTwin/HillClimbingTwin.java @@ -0,0 +1,95 @@ +package genTwin; + +public class HillClimbingTwin { + /** The length of the genotype of the individuals **/ + private int m_GenotypeLength; + /** The number of single optimization steps to be evaluated **/ + private int m_OptimizationSteps; + /** The number of times the experiment is repeated **/ + private int m_MultiRuns; + /** Number of steps needed to reach best result **/ + private int m_OptimizationStepsNeeded = 0; + /** Current best individual **/ + private GAIndividualTwin m_Best; + + /** + * This constructor sets up HillClimber + * + * @param genotypeLength + * The length of the genotype of the individuals + * @param optimizationSteps + * The number of single optimization steps to be evaluated + * (adjust as necessary) + * @param multiRuns + * The number of times the experiment is repeated (at least 10) + */ + public HillClimbingTwin(int genotypeLength, int optimizationSteps, + int multiRuns) { + assert multiRuns > 9; + this.m_GenotypeLength = genotypeLength; + this.m_OptimizationSteps = optimizationSteps; + this.m_MultiRuns = multiRuns; + } + + /** + * This method will initialize the HillClimber + */ + public void initialize() { + m_Best = new GAIndividualTwin(m_GenotypeLength); + m_OptimizationStepsNeeded = 0; + } + + /** + * This method will optimize the defaultEvaulateAsMiniBits Problem. Use + * m_FitnessCallsNeeded to return the number of FitnessCalls (e.g., calling + * evaluateAsMaxiBits()) needed to find the optimum. The optimization should + * terminate after m_FitnessCalls. + */ + public void optimize() { + // nur mutieren oder auch crossover? + + // TODO implement this + // use GAIndividual.evaluateAsMaxiBits() to evaluate the fitness of an + // individual and call it m_OptimizationSteps times before terminating + for (int i = 0; i < m_OptimizationSteps; i++) { + GAIndividualTwin clone = (GAIndividualTwin) m_Best.clone(); + clone.mutate(); + m_Best = clone.evaluateAsTwin() <= m_Best.evaluateAsTwin() ? clone + : m_Best; + + if (m_Best.evaluateAsTwin() != 0) { + m_OptimizationStepsNeeded++; + } + } + } + + /** + * This main method will start a simple hill climber. No arguments + * necessary. + * + * @param args + */ + public static void main(String[] args) { + // TODO: parameters for the HillClimber, adjust these values as + // necessary + int genotypeLength = 50; + int optimizationSteps = 1000; + int multiRuns = 100; + HillClimbingTwin program = new HillClimbingTwin(genotypeLength, + optimizationSteps, multiRuns); + int TmpMeanCalls = 0, TmpMeanFitness = 0; + // perform repeated optimization + for (int i = 0; i < program.m_MultiRuns; i++) { + program.initialize(); + program.optimize(); + TmpMeanCalls += program.m_OptimizationStepsNeeded; + TmpMeanFitness += program.m_Best.evaluateAsTwin(); + + } + TmpMeanCalls = TmpMeanCalls / program.m_MultiRuns; + TmpMeanFitness = TmpMeanFitness / program.m_MultiRuns; + System.out.println("(" + program.m_MultiRuns + "/" + + program.m_OptimizationSteps + ") Mean Fitness : " + + TmpMeanFitness + " Mean Calls needed: " + TmpMeanCalls); + } +} diff --git a/ea/Ub7/PBIL/src/twin/PBILTwin.java b/ea/Ub7/PBIL/src/twin/PBILTwin.java index b27cab5..27cd0d3 100644 --- a/ea/Ub7/PBIL/src/twin/PBILTwin.java +++ b/ea/Ub7/PBIL/src/twin/PBILTwin.java @@ -4,7 +4,6 @@ * This class implements a deterministic variant of the Genetic Algorithm described in the script, section 5.1.1. */ import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -52,9 +51,6 @@ this.m_OptimizationSteps = optimizationSteps; this.m_MultiRuns = multiRuns; this.propVector = new double[m_GenotypeLength]; - for (int i = 0; i < propVector.length; i++) { - propVector[i] = 0.5; - } // this.learnrate = 1 / lambda; this.learnrate = 0.05; @@ -67,7 +63,9 @@ public void initialize() { m_OptimizationStepsNeeded = 0; - + for (int i = 0; i < propVector.length; i++) { + propVector[i] = 0.5; + } } /** @@ -78,9 +76,9 @@ */ public void optimize() { for (int i = 0; i < m_OptimizationSteps; i++) { - List population = new ArrayList(); + List population = new ArrayList(); for (int j = 0; j < m_Mu; j++) { - population.add(new PBilIndividualTwin(propVector)); + population.add(new PBIndividualTwin(propVector)); } Collections.sort(population, Collections.reverseOrder()); // comparable // implemente @@ -90,28 +88,28 @@ // for (int j = 0; j < population.size(); j++) { // System.out.println(population.get(j).getStringRepresentation()); // } - List m_Best = population.subList(0, m_Mu); - System.out.println("Print best:"); - System.out.println(m_Best.get(0).getStringRepresentation()); - for (PBilIndividualTwin p : m_Best) { + List m_Best = population.subList(0, m_Mu); + // System.out.println("Print best:"); + // System.out.println(m_Best.get(0).getStringRepresentation()); + for (PBIndividualTwin p : m_Best) { for (int k = 0; k < m_GenotypeLength; k++) { propVector[k] = (propVector[k] * (1 - learnrate)) + ((p.getGenotype().get(k) ? 1 : 0) * learnrate); } } - System.out.println(Arrays.toString(propVector)); + // System.out.println(Arrays.toString(propVector)); double fitnessPV = 0; for (int j = 0; j < propVector.length; j++) { - double p=propVector[j]; - if (j < propVector.length / 2) { + double p = propVector[j]; + if (j < (propVector.length / 2)) { fitnessPV += p; - } - else{ - fitnessPV-=p; + } else { + fitnessPV -= p; } } - meanFitness = Math.abs(fitnessPV); - if (fitnessPV != propVector.length) { + double oldFitness = meanFitness; + meanFitness = (m_GenotypeLength / 2) - Math.abs(fitnessPV); + if (oldFitness != meanFitness) { m_OptimizationStepsNeeded++; } @@ -132,9 +130,9 @@ int lambda = 50; int optimizationSteps = 1000; // int optimizationSteps = 100; - int multiRuns = 1; - PBILTwin program = new PBILTwin(genotypeLength, mu, lambda, optimizationSteps, - multiRuns); + int multiRuns = 100; + PBILTwin program = new PBILTwin(genotypeLength, mu, lambda, + optimizationSteps, multiRuns); int TmpMeanCalls = 0, TmpMeanFitness = 0; // perform repeated optimization for (int i = 0; i < program.m_MultiRuns; i++) { diff --git a/ea/Ub7/PBIL/src/twin/PBIndividualTwin.java b/ea/Ub7/PBIL/src/twin/PBIndividualTwin.java new file mode 100644 index 0000000..7a1fa16 --- /dev/null +++ b/ea/Ub7/PBIL/src/twin/PBIndividualTwin.java @@ -0,0 +1,165 @@ +package twin; + +//import tools.RandomNumberGenerator; + +import java.util.BitSet; +import java.util.Random; + +/** + * @author Maximus + * + */ +public class PBIndividualTwin implements Comparable { + protected BitSet m_Genotype; + protected int m_GenotypeLength; + protected Random r = new Random(); + + /** Constructor **/ + public PBIndividualTwin(double[] propVector) { + // This method should call initGenotype() to initialize the genotype + this.m_GenotypeLength = propVector.length; + initGenotype(propVector); + + } + + /** + * cloning constructor + * + * @param toClone + */ + private PBIndividualTwin(PBIndividualTwin toClone) { + this.m_Genotype = (BitSet) toClone.m_Genotype.clone();// allowed, has + // only native + // typed + // fields + this.m_GenotypeLength = toClone.m_GenotypeLength; + } + + /** + * This method creates a deep copy of an individual. It should clone all + * objects contained by this object. + * + * @return An deep copy of this {@link PBIndividualTwin} + */ + @Override + public Object clone() { + + PBIndividualTwin c = new PBIndividualTwin(new double[m_GenotypeLength]); + c.setGenotype((BitSet) this.m_Genotype.clone()); + return c; + + // return new GAIndividual(this); + } + + /** + * This method evaluates the GAIndividual as a simple + * "maximize number of bits" problem. The fitness is the number of true bits + * in m_Genotype. Best fitness is reached if there are no false bits. + * + * @return The number of false bits (less is better!) + */ + public double evaluateAsMaxiBits() { + int zeros = 0; + for (int i = 0; i < m_GenotypeLength; i++) { + if (!m_Genotype.get(i)) { + zeros++; + } + } + return zeros; + } + + /** + * + * @return best fitness ==0 + */ + public double evaluateAsTwin() { + int f1 = 0; + int f2 = 0; + for (int i = 0; i < (m_GenotypeLength / 2); i++) { + if (m_Genotype.get(i)) { + f1++; + } + } + for (int i = (m_GenotypeLength / 2); i < m_GenotypeLength; i++) { + if (m_Genotype.get(i)) { + f2++; + } + } + return (m_GenotypeLength / 2) - Math.abs(f1 - f2); + } + + /** + * This method will return a string description of the GAIndividal notably + * the genotype: '0011000101' + * + * @return A descriptive string + */ + public String getStringRepresentation() { + // this should return exactly the representation shown in the comment + // above: + // only 0 (for false bits) and 1 (for true bits) with no extra white + // space! + String representation = ""; + for (int i = 0; i < m_GenotypeLength; i++) { + representation = m_Genotype.get(i) ? representation + "1" + : representation + "0"; + + } + return representation; + } + + /** + * This method will allow the user to read the GA genotype + * + * @return BitSet + */ + public BitSet getGenotype() { + return m_Genotype; + } + + /** + * This method will allow the user to set the current GA genotype. Should + * check if the length of the BitSet and the genotype length match. + * + * @param b + * The new genotype of the Individual + */ + public void setGenotype(BitSet b) { + + this.m_Genotype = b; + + } + + /** + * This method allows the user to read the length of the genotype. This may + * be necessary since BitSet.length only returns the index of the last + * significant bit. + * + * @return The length of the genotype. + */ + public int getGenotypeLength() { + return m_GenotypeLength; + } + + /** + * This method initializes the GA genotype randomly. Please use the + * tools.RandomNumberGenerator + * + * @param propVector + */ + public void initGenotype(double[] propVector) { + m_Genotype = new BitSet(m_GenotypeLength); + for (int i = 0; i < m_GenotypeLength; i++) { + if (r.nextDouble() < propVector[i]) { + m_Genotype.set(i); + } + } + } + + @Override + public int compareTo(PBIndividualTwin o) { + // return ((Double) this.evaluateAsMaxiBits()).compareTo(o + // .evaluateAsMaxiBits()); + return ((Double) this.evaluateAsTwin()).compareTo(o.evaluateAsTwin()); + } +} diff --git a/ea/Ub7/PBIL/src/twin/PBilIndividualTwin.java b/ea/Ub7/PBIL/src/twin/PBilIndividualTwin.java deleted file mode 100644 index be2b9eb..0000000 --- a/ea/Ub7/PBIL/src/twin/PBilIndividualTwin.java +++ /dev/null @@ -1,165 +0,0 @@ -package twin; - -//import tools.RandomNumberGenerator; - -import java.util.BitSet; -import java.util.Random; - -/** - * @author Maximus - * - */ -public class PBilIndividualTwin implements Comparable { - protected BitSet m_Genotype; - protected int m_GenotypeLength; - protected Random r = new Random(); - - /** Constructor **/ - public PBilIndividualTwin(double[] propVector) { - // This method should call initGenotype() to initialize the genotype - this.m_GenotypeLength = propVector.length; - initGenotype(propVector); - - } - - /** - * cloning constructor - * - * @param toClone - */ - private PBilIndividualTwin(PBilIndividualTwin toClone) { - this.m_Genotype = (BitSet) toClone.m_Genotype.clone();// allowed, has - // only native - // typed - // fields - this.m_GenotypeLength = toClone.m_GenotypeLength; - } - - /** - * This method creates a deep copy of an individual. It should clone all - * objects contained by this object. - * - * @return An deep copy of this {@link PBilIndividualTwin} - */ - @Override - public Object clone() { - - PBilIndividualTwin c = new PBilIndividualTwin(new double[m_GenotypeLength]); - c.setGenotype((BitSet) this.m_Genotype.clone()); - return c; - - // return new GAIndividual(this); - } - - /** - * This method evaluates the GAIndividual as a simple - * "maximize number of bits" problem. The fitness is the number of true bits - * in m_Genotype. Best fitness is reached if there are no false bits. - * - * @return The number of false bits (less is better!) - */ - public double evaluateAsMaxiBits() { - int zeros = 0; - for (int i = 0; i < m_GenotypeLength; i++) { - if (!m_Genotype.get(i)) { - zeros++; - } - } - return zeros; - } - - /** - * - * @return best fitness ==0 - */ - public double evaluateAsTwin() { - int f1 = 0; - int f2 = 0; - for (int i = 0; i < (m_GenotypeLength / 2); i++) { - if (m_Genotype.get(i)) { - f1++; - } - } - for (int i = (m_GenotypeLength / 2); i < m_GenotypeLength; i++) { - if (m_Genotype.get(i)) { - f2++; - } - } - return (m_GenotypeLength / 2) - Math.abs(f1 - f2); - } - - /** - * This method will return a string description of the GAIndividal notably - * the genotype: '0011000101' - * - * @return A descriptive string - */ - public String getStringRepresentation() { - // this should return exactly the representation shown in the comment - // above: - // only 0 (for false bits) and 1 (for true bits) with no extra white - // space! - String representation = ""; - for (int i = 0; i < m_GenotypeLength; i++) { - representation = m_Genotype.get(i) ? representation + "1" - : representation + "0"; - - } - return representation; - } - - /** - * This method will allow the user to read the GA genotype - * - * @return BitSet - */ - public BitSet getGenotype() { - return m_Genotype; - } - - /** - * This method will allow the user to set the current GA genotype. Should - * check if the length of the BitSet and the genotype length match. - * - * @param b - * The new genotype of the Individual - */ - public void setGenotype(BitSet b) { - - this.m_Genotype = b; - - } - - /** - * This method allows the user to read the length of the genotype. This may - * be necessary since BitSet.length only returns the index of the last - * significant bit. - * - * @return The length of the genotype. - */ - public int getGenotypeLength() { - return m_GenotypeLength; - } - - /** - * This method initializes the GA genotype randomly. Please use the - * tools.RandomNumberGenerator - * - * @param propVector - */ - public void initGenotype(double[] propVector) { - m_Genotype = new BitSet(m_GenotypeLength); - for (int i = 0; i < m_GenotypeLength; i++) { - if (r.nextDouble() < propVector[i]) { - m_Genotype.set(i); - } - } - } - - @Override - public int compareTo(PBilIndividualTwin o) { - // return ((Double) this.evaluateAsMaxiBits()).compareTo(o - // .evaluateAsMaxiBits()); - return ((Double) this.evaluateAsTwin()).compareTo(o.evaluateAsTwin()); - } -} diff --git a/ea/Ub7/ea7.pdf b/ea/Ub7/ea7.pdf index 8b358c0..f666ed3 100644 --- a/ea/Ub7/ea7.pdf +++ b/ea/Ub7/ea7.pdf Binary files differ diff --git a/ea/Ub7/ea7.tex b/ea/Ub7/ea7.tex index 0991d25..15b9512 100644 --- a/ea/Ub7/ea7.tex +++ b/ea/Ub7/ea7.tex @@ -84,11 +84,19 @@ \vspace{0.5cm} \Aufgabe{Population-based incremental learning}{12}\\ \begin{enumerate}[(a)] \item siehe Quellcode - \item PBIL MaxiBits: (1000/1000) Mean Fitness : 0 Mean Calls needed: 19\\ - GA MaxiBits: - \item die Einstellungen des Hill Climbers müssen ...\\ - Mit $\mu=$ und $\eta= $ ist PBIL deutlich besser + \item HC MaxiBits: (100/1000) Mean Fitness : 0 Mean Calls needed: 184 \\ + PBIL MaxiBits: (100/1000) Mean Fitness : 5 Mean Calls needed: 149 \\ + HC Twin (100/1000) Mean Fitness : 0 Mean Calls needed: 179\\ + PBIL Twin (100/1000) Mean Fitness : 6 Mean Calls needed: 149\\ + Die Konvergenzgeschwindigkeit des PBILs ist in beiden Fällen höher + \item Die einzige Einstellungen des Hill Climbers, welche verändert werden kann, ist die Länge des Genoms. Dies ändert allerdings die Problemstellung. + Eine Möglichkeit bei gleicher Problemstellung wäre es mehrere HillClimber auf einer Population laufen zu lassen und dann das beste Individuum aus den Ergebnissen aller HillClimber zu wählen. + + Mit $\mu=15$ und $\eta=0.1 $:\\ + PBIL MaxiBits: (100/1000) Mean Fitness : 3 Mean Calls needed: 56\\ + PBIL Twin (100/1000) Mean Fitness : 4 Mean Calls needed: 58\\ + Durch schnelleres Lernen werden zwar Bits wahrscheinlicher verloren allerdings konvergiert der PBIL dafür schneller. \end{enumerate} \Aufgabe{ Bucked Brigade Algorithmus}{8} $C_{bid}=0.1$\\ @@ -112,38 +120,38 @@ \end{tabular}\\ \begin{tabular}{|c|c|l|c|c|c|c|c|} $t_2$ & Index & Classifier & Strength & Messages & Match & Bid & Reward \\ - & 1 & 1\#101:01010 & 900 & 01010 & 3,5 & 90 & 50 \\ - & 2 & 01\#1\#:01111 & 990 & 01111 & 1,2 & 99 & 150 \\ - & 3 & 011\#1\#:11101 & 1010 & 11101 & 2 & 101 & 90 \\ - & 4 & 101\#\#:00010 & 1000 & & & & \\ - & 5 & \#\#101:11101 & 900 & 11101 & 3,5 & 90 & 90 \\ \hline - Environment & & & & & & & + & 1 & 1\#101:01010 & 900 & 01010 & 3,5 & 90 & 50 \\ + & 2 & 01\#1\#:01111 & 990 & 01111 & 1,2 & 99 & 150 \\ + & 3 & 011\#1\#:11101 & 1010 & 11101 & 2 & 101 & 90 \\ + & 4 & 101\#\#:00010 & 1000 & & & & \\ + & 5 & \#\#101:11101 & 900 & 11101 & 3,5 & 90 & 90 \\ \hline + Environment & & & & & & & \end{tabular}\\ \begin{tabular}{|c|c|l|c|c|c|c|c|} - $t_3$ & Index & Classifier & Strength & Messages & Match & Bid & Reward \\ - & 1 & 1\#101:01010 & 940 & 01010 & 3,5 & 94 & 52 \\ - & 2 & 01\#1\#:01111 & 1041 & 01111 & 1,2 & 104 & 151 \\ - & 3 & 011\#1\#:11101 & 999 & 11101 & 2 & 99 & 92 \\ - & 4 & 101\#\#:00010 & 1000 & & & & \\ - & 5 & \#\#101:11101 & 900 & 11101 & 3,5 & 90 & 92 \\ \hline - Environment & & & & & & & + $t_3$ & Index & Classifier & Strength & Messages & Match & Bid & Reward \\ + & 1 & 1\#101:01010 & 860 & 01010 & 3,5 & 86 & 52 \\ + & 2 & 01\#1\#:01111 & 1041 & 01111 & 1,2 & 104 & 151 \\ + & 3 & 011\#1\#:11101 & 999 & 11101 & 2 & 99 & 88 \\ + & 4 & 101\#\#:00010 & 1000 & & & & \\ + & 5 & \#\#101:11101 & 900 & 11101 & 3,5 & 90 & 88 \\ \hline + Environment & & & & & & & \end{tabular}\\ \begin{tabular}{|c|c|l|c|c|c|c|c|} - $t_4$ & Index & Classifier & Strength & Messages & Match & Bid & Reward \\ - & 1 & 1\#101:01010 & 898 & 01010 & 3,5 & 90 & 55 \\ - & 2 & 01\#1\#:01111 & 1088 & 01111 & 1,2 & 109 & 154 \\ - & 3 & 011\#1\#:11101 & 992 & 11101 & 2 & 99 & 90 \\ - & 4 & 101\#\#:00010 & 1000 & & & & \\ - & 5 & \#\#101:11101 & 902 & 11101 & 3,5 & 90 & 90 \\ \hline - Environment & & & & & & & + $t_4$ & Index & Classifier & Strength & Messages & Match & Bid & Reward \\ + & 1 & 1\#101:01010 & 826 & 01010 & 3,5 & 83 & 55 \\ + & 2 & 01\#1\#:01111 & 1088 & 01111 & 1,2 & 109 & 154 \\ + & 3 & 011\#1\#:11101 & 988 & 11101 & 2 & 99 & 87 \\ + & 4 & 101\#\#:00010 & 1000 & & & & \\ + & 5 & \#\#101:11101 & 898 & 11101 & 3,5 & 90 & 87 \\ \hline + Environment & & & & & & & \end{tabular}\\ \begin{tabular}{|c|c|l|c|c|c|c|c|} $t_5$ & Index & Classifier & Strength\\ - & 1 & 1\#101:01010 & 809 \\ - & 2 & 01\#1\#:01111 & 1143 \\ - & 3 & 011\#1\#:11101 & 983 \\ + & 1 & 1\#101:01010 & 798 \\ + & 2 & 01\#1\#:01111 & 1133 \\ + & 3 & 011\#1\#:11101 & 976 \\ & 4 & 101\#\#:00010 & 1000 \\ - & 5 & \#\#101:11101 & 902 \\ \hline + & 5 & \#\#101:11101 & 895 \\ \hline Environment & & & \end{tabular} \end{document} diff --git a/mr/ub7/1dMatlab.png b/mr/ub7/1dMatlab.png index dd00742..4bbee4b 100644 --- a/mr/ub7/1dMatlab.png +++ b/mr/ub7/1dMatlab.png Binary files differ diff --git a/mr/ub7/A1d.m b/mr/ub7/A1d.m index f70d581..a15be3e 100644 --- a/mr/ub7/A1d.m +++ b/mr/ub7/A1d.m @@ -1,17 +1,34 @@ pmi=0.5; - - pmit=[0.8,0.4,0.8,0.8,0.8;0.8,0.8,0.4,0.4,0.8;0.4,0.4,0.4,0.4,0.4;0.4,0.8,0.4,0.8,0.4] pmiz=[] - +pmizOdds=[] +pmizLogs=[] for j=1:size(pmit,1) - j pmizl=pmit(j,1); for i = 2:size(pmit,2) - i pmizc= 1/(1+((1-pmit(j,i))/(pmit(j,i))*(1-pmizl)/(pmizl)* pmi/(1-pmi))); - pmizl= pmizc + pmizl= pmizc; end pmiz(j)=pmizl; end -pmiz \ No newline at end of file +pmiz + +for j=1:size(pmit,1) + pmizl=pmit(j,1)/(1-pmit(j,1)); + for i = 2:size(pmit,2) + pmizc= (pmizl)*(pmit(j,i))/(1-pmit(j,i))* (1-pmi)/(pmi); + pmizl= pmizc; + end + pmizOdds(j)=pmizl; +end +pmizOdds + +for j=1:size(pmit,1) + pmizl=log(pmit(j,1)/(1-pmit(j,1))); + for i = 2:size(pmit,2) + pmizc= (pmizl)+log(pmit(j,i))-log(1-pmit(j,i))+ log(1-pmi)-log(pmi); + pmizl= pmizc; + end + pmizLogs(j)=pmizl; +end +pmizLogs \ No newline at end of file diff --git a/mr/ub7/mr7.pdf b/mr/ub7/mr7.pdf index fda404a..eeb6759 100644 --- a/mr/ub7/mr7.pdf +++ b/mr/ub7/mr7.pdf Binary files differ diff --git a/mr/ub7/mr7.tex b/mr/ub7/mr7.tex index 02a76b4..2aea176 100644 --- a/mr/ub7/mr7.tex +++ b/mr/ub7/mr7.tex @@ -96,11 +96,23 @@ 6 Add/Sub, 4 logs \\ \item - grids are counted clockwise \\ + grids are evaluated clockwise \\ $ p(m_1|z_{1,\dots,5})=0.9942$\\ $ p(m_2|z_{1,\dots,5})=0.9660$\\ $ p(m_3|z_{1,\dots,5})=0.1164$\\ $ p(m_4|z_{1,\dots,5})=0.8258$\\ + + $ o(m_1|z_{1,\dots,5})=170.6667$\\ + $ o(m_2|z_{1,\dots,5})=28.4444 $\\ + $ o(m_3|z_{1,\dots,5})=0.1317$\\ + $ o(m_4|z_{1,\dots,5})=4.7407$\\ + + $ lo(m_1|z_{1,\dots,5})=5.1397$\\ + $ lo(m_2|z_{1,\dots,5})=3.3480 $\\ + $ lo(m_3|z_{1,\dots,5})=-2.0273 $\\ + $ lo(m_4|z_{1,\dots,5})=1.5562$\\ + + Rechenweg Matlab siehe Abbildung \ref{fig:1dMatlab}: \begin{figure} \centering