updated
authorChristian Urban <urbanc@in.tum.de>
Wed, 05 Feb 2020 12:24:27 +0000
changeset 332 703c7e42bf46
parent 331 e3878cdd38bc
child 333 24bc76d97db2
updated
Attic/knight3a_test.scala
Attic/knight3b_test.scala
Attic/knight3c_test.scala
marking2/danube_test.sh
marking2/mk-advanced
marking3/knight2_test.sh
marking3/knight3a_test.scala
marking3/knight3b_test.scala
marking3/knight3c_test.scala
marking3/mk
marking3/mk-advanced
marking4/mk
marking4/mk-advanced
marking4/re_test.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Attic/knight3a_test.scala	Wed Feb 05 12:24:27 2020 +0000
@@ -0,0 +1,5 @@
+
+assert(CW7c.ordered_moves(8, List((3,4), (3,2)), (1,3)) == List((0,1), (0,5), (2,1), (2,5)))
+assert(CW7c.ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2)))
+assert(CW7c.ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1)))
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Attic/knight3b_test.scala	Wed Feb 05 12:24:27 2020 +0000
@@ -0,0 +1,40 @@
+
+//import scala.concurrent._
+//import scala.concurrent.duration._
+//import ExecutionContext.Implicits.global
+//import scala.language.postfixOps 
+
+type Pos = (Int, Int)
+type Path = List[Pos]
+
+def add_pair_urban(x: Pos)(y: Pos): Pos = 
+  (x._1 + y._1, x._2 + y._2)
+
+def is_legal_urban(dim: Int, path: Path)(x: Pos): Boolean = 
+  0 <= x._1 && 0 <= x._2 && x._1 < dim && x._2 < dim && !path.contains(x)
+
+def moves_urban(x: Pos): List[Pos] = 
+  List(( 1,  2),( 2,  1),( 2, -1),( 1, -2),
+       (-1, -2),(-2, -1),(-2,  1),(-1,  2)).map(add_pair_urban(x))
+
+def legal_moves_urban(dim: Int, path: Path, x: Pos): List[Pos] = 
+  moves_urban(x).filter(is_legal_urban(dim, path))
+
+def correct_urban(dim: Int)(p: Path): Boolean = p match {
+  case Nil => true
+  case x::Nil => true
+  case x::y::p => 
+    if (legal_moves_urban(dim, p, y).contains(x)) correct_urban(dim)(y::p) else false
+}
+
+def correct_closed_urban(dim: Int)(p: Path) =
+  correct_urban(6)(p) &&  moves_urban(p.head).contains(p.last)
+
+//lazy val f = Future {
+
+  val tsc = CW7c.first_closed_tour_heuristic(6, List((3, 3))).get
+  assert(correct_closed_urban(6)(tsc) == true)
+
+//}
+
+//Await.result(f, 300 second)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Attic/knight3c_test.scala	Wed Feb 05 12:24:27 2020 +0000
@@ -0,0 +1,50 @@
+
+//import scala.concurrent._
+//import scala.concurrent.duration._
+//import ExecutionContext.Implicits.global
+//import scala.language.postfixOps 
+
+println(Runtime.getRuntime.maxMemory)
+
+type Pos = (Int, Int)
+type Path = List[Pos]
+
+def add_pair_urban(x: Pos)(y: Pos): Pos = 
+  (x._1 + y._1, x._2 + y._2)
+
+def is_legal_urban(dim: Int, path: Path)(x: Pos): Boolean = 
+  0 <= x._1 && 0 <= x._2 && x._1 < dim && x._2 < dim && !path.contains(x)
+
+def moves_urban(x: Pos): List[Pos] = 
+  List(( 1,  2),( 2,  1),( 2, -1),( 1, -2),
+       (-1, -2),(-2, -1),(-2,  1),(-1,  2)).map(add_pair_urban(x))
+
+def legal_moves_urban(dim: Int, path: Path, x: Pos): List[Pos] = 
+  moves_urban(x).filter(is_legal_urban(dim, path))
+
+def correct_urban(dim: Int)(p: Path): Boolean = p match {
+  case Nil => true
+  case x::Nil => true
+  case x::y::p => 
+    if (legal_moves_urban(dim, p, y).contains(x)) correct_urban(dim)(y::p) else false
+}
+
+// !!!!!!! the futures need to be removed
+//lazy val f1 = Future {
+
+  val ts8 = CW7c.first_tour_heuristic(8, List((0,0))).get
+  assert(correct_urban(8)(ts8) == true)
+
+//}
+
+//Await.result(f1, 360 second)
+
+
+//lazy val f2 = Future {
+
+  val ts40 = CW7c.first_tour_heuristic(40, List((0,0))).get
+  assert(correct_urban(40)(ts40) == true)
+
+//}
+
+//Await.result(f2, 360 second)
--- a/marking2/danube_test.sh	Tue Feb 04 14:15:42 2020 +0000
+++ b/marking2/danube_test.sh	Wed Feb 05 12:24:27 2020 +0000
@@ -40,8 +40,11 @@
 # purity test
 
 function scala_vars {
-   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
+   (egrep '\bvar\b|\breturn\b|ListBuffer|new Array' "$1" 2> /dev/null 1> /dev/null)
 }
