From f7e82eda40e369e0349aae7c64decab269171781 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Wed, 18 Jun 2014 21:14:27 +0200 Subject: [PATCH] Updated gitignore, first draft report, makefile --- .gitignore | 8 ++++++-- LubbersReport.tex | 23 +++++++++++++++++++++++ LubbersSolver.java | 28 +++++++++++++++++++++++----- Makefile | 14 ++++++++++++++ PetTest.java | 10 +++++----- build.xml | 41 ----------------------------------------- make.sh | 4 ---- 7 files changed, 71 insertions(+), 57 deletions(-) create mode 100644 LubbersReport.tex create mode 100644 Makefile delete mode 100644 build.xml delete mode 100755 make.sh diff --git a/.gitignore b/.gitignore index a7ea31e..d872d94 100644 --- a/.gitignore +++ b/.gitignore @@ -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 index 0000000..b2a9422 --- /dev/null +++ b/LubbersReport.tex @@ -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} + diff --git a/LubbersSolver.java b/LubbersSolver.java index dfd968c..bdb4ded 100755 --- a/LubbersSolver.java +++ b/LubbersSolver.java @@ -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=m ? -1 : i; } - - if(m ps = new LinkedList(); 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(){ @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 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} diff --git a/PetTest.java b/PetTest.java index cabef3e..f55a815 100755 --- a/PetTest.java +++ b/PetTest.java @@ -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 index d5a9cc0..0000000 --- a/build.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - simple example build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/make.sh b/make.sh deleted file mode 100755 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 -- 2.20.1