Skip to content

Commit 6dba0dc

Browse files
committed
wip: SatSolver
1 parent 562d009 commit 6dba0dc

File tree

1 file changed

+0
-81
lines changed

1 file changed

+0
-81
lines changed

src/main/scala/ru/org/codingteam/icfpc_2025/SatSolver.scala

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ object SatSolver:
4040
return Step.ExploreStep(plan)
4141

4242
var exploredConnections = Seq.empty[(Int, Int, Int)]
43-
var byEnter = Map.empty[Int, Seq[(Int, Int)]]
44-
var byExit = Map.empty[Int, Seq[(Int, Int)]]
45-
var byEnterExit = Map.empty[(Int, Int), Seq[Int]]
46-
4743
for j <- knowledge.visitedRoutes.indices do
4844
val plan = knowledge.visitedRoutes(j)
4945
val rooms = knowledge.visitedRooms(j)
@@ -52,25 +48,8 @@ object SatSolver:
5248
val door = plan(i)
5349
val enter = rooms(i)
5450
val exit = rooms(i + 1)
55-
5651
exploredConnections = exploredConnections :+ (enter, exit, door)
5752

58-
if !byEnter.contains(enter) then
59-
byEnter += (enter -> Seq((exit, door)))
60-
else
61-
byEnter += (enter -> (byEnter(enter) :+ (exit, door)))
62-
63-
if !byExit.contains(exit) then
64-
byExit += (exit -> Seq((enter, door)))
65-
else
66-
byExit += (exit -> (byExit(exit) :+ (enter, door)))
67-
68-
var enterExit = (enter, exit)
69-
if !byEnterExit.contains(enterExit) then
70-
byEnterExit += (enterExit -> Seq(door))
71-
else
72-
byEnterExit += (enterExit -> (byEnterExit(enterExit) :+ door))
73-
7453
println(s"Explored conntections: ${exploredConnections}")
7554

7655
val sb = new StringBuilder()
@@ -165,62 +144,6 @@ object SatSolver:
165144
sb ++= s"-${connectionVariableIndex(problem.size, j, i, d)} "
166145
sb ++= "0\n"
167146

168-
// // expeditions clauses
169-
// for (enter, exit, door) <- exploredConnections do
170-
// if enter != exit then
171-
// // exist connection between two different rooms through the __door__
172-
// for i <- 0 to problem.size - 1 do
173-
// for j <- 0 to problem.size - 1 do
174-
// if i != j then
175-
// sb ++= s"${connectionVariableIndex(problem.size, i, j, door)} "
176-
// sb ++= "0\n"
177-
178-
// // for enter -door-> exit
179-
// // if room labeled as __enter__ should exist one of connections to other rooms via the __door__
180-
// for (enter, exits) <- byEnter do
181-
// for i <- 0 to problem.size - 1 do
182-
// sb ++= s"-${roomLabelVariableIndex(i, enter)} "
183-
184-
// for (exit, door) <- exits do
185-
// for j <- 0 to problem.size - 1 do
186-
// if enter != exit then
187-
// if i != j then
188-
// sb ++= s"${connectionVariableIndex(problem.size, i, j, door)} "
189-
// else
190-
// sb ++= s"${connectionVariableIndex(problem.size, i, j, door)} "
191-
// sb ++= "0\n"
192-
193-
// // if room labeled as __exit__ should exist one of connections from other rooms via the __door__
194-
// for (exit, enters) <- byExit do
195-
// for i <- 0 to problem.size - 1 do
196-
// sb ++= s"-${roomLabelVariableIndex(i, exit)} "
197-
198-
// for (enter, door) <- enters do
199-
// for j <- 0 to problem.size - 1 do
200-
// if enter != exit then
201-
// if i != j then
202-
// sb ++= s"${connectionVariableIndex(problem.size, i, j, door)} "
203-
// else
204-
// sb ++= s"${connectionVariableIndex(problem.size, i, j, door)} "
205-
// sb ++= "0\n"
206-
207-
// for ((enter, exit), doors) <- byEnterExit do
208-
// for i <- 0 to problem.size - 1 do
209-
// for j <- 0 to problem.size - 1 do
210-
// if enter != exit then
211-
// if i != j then
212-
// sb ++= s"-${roomLabelVariableIndex(i, enter)} "
213-
// sb ++= s"-${roomLabelVariableIndex(j, exit)} "
214-
// for door <- doors do
215-
// sb ++= s"${connectionVariableIndex(problem.size, i, j, door)} "
216-
// sb ++= "0\n"
217-
// else
218-
// sb ++= s"-${roomLabelVariableIndex(i, enter)} "
219-
// sb ++= s"-${roomLabelVariableIndex(j, exit)} "
220-
// for door <- doors do
221-
// sb ++= s"${connectionVariableIndex(problem.size, i, j, door)} "
222-
// sb ++= "0\n"
223-
224147
val folder = Files.createTempDirectory(s"icfpc.sat.${problem.name}")
225148
println(s"Temp directory: ${folder}")
226149

@@ -251,17 +174,13 @@ object SatSolver:
251174
var outConnectionsCount = 0
252175
for d <- 0 to 5 do
253176
if solution(connectionVariableIndex(problem.size, i, j, d) - 1) > 0 then
254-
// println(s"out beta(${i}, ${j}, ${d}) = ${solution(connectionVariableIndex(problem.size, i, j, d) - 1)}")
255177
outConnectionsCount = outConnectionsCount + 1
256178

257179
var inConnectionsCount = 0
258180
for d <- 0 to 5 do
259181
if solution(connectionVariableIndex(problem.size, j, i, d) - 1) > 0 then
260-
// println(s"in beta(${j}, ${i}, ${d}) = ${solution(connectionVariableIndex(problem.size, j, i, d) - 1)}")
261182
inConnectionsCount = inConnectionsCount + 1
262183

263-
// println(s"rooms ${i} ${j}, out = ${outConnectionsCount}")
264-
// println(s"rooms ${i} ${j}, in = ${inConnectionsCount}")
265184
if outConnectionsCount != inConnectionsCount then
266185
invalid = true
267186

0 commit comments

Comments
 (0)