-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new NLPModelMeta constructor (#471)
* Add meta constructor Co-authored-by: Tangi Migot <[email protected]>
- Loading branch information
1 parent
1534231
commit 6ebae68
Showing
2 changed files
with
72 additions
and
2 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,3 +1,24 @@ | ||
@testset "A problem with zero variables doesn't make sense." begin | ||
@test_throws ErrorException NLPModelMeta(0) | ||
end | ||
|
||
@testset "Meta copier." begin | ||
nlp = SimpleNLPModel() | ||
|
||
# Check simple copy | ||
meta = NLPModelMeta(nlp.meta) | ||
for field in fieldnames(typeof(nlp.meta)) | ||
@test getfield(nlp.meta, field) == getfield(meta, field) | ||
end | ||
|
||
modif = Dict(:nnzh => 1, :x0 => [2.0; 2.0; 0.0], :nvar => 3, :lvar => zeros(3), :uvar => [1.0; 1.0; 0.0]) | ||
meta = NLPModelMeta(nlp.meta; modif...) | ||
|
||
for field in setdiff(fieldnames(typeof(nlp.meta)), union(keys(modif),[:ifix])) | ||
@test getfield(nlp.meta, field) == getfield(meta, field) | ||
end | ||
for field in keys(modif) | ||
@test getfield(meta, field) == modif[field] | ||
end | ||
@test meta.ifix == [3] | ||
end |