Skip to content

Commit c004f51

Browse files
committed
new version v0.1.2
1 parent fc3f4ce commit c004f51

File tree

3 files changed

+14
-72
lines changed

3 files changed

+14
-72
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ConstrainSolver.jl - Changelog
22

3+
## v0.1.2 (27th of April 2020)
4+
- Table constraint
5+
- `@constraint(m, x in CS.TableSet(2dArr))`
6+
37
## v0.1.1 (15th of April 2020)
48
- CS.Integers
59
- i.e `@variable(m, x, CS.Integers([1,2,5]))`

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ConstraintSolver"
22
uuid = "e0e52ebd-5523-408d-9ca3-7641f1cd1405"
33
authors = ["Ole Kröger <[email protected]>"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[deps]
77
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"

visualizations/plot_search_space.jl

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function plot_killer(grid, sums, fname; fill = true, mark = nothing)
137137
png("/home/ole/Julia/ConstraintSolver/visualizations/images/$(fname)")
138138
end
139139

140-
function plot_str8ts(grid, white, fname)
140+
function plot_str8ts(grid, white, fname; search_space = nothing, only_fixed=true)
141141
plot(;
142142
size = (900, 900),
143143
legend = false,
@@ -148,83 +148,21 @@ function plot_str8ts(grid, white, fname)
148148

149149
for r=1:9, c=1:9
150150
plot!(
151-
rectangle(1, 1, r - 1, 9 - c),
151+
rectangle(1, 1, c - 1, 9 - r),
152152
color = white[r,c] == 1 ? "white" : "black",
153153
)
154+
x = c - 0.5
155+
y = 10 - r - 0.5
154156
if grid[r,c] != 0
155-
x = r - 0.5
156-
y = 10 - c - 0.5
157-
annotate!([x, y, text(string(grid[r,c]), 20, white[r,c] == 1 ? :black : :white)])
157+
annotate!(x, y, text(string(grid[r,c]), 20, white[r,c] == 1 ? :black : :white))
158158
end
159-
end
160-
#=
161-
for s in sums
162-
ind = s.indices[1]
163-
x = ind[2] - 0.75
164-
y = 10 - ind[1] - 0.17
165-
annotate!(x, y, text(s.result, 15, :black))
166-
if mark === nothing
167-
for ind in s.indices
168-
plot!(rectangle(1, 1, ind[2] - 1, 9 - ind[1]), color = s.color, alpha = 0.4)
169-
end
170-
else
171-
for ind in s.indices
172-
if ind in mark
173-
plot!(
174-
rectangle(1, 1, ind[2] - 1, 9 - ind[1]),
175-
color = "red",
176-
alpha = 0.4,
177-
)
178-
else
179-
plot!(
180-
rectangle(1, 1, ind[2] - 1, 9 - ind[1]),
181-
color = s.color,
182-
alpha = 0.4,
183-
)
184-
end
185-
end
186-
end
187-
end
188-
189-
for i in [3, 6]
190-
plot!([i, i], [0, 9], color = :black, linewidth = 4)
191-
end
192-
for j in [3, 6]
193-
plot!([0, 9], [j, j], color = :black, linewidth = 4)
194-
end
195-
196-
197-
if fill
198-
for ind in keys(grid)
199-
if CS.isfixed(grid[ind])
200-
x = ind[2] - 0.5
201-
y = 10 - ind[1] - 0.5
202-
annotate!(x, y, text(value(grid[ind]), 20, :black))
203-
else
204-
vals = values(grid[ind])
205-
sort!(vals)
206-
x = ind[2] - 0.3
207-
y = 10 - ind[1] - 0.2
208-
max_idx = min(3, length(vals))
209-
text_vals = join(vals[1:max_idx], ",")
210-
annotate!(x, y, text(text_vals, 11))
211-
if length(vals) > 3
212-
y -= 0.25
213-
max_idx = min(6, length(vals))
214-
text_vals = join(vals[4:max_idx], ",")
215-
annotate!(x, y, text(text_vals, 11))
216-
end
217-
if length(vals) > 6
218-
y -= 0.25
219-
max_idx = length(vals)
220-
text_vals = join(vals[7:max_idx], ",")
221-
annotate!(x, y, text(text_vals, 11))
222-
end
223-
159+
if search_space !== nothing
160+
if search_space[r,c] != 0 && (search_space[r,c] isa Int || length(search_space[r,c]) == 1)
161+
@assert white[r,c] == 1
162+
annotate!(x, y, text(string(search_space[r,c]), 20, :blue))
224163
end
225164
end
226165
end
227-
=#
228166

229167
png("/home/ole/Julia/ConstraintSolver/visualizations/images/$(fname)")
230168
end

0 commit comments

Comments
 (0)