Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Louis/bug fixes #14

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
name = "SeaPearlExtras"
uuid = "90978a9a-af5e-4113-9033-e3aa0a1ac968"
authors = ["PierreTsr <[email protected]>","3rdCore <[email protected]>"]
authors = ["PierreTsr <[email protected]>", "3rdCore <[email protected]>"]
version = "0.1.0"


[deps]
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
SeaPearl = "c13076dc-bdcd-48ba-bc88-4b44c2587ab3"

[compat]
julia = "1.6 - 1.7"
julia = "1.6 - 1.7"
12 changes: 6 additions & 6 deletions src/metrics/basicmetrics/dataframes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ function storedata(metrics::AbstractMetrics; filename::String="")
:Nodes => metrics.meanNodeVisitedUntilEnd[i],
:Time => metrics.timeneeded[i],
:Score => missing,
:Reward => isnothing(metrics.totalReward) ? missing : metrics.totalReward[i],
:Loss => isnothing(metrics.loss) ? missing : metrics.loss[i]
:Reward => isnothing(metrics.totalReward) || isnothing(metrics.totalReward[i]) ? missing : metrics.totalReward[i],
:Loss => isnothing(metrics.loss) || isnothing(metrics.loss[i]) ? missing : metrics.loss[i]
)
push!(df, episodeData)
for j = 1:length(metrics.nodeVisited[i])
solutionData = copy(episodeData)
solutionData[:Solution] = j
solutionData[:Nodes] = metrics.nodeVisited[i][j]
solutionData[:Score] = isnothing(metrics.scores) ? missing : metrics.scores[i][j]
solutionData[:Score] = isnothing(metrics.scores) || isnothing(metrics.scores[i]) || isnothing(metrics.scores[i][j]) ? missing : metrics.scores[i][j]
push!(df, solutionData)
end
end
Expand Down Expand Up @@ -62,15 +62,15 @@ function storedata(metrics::Vector{<:AbstractMetrics}; filename::String="")
:Nodes => metrics[j].meanNodeVisitedUntilEnd[i],
:Time => metrics[j].timeneeded[i],
:Score => missing,
:Reward => isnothing(metrics[j].totalReward) ? missing : metrics[j].totalReward[i],
:Loss => isnothing(metrics[j].loss) ? missing : metrics[j].loss[i]
:Reward => isnothing(metrics[j].totalReward) || isnothing(metrics[j].totalReward[i]) ? missing : metrics[j].totalReward[i],
:Loss => isnothing(metrics[j].loss) || isnothing(metrics[j].loss[i]) ? missing : metrics[j].loss[i]
)
push!(df, episodeData)
for k = 1:length(metrics[j].nodeVisited[i])
solutionData = copy(episodeData)
solutionData[:Solution] = k
solutionData[:Nodes] = metrics[j].nodeVisited[i][k]
solutionData[:Score] = isnothing(metrics[j].scores) ? missing : metrics[j].scores[i][k]
solutionData[:Score] = isnothing(metrics[j].scores) || isnothing(metrics[j].scores[i]) || isnothing(metrics[j].scores[i][k]) ? missing : metrics[j].scores[i][k]
push!(df, solutionData)
end
end
Expand Down
27 changes: 20 additions & 7 deletions src/staterepresentation/tripartite/tripartite.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
using SeaPearl: DefaultStateRepresentation, VariableVertex, ValueVertex
using SeaPearl: DefaultStateRepresentation, VariableVertex, ValueVertex, adjacency_matrix, HeterogeneousStateRepresentation
using Graphs
using Cairo, Compose

function plottripartite(sr::DefaultStateRepresentation)
function plottripartite(sr::Union{DefaultStateRepresentation, HeterogeneousStateRepresentation})
cpmodel = sr.cplayergraph
am = Matrix(adjacency_matrix(cpmodel))
n = cpmodel.totalLength
nodefillc = []
label = []
for id in 1:n
v = cpmodel.idToNode[id]
if isa(v, VariableVertex) push!(nodefillc,"red")
elseif isa(v, ValueVertex) push!(nodefillc,"blue")
else push!(nodefillc,"black") end
if isa(v, VariableVertex)
push!(nodefillc,"red")
push!(label,v.variable.id)
elseif isa(v, ValueVertex)
push!(nodefillc,"blue")
push!(label,v.value)
else
push!(nodefillc,"black")
push!(label,typeof(v.constraint))
end

end
gplot(cpmodel;nodefillc=nodefillc)
draw(PDF("test.pdf", 16cm, 16cm), gplot(Graphs.Graph(am); nodefillc=nodefillc, nodelabel=label))
error("Your plot is ready")
end

export plottripartite
export plottripartite, plottripartite2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why export a plottripartite2 ?