Skip to content

Commit

Permalink
Merge pull request #121 from Mala1180/feature/fix-problem-next
Browse files Browse the repository at this point in the history
Feature/fix-problem-next
  • Loading branch information
paga16-hash authored Sep 20, 2023
2 parents 1084987 + 8bf0929 commit 8a2feb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/satify/model/problems/NurseScheduling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ case class NurseScheduling(nurses: Int, days: Int, shifts: Int) extends Problem:
)

def toString(assignment: Assignment): String =
var output = s"There are $shifts shifts a day\n" +
var output = s"There are $shifts shifts per day\n" +
"Min shifts per nurse " + minShiftsPerNurse + "\n" +
"Max shifts per nurse " + maxShiftsPerNurse + "\n"

Expand All @@ -75,9 +75,9 @@ case class NurseScheduling(nurses: Int, days: Int, shifts: Int) extends Problem:
variables.filter(_.value).foreach { v =>
val name = v.name
val nurse = "Nurse-" + name.split("_d")(0).replace("n", "")
val day = "Day " + name.split("_s")(0).last
val day = "day " + name.split("_s")(0).last
val shift = name.split("_s")(1)
output += s"$nurse works $day at the shift number $shift\n"
output += s"$nurse works $day at the shift $shift\n"
}
output
case _ => output
2 changes: 1 addition & 1 deletion src/main/scala/satify/view/View.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object View:
contents += new BoxPanel(Orientation.Vertical):
contents += new ScrollPane(createOutputTextArea(sol.print, 30, 35))
if model.problem.isDefined && model.solution.get.result == Result.SAT then
contents += createShowSection(model.problem.get, model.solution.get.assignment.head)
contents += createShowSection(model.problem.get, model.solution.get.assignment.last)
sol.status match
case PARTIAL => contents += createNextSection(model)
case _ =>
Expand Down
14 changes: 7 additions & 7 deletions src/test/scala/satify/problems/NurseSchedulingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import satify.update.solver.{Solver, SolverType}

class NurseSchedulingTest extends AnyFlatSpec with Matchers:

"NurseScheduling 2 nurses with 5 days and 2 shifts" should "be UNSAT" in {
val problem = NurseScheduling(2, 5, 2)
/*val sol = Solver(DPLL).solve(problem.exp)
sol should matchPattern { case Solution(UNSAT, _, _) => }*/
"Scheduling of 2 nurses, 2 days and 3 shifts" should "be UNSAT" in {
val problem = NurseScheduling(2, 2, 3)
val sol = Solver(DPLL).solve(problem.exp)
sol should matchPattern { case Solution(UNSAT, _, _) => }
}

"NurseScheduling 3 nurses with 1 days and 3 shifts" should "be SAT" in {
"Scheduling of 3 nurses, 1 days and 3 shifts" should "be SAT" in {
val problem = NurseScheduling(3, 1, 3)
/*val sol = Solver(DPLL).solve(problem.exp)
sol should matchPattern { case Solution(SAT, _, _) => }*/
val sol = Solver(DPLL).solve(problem.exp)
sol should matchPattern { case Solution(SAT, _, _) => }
}

0 comments on commit 8a2feb3

Please sign in to comment.