Skip to content

Commit

Permalink
add print for constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
mcosovic committed Sep 11, 2023
1 parent 2ef589b commit b974964
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/JuliaGrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using SparseArrays, LinearAlgebra, SuiteSparse
using HDF5, UUIDs
using JuMP

import Base.print

########## Types and Constants ##########
include("definition/internal.jl")
Expand All @@ -13,7 +14,7 @@ include("definition/analysis.jl")
######### Utility ##########
include("utility/routine.jl")
include("utility/internal.jl")
export @base, @power, @voltage, @current, @parameter, @default, @print
export @base, @power, @voltage, @current, @parameter, @default

########## Power System ##########
include("powerSystem/load.jl")
Expand Down
20 changes: 12 additions & 8 deletions src/utility/routine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,18 @@ function checkStatus(status)
end

######### Print Constraints ##########
macro print(constraint)
analysis = constraint.args[1].args[1].args[1]
return quote
analysis = $(esc(analysis))
for i = 1:length($constraint)
if is_valid(analysis.jump, $constraint[i])
println($constraint[i])
end
function print(obj::Union{PolarAngleRef, CartesianRealRef})
for i in eachindex(obj)
try
println(obj[i])
catch
end
end
end

function print(obj::PolarAngleRefSimple)
try
println(obj)
catch
end
end

0 comments on commit b974964

Please sign in to comment.