Updated gitignore, first draft report, makefile
authorMart Lubbers <mart@martlubbers.net>
Wed, 18 Jun 2014 19:14:27 +0000 (21:14 +0200)
committerMart Lubbers <mart@martlubbers.net>
Wed, 18 Jun 2014 19:14:27 +0000 (21:14 +0200)
.gitignore
LubbersReport.tex [new file with mode: 0644]
LubbersSolver.java
Makefile [new file with mode: 0644]
PetTest.java
build.xml [deleted file]
make.sh [deleted file]

index a7ea31e..d872d94 100644 (file)
@@ -1,3 +1,7 @@
-build/*
-dist/*
+*.aux
 *.class
+*.dvi
+*.log
+*.out
+*.pdf
+*.toc
diff --git a/LubbersReport.tex b/LubbersReport.tex
new file mode 100644 (file)
index 0000000..b2a9422
--- /dev/null
@@ -0,0 +1,23 @@
+\documentclass{article}
+
+\usepackage[dvipdfm]{hyperref}
+
+\author{
+       Mart Lubbers\\
+       s4109503\\
+       \url{mailto:mart@martlubbers.net}
+}
+\title{Complexity Assignment}
+\date{\today}
+
+\begin{document}
+\maketitle
+\tableofcontents
+\section{Introduction}
+
+\section{Implementation}
+
+\section{Conclusion}
+
+\end{document}
+
index dfd968c..bdb4ded 100755 (executable)
@@ -7,7 +7,11 @@ import java.util.List;
 import java.util.Comparator;
 
 
-/* Generate a random solution which not is necessarily optimal. */
+/**
+ * Class that implements the pot problem solver.
+ *
+ * @author Mart Lubbers
+ */
 public class LubbersSolver implements IPetproblemSolver {
 
        private class Tuple {
@@ -58,6 +62,14 @@ public class LubbersSolver implements IPetproblemSolver {
                return sum;
        }
 
+       /**
+        * Mart Lubbers' implementation of the pet problem
+        *
+        * @param n the amount of children
+        * @param m the amount of pets
+        * @param compatibility the compatibility matrix of pets and children
+        * @return the optimal distribution of pets and children
+        */
        @Override
        public int[] solve(int n, int m, final int[][] compatibility) {
                System.out.println("n: " + n + " m: " + m);
@@ -65,10 +77,15 @@ public class LubbersSolver implements IPetproblemSolver {
                for(int i = 0; i<n; i++){
                        possibilities[i] = i>=m ? -1 : i;
                }
-
-               if(m<n){
+               if(m<=n){
+                       System.out.println("Wierd shizzleeee");
                        List<int[]> ps = new LinkedList<int[]>();
                        permute(possibilities, 0, ps);
+                       for(int[] i : ps){
+                               System.out.println(computeCompatibility(compatibility, i) + ": " + Arrays.toString(i));
+                       }
+                       System.exit(0);
+
                        return Collections.max(ps, new Comparator<int[]>(){
                                @Override
                                public int compare(int[] a, int[] b){
@@ -76,9 +93,10 @@ public class LubbersSolver implements IPetproblemSolver {
                                }
                        });
                }
-               else{
+               else {
                        System.out.println("not equal...");
-                       return null;
+                       return new int[n];
+                       //return null;
                }
                
        }
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..974967e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,14 @@
+SHELL:=/bin/bash
+all: pdf test
+
+pdf:
+       latex LubbersReport.tex
+       latex LubbersReport.tex
+       dvipdfm LubbersReport.dvi
+
+test:
+       javac -cp /usr/share/java/junit.jar:/usr/share/java/junit4.jar *.java
+       java org.junit.runner.JUnitCore PetTest
+
+clean:
+       rm -vf *.{class,aux,log,out,pdf,toc,dvi}
index cabef3e..f55a815 100755 (executable)
@@ -89,7 +89,7 @@ public class PetTest {
                checkConformance(n, m, result);
        }
        
-       @Test(timeout = 2000)
+       @Test(timeout = 10000)
        public void testExample() {
                int n = 5, m = 4;
                int[][] compatibility = {
@@ -105,19 +105,19 @@ public class PetTest {
                Assert.assertEquals("Does not give a correct answer", 4, computeCompatibility(compatibility, result));
        }
        
-       @Test(timeout = 2000)
+       @Test(timeout = 10000)
        public void testGeneratedSmall() {
                performGeneratedTest(8, 10);
                performGeneratedTest(10, 8);
        }
        
-       @Test(timeout = 2000)
+       @Test(timeout = 10000)
        public void testGeneratedMedium() {
                performGeneratedTest(23, 20);
                performGeneratedTest(20, 23);
        }
        
-       @Test(timeout = 5000)
+       @Test(timeout = 10000)
        public void testGeneratedLarge() {
                performGeneratedTest(121, 130);
                performGeneratedTest(130, 121);
@@ -128,7 +128,7 @@ public class PetTest {
         * your solution is not incorrect if it takes longer,
         * or if it is not capable to finish in a reasonable amount of time.
         */
-       @Test(timeout = 5000) 
+       @Test(timeout = 10000) 
        public void testGeneratedTerrible() {
                performGeneratedTest(2910, 3102);
                performGeneratedTest(3102, 2910);
diff --git a/build.xml b/build.xml
deleted file mode 100644 (file)
index d5a9cc0..0000000
--- a/build.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<project name="MyProject" default="dist" basedir=".">
-       <description>
-               simple example build file
-       </description>
-       <!-- set global properties for this build -->
-       <property name="src" location="src"/>
-       <property name="build" location="build"/>
-       <property name="dist"  location="dist"/>
-
-       <target name="init">
-               <!-- Create the time stamp -->
-               <tstamp/>
-               <!-- Create the build directory
-                                                                                                                                                                                                structure used by compile -->
-               <mkdir dir="${build}"/>
-       </target>
-
-       <target name="compile" depends="init"
-               description="compile the source " >
-               <!-- Compile the java code from ${src} into ${build} -->
-               <javac srcdir="." destdir="${build}"/>
-       </target>
-
-       <target name="dist" depends="compile"
-               description="generate the distribution" >
-               <!-- Create the distribution
-                                                                                                                                                                                                directory -->
-               <mkdir dir="${dist}/lib"/>
-
-               <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file
-                                                -->
-               <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
-       </target>
-
-       <target name="clean"
-               description="clean up" >
-               <!-- Delete the ${build} and ${dist} directory trees -->
-               <delete dir="${build}"/>
-               <delete dir="${dist}"/>
-       </target>
-</project>
diff --git a/make.sh b/make.sh
deleted file mode 100755 (executable)
index 2199991..0000000
--- a/make.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-set -e
-javac -cp /usr/share/java/junit.jar:/usr/share/java/junit4.jar *.java
-java org.junit.runner.JUnitCore PetTest || true