+#function scala_vars {
+#   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
+#}
 
 
 # var, .par return, ListBuffer test
--- a/marking2/mk-advanced	Tue Feb 04 14:15:42 2020 +0000
+++ b/marking2/mk-advanced	Wed Feb 05 12:24:27 2020 +0000
@@ -19,7 +19,7 @@
   cp ../../../../../marking2/movies.csv .
   cp ../../../../../marking2/ratings.csv .
   ./danube_test.sh output
-  rm danube_test2.sh
+  rm danube_test.sh
   rm danube_test1.scala
   rm danube_test2.scala
   rm danube_test3.scala
--- a/marking3/knight2_test.sh	Tue Feb 04 14:15:42 2020 +0000
+++ b/marking3/knight2_test.sh	Wed Feb 05 12:24:27 2020 +0000
@@ -20,21 +20,21 @@
 # compilation tests
 
 function scala_compile {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2> /dev/null 1> /dev/null)
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out)
 }
 
 # functional tests
 
 function scala_assert {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+    (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 }
 
 function scala_assert_long {
-  (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+  (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 }
 
 #function scala_assert_elong {
-#  (ulimit -t 90; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+#  (ulimit -t 90; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 #}
 
 # purity test
@@ -253,7 +253,7 @@
   echo -e " tour_on_mega_board(70, List((0,0))) found and correct?" | tee -a $out
   START=$(date +%s)
   
-  if (scala_assert "knight3.scala" "knight3_test9.scala")
+  if (scala_assert_long "knight3.scala" "knight3_test9.scala")
   then
       END=$(date +%s)
       DIFF=$(( $END - $START ))
@@ -264,7 +264,7 @@
       END=$(date +%s)
       DIFF=$(( $END - $START ))
       echo "  It took $DIFF seconds" | tee -a $out
-      echo -e "  --> test  failed" | tee -a $out 
+      echo -e "  --> TEST FAILED\n" | tee -a $out 
   fi
 fi
 
--- a/marking3/knight3a_test.scala	Tue Feb 04 14:15:42 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-
-assert(CW7c.ordered_moves(8, List((3,4), (3,2)), (1,3)) == List((0,1), (0,5), (2,1), (2,5)))
-assert(CW7c.ordered_moves(8, List((4,0)), (0,0)) == List((2,1), (1,2)))
-assert(CW7c.ordered_moves(8, List((0,4)), (0,0)) == List((1,2), (2,1)))
-
--- a/marking3/knight3b_test.scala	Tue Feb 04 14:15:42 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-
-//import scala.concurrent._
-//import scala.concurrent.duration._
-//import ExecutionContext.Implicits.global
-//import scala.language.postfixOps 
-
-type Pos = (Int, Int)
-type Path = List[Pos]
-
-def add_pair_urban(x: Pos)(y: Pos): Pos = 
-  (x._1 + y._1, x._2 + y._2)
-
-def is_legal_urban(dim: Int, path: Path)(x: Pos): Boolean = 
-  0 <= x._1 && 0 <= x._2 && x._1 < dim && x._2 < dim && !path.contains(x)
-
-def moves_urban(x: Pos): List[Pos] = 
-  List(( 1,  2),( 2,  1),( 2, -1),( 1, -2),
-       (-1, -2),(-2, -1),(-2,  1),(-1,  2)).map(add_pair_urban(x))
-
-def legal_moves_urban(dim: Int, path: Path, x: Pos): List[Pos] = 
-  moves_urban(x).filter(is_legal_urban(dim, path))
-
-def correct_urban(dim: Int)(p: Path): Boolean = p match {
-  case Nil => true
-  case x::Nil => true
-  case x::y::p => 
-    if (legal_moves_urban(dim, p, y).contains(x)) correct_urban(dim)(y::p) else false
-}
-
-def correct_closed_urban(dim: Int)(p: Path) =
-  correct_urban(6)(p) &&  moves_urban(p.head).contains(p.last)
-
-//lazy val f = Future {
-
-  val tsc = CW7c.first_closed_tour_heuristic(6, List((3, 3))).get
-  assert(correct_closed_urban(6)(tsc) == true)
-
-//}
-
-//Await.result(f, 300 second)
--- a/marking3/knight3c_test.scala	Tue Feb 04 14:15:42 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-
-//import scala.concurrent._
-//import scala.concurrent.duration._
-//import ExecutionContext.Implicits.global
-//import scala.language.postfixOps 
-
-println(Runtime.getRuntime.maxMemory)
-
-type Pos = (Int, Int)
-type Path = List[Pos]
-
-def add_pair_urban(x: Pos)(y: Pos): Pos = 
-  (x._1 + y._1, x._2 + y._2)
-
-def is_legal_urban(dim: Int, path: Path)(x: Pos): Boolean = 
-  0 <= x._1 && 0 <= x._2 && x._1 < dim && x._2 < dim && !path.contains(x)
-
-def moves_urban(x: Pos): List[Pos] = 
-  List(( 1,  2),( 2,  1),( 2, -1),( 1, -2),
-       (-1, -2),(-2, -1),(-2,  1),(-1,  2)).map(add_pair_urban(x))
-
-def legal_moves_urban(dim: Int, path: Path, x: Pos): List[Pos] = 
-  moves_urban(x).filter(is_legal_urban(dim, path))
-
-def correct_urban(dim: Int)(p: Path): Boolean = p match {
-  case Nil => true
-  case x::Nil => true
-  case x::y::p => 
-    if (legal_moves_urban(dim, p, y).contains(x)) correct_urban(dim)(y::p) else false
-}
-
-// !!!!!!! the futures need to be removed
-//lazy val f1 = Future {
-
-  val ts8 = CW7c.first_tour_heuristic(8, List((0,0))).get
-  assert(correct_urban(8)(ts8) == true)
-
-//}
-
-//Await.result(f1, 360 second)
-
-
-//lazy val f2 = Future {
-
-  val ts40 = CW7c.first_tour_heuristic(40, List((0,0))).get
-  assert(correct_urban(40)(ts40) == true)
-
-//}
-
-//Await.result(f2, 360 second)
--- a/marking3/mk	Tue Feb 04 14:15:42 2020 +0000
+++ b/marking3/mk	Wed Feb 05 12:24:27 2020 +0000
@@ -14,16 +14,12 @@
   cp ../../../../../marking3/knight1_test2.scala .
   cp ../../../../../marking3/knight1_test3a.scala .
   cp ../../../../../marking3/knight1_test3b.scala .
-  #cp ../../../../../marking3/knight1_test4.scala .
-  #cp ../../../../../marking3/knight1_test5.scala .
-  ./knight1_test.sh output1
+  ./knight1_test.sh output
   rm knight1_test.sh
   rm knight1_test1.scala
   rm knight1_test2.scala
   rm knight1_test3a.scala 
   rm knight1_test3b.scala
-  #rm knight1_test4.scala
-  #rm knight1_test5.scala
   cd ..
   cd ..
 done
--- a/marking3/mk-advanced	Tue Feb 04 14:15:42 2020 +0000
+++ b/marking3/mk-advanced	Wed Feb 05 12:24:27 2020 +0000
@@ -3,23 +3,29 @@
 
 trap "exit" INT
 
-files=${1:-assignment20188-*}
+files=${1:-assignment2019scala-*/Part8}
 
 for sd in $files; do
   cd $sd
   echo $sd
+  sleep 5
   touch .
-  cp ../../../marking3/knight3_test.sh .
-  cp ../../../marking3/knight_test6.scala .
-  cp ../../../marking3/knight_test7.scala .
-  cp ../../../marking3/knight_test8.scala .
-  cp ../../../marking3/knight_test9.scala .
-  ./knight3_test.sh output
-  rm knight3_test.sh
-  rm knight_test6.scala
-  rm knight_test7.scala
-  rm knight_test8.scala
-  rm knight_test9.scala
+  cp ../../../../../marking3/knight2_test.sh .
+  cp ../../../../../marking3/knight1_test4.scala .
+  cp ../../../../../marking3/knight1_test5.scala .
+  cp ../../../../../marking3/knight2_test6.scala .
+  cp ../../../../../marking3/knight2_test7.scala .
+  cp ../../../../../marking3/knight2_test8.scala .
+  cp ../../../../../marking3/knight3_test9.scala .
+  ./knight2_test.sh output
+  rm knight2_test.sh
+  rm knight1_test4.scala
+  rm knight1_test5.scala
+  rm knight2_test6.scala
+  rm knight2_test7.scala
+  rm knight2_test8.scala
+  rm knight3_test9.scala
+  cd ..
   cd ..
 done
 
--- a/marking4/mk	Tue Feb 04 14:15:42 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#!/bin/sh
-###set -e
-
-trap "exit" INT
-
-files=${1:-assignment20189-*}
-
-for sd in $files; do
-  cd $sd
-  echo $sd
-  touch .
-  cp ../../../marking4/re_test.sh .
-  cp ../../../marking4/re_test1.scala .
-  cp ../../../marking4/re_test2.scala .
-  cp ../../../marking4/re_test3.scala .
-  cp ../../../marking4/re_test4.scala .
-  cp ../../../marking4/re_test5.scala .
-  cp ../../../marking4/re_test6.scala .
-  ./re_test.sh output
-  rm re_test.sh
-  rm re_test1.scala
-  rm re_test2.scala
-  rm re_test3.scala
-  rm re_test4.scala
-  rm re_test5.scala
-  rm re_test6.scala
-  cd ..
-done
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/marking4/mk-advanced	Wed Feb 05 12:24:27 2020 +0000
@@ -0,0 +1,31 @@
+#!/bin/sh
+###set -e
+
+trap "exit" INT
+
+files=${1:-assignment2019scala-*/Part9}
+
+for sd in $files; do
+  cd $sd
+  echo $sd
+  touch .
+  cp ../../../../../marking4/re_test.sh .
+  cp ../../../../../marking4/re_test1.scala .
+  cp ../../../../../marking4/re_test2.scala .
+  cp ../../../../../marking4/re_test3.scala .
+  cp ../../../../../marking4/re_test4.scala .
+  cp ../../../../../marking4/re_test5.scala .
+  cp ../../../../../marking4/re_test6.scala .
+  ./re_test.sh output
+  rm re_test.sh
+  rm re_test1.scala
+  rm re_test2.scala
+  rm re_test3.scala
+  rm re_test4.scala
+  rm re_test5.scala
+  rm re_test6.scala
+  cd ..
+  cd ..
+done
+
+
--- a/marking4/re_test.sh	Tue Feb 04 14:15:42 2020 +0000
+++ b/marking4/re_test.sh	Wed Feb 05 12:24:27 2020 +0000
@@ -26,11 +26,11 @@
 # functional tests
 
 function scala_assert {
-    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
+    (ulimit -t 40; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 }
 
 function scala_assert_long {
-    (ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
+    (ulimit -t 80; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null)
 }
 
 # purity test
@@ -104,19 +104,19 @@
   echo -e " der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))" | tee -a $out
   echo -e "" | tee -a $out
   echo -e " val r0 = \"a\" ~ \"b\" ~ \"c\"" | tee -a $out
-  echo -e " assert(der('a', r0) == (ONE ~ \"b\") ~ \"c\")" | tee -a $out
-  echo -e " assert(der('b', r0) == (ZERO ~ \"b\") ~ \"c\")" | tee -a $out
-  echo -e " assert(der('c', r0) == (ZERO ~ \"b\") ~ \"c\")" | tee -a $out
+  echo -e " der('a', r0) == (ONE ~ \"b\") ~ \"c\"" | tee -a $out
+  echo -e " der('b', r0) == (ZERO ~ \"b\") ~ \"c\"" | tee -a $out
+  echo -e " der('c', r0) == (ZERO ~ \"b\") ~ \"c\"" | tee -a $out
   echo -e "" | tee -a $out
   echo -e " val r1 = (ONE ~ \"b\") ~ \"c\"" | tee -a $out
-  echo -e " assert(der('a', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\")" | tee -a $out
-  echo -e " assert(der('b', r1) == ((ZERO ~ \"b\") | ONE) ~ \"c\")" | tee -a $out
-  echo -e " assert(der('c', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\")" | tee -a $out
+  echo -e " der('a', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\"" | tee -a $out
+  echo -e " der('b', r1) == ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
+  echo -e " der('c', r1) == ((ZERO ~ \"b\") | ZERO) ~ \"c\"" | tee -a $out
   echo -e "" | tee -a $out
   echo -e " val r2 = ((ZERO ~ \"b\") | ONE) ~ \"c\"" | tee -a $out
-  echo -e " assert(der('a', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO))" | tee -a $out
-  echo -e " assert(der('b', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO))" | tee -a $out
-  echo -e " assert(der('c', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ONE))" | tee -a $out
+  echo -e " der('a', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO)" | tee -a $out
+  echo -e " der('b', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ZERO)" | tee -a $out
+  echo -e " der('c', r2) == ((((ZERO ~ \"b\") | ZERO) ~ \"c\") | ONE)" | tee -a $out
 
   if (scala_assert "re.scala" "re_test2.scala")
   then
@@ -146,7 +146,7 @@
   echo -e " simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO" | tee -a $out
   echo -e " simp(ALT(ONE | ONE, ONE | ONE)) == ONE" | tee -a $out
   echo -e " simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')" | tee -a $out
-  echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE | CHAR('a'), CHAR('a') | ONE)" tee -a $out
+  echo -e " simp(ALT(ONE | CHAR('a'), CHAR('a') | ONE)) == ALT(ONE | CHAR('a'), CHAR('a') | ONE)" | tee -a $out
   
   if (scala_assert "re.scala" "re_test3.scala")
   then
@@ -226,13 +226,19 @@
   echo -e " val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))" | tee -a $out
   echo -e " matcher(EVIL, \"a\" * 1000000 ++ \"b\") == true" | tee -a $out
   echo -e " matcher(EVIL, \"a\" * 1000000) == false" | tee -a $out
-
+  START=$(date +%s)
   
-  if (time scala_assert_long "re.scala" "re_test6.scala")
+  if (scala_assert_long "re.scala" "re_test6.scala")
   then
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo "  It took $DIFF seconds" | tee -a $out
       echo -e "  --> success" | tee -a $out
       marks=$(( marks + 1 ))
   else
+      END=$(date +%s)
+      DIFF=$(( $END - $START ))
+      echo "  It took $DIFF seconds" | tee -a $out
       echo -e "  --> ONE OF THE TESTS FAILED\n" | tee -a $out
   fi
 fi