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

getvars(::Formulation) should return a membersvector #106

Closed
vitornesello opened this issue May 29, 2019 · 3 comments · Fixed by #183
Closed

getvars(::Formulation) should return a membersvector #106

vitornesello opened this issue May 29, 2019 · 3 comments · Fixed by #183
Assignees
Milestone

Comments

@vitornesello
Copy link
Collaborator

To avoid the need of both filters that take a tuple and the own object.
Currently it returns a VarDict

@vitornesello vitornesello added this to the v0.2 milestone May 29, 2019
@vitornesello
Copy link
Collaborator Author

Not trivial.
We could change:

function Base.filter(f::Function, vec::MembersVector)
    MembersVector(vec.elements, Base.filter(e -> f(vec.elements[e[1]]), vec.records))
end

to

function Base.filter(f::Function, vec::MembersVector)
    MembersVector(vec.elements, Base.filter(e -> f(Pair(e[1],vec.elements[e[1]])), vec.records))
end

where e[1] is the Id and vec.elements[e[1]] is the Variable itself.
But the thing get uglier and we will have to check if it allocates memory to do Pair(e[1],vec.elements[e[1]])

@guimarqu
Copy link
Contributor

A way to solve this issue is to replace :

const VarDict = Dict{VarId,Variable}

by

struct VarDict
    variables:: Dict{VarId,Variable}
end

and do the same for constraints. What do you think about that @vitornesello ?

@vitornesello
Copy link
Collaborator Author

This seems good to me. I think it solves the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants