-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from psrenergy/px/interface
Bump Version `-> v0.2`
- Loading branch information
Showing
16 changed files
with
312 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "PseudoBooleanOptimization" | ||
uuid = "c8fa9a04-bc42-452d-8558-dc51757be744" | ||
authors = ["pedromxavier <[email protected]>"] | ||
version = "0.1.1" | ||
version = "0.2.0" | ||
|
||
[deps] | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,3 @@ | ||
varshow(io::IO, v::V) where {V} = show(io, varshow(v)) | ||
varshow(v::Integer, x::AbstractString = "x") = "$(x)$(_subscript(v))" | ||
varshow(v::V) where {V<:Union{Symbol,AbstractString}} = string(v) | ||
|
||
function Base.show(io::IO, ::MIME"text/plain", f::AbstractPBF{V,T}) where {V,T} | ||
if isconstant(f) | ||
print(io, f[nothing]) | ||
|
||
return nothing | ||
end | ||
|
||
terms = sort!(map(((ω, c)::Pair) -> (sort(collect(ω)) => c), pairs(f)); by=first, lt=varlt) | ||
|
||
for (i, (ω, c)) in enumerate(terms) | ||
if i > 1 | ||
if c < zero(T) | ||
print(io, " - ") | ||
else | ||
print(io, " + ") | ||
end | ||
else | ||
if c < zero(T) | ||
print(io, "-") | ||
end | ||
end | ||
|
||
c_ = abs(c) | ||
|
||
if isone(c_) | ||
join(io, varshow.(ω), " ") | ||
else | ||
join(io, [string(c_); varshow.(ω)], " ") | ||
end | ||
end | ||
|
||
return nothing | ||
end | ||
|
||
# function Base.show(io::IO, f::VectorFunction{V,T}) where {V,T} | ||
# join(io, f.Ω, " + ") | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
# Tests | ||
|
||
## Requirements | ||
|
||
- [ ] Constructors | ||
- [ ] Standard Constructor | ||
- [ ] Operators | ||
- [ ] `+` | ||
- [ ] `-` | ||
- [ ] `*` | ||
- [ ] `/` | ||
- [ ] `^` | ||
## Unit Tests | ||
|
||
## Integration Tests | ||
|
||
To run the integration tests, the `PBO_INTEGRATION_TEST` environment variable must be set to a try value. For example: | ||
|
||
```bash | ||
export PBO_INTEGRATION_TEST=1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,47 @@ | ||
module Assets | ||
# Base.get_bool_env will be available in Julia 1.10 and beyond | ||
# Source: | ||
# https://github.com/JuliaLang/julia/blob/3cc4fdc7a11b99a253fb1d4b1b420bb52ac95b69/base/env.jl#L100C1-L136C4 | ||
|
||
using PseudoBooleanOptimization | ||
const GET_BOOL_ENV_TRUTHY = ( | ||
"t", "T", | ||
"true", "True", "TRUE", | ||
"y", "Y", | ||
"yes", "Yes", "YES", | ||
"1" | ||
) | ||
const GET_BOOL_ENV_FALSY = ( | ||
"f", "F", | ||
"false", "False", "FALSE", | ||
"n", "N", | ||
"no", "No", "NO", | ||
"0" | ||
) | ||
|
||
const PBO = PseudoBooleanOptimization | ||
""" | ||
get_bool_env(key::String, default::Bool)::Union{Bool,Nothing} | ||
include("function.jl") | ||
Evaluate whether the value of environnment variable `key` is a truthy or falsy string, | ||
and return `nothing` if it is not recognized as either. If the variable is not set, or is set to "", | ||
return `default`. | ||
Recognized values are the following, and their Capitalized and UPPERCASE forms: | ||
truthy: "t", "true", "y", "yes", "1" | ||
falsy: "f", "false", "n", "no", "0" | ||
""" | ||
function get_bool_env(key::String, default::Bool)::Union{Bool,Nothing} | ||
if !haskey(ENV, key) | ||
return default | ||
end | ||
|
||
val = ENV[key] | ||
|
||
if isempty(val) | ||
return default | ||
elseif val ∈ GET_BOOL_ENV_TRUTHY | ||
return true | ||
elseif val ∈ GET_BOOL_ENV_FALSY | ||
return false | ||
else | ||
return nothing | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.