-
Notifications
You must be signed in to change notification settings - Fork 32
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
Zonotope membership test using simplex #247
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand what happens here. I see that you add one dimension for the objective function, but why does the solution have to be optimal? Can you add some more documentation what happens here?
src/Zonotope.jl
Outdated
return false | ||
end | ||
p, n = ngens(Z), dim(Z) | ||
A = [[1.; fill(0, p)]'; [fill(0., n) Z.generators]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one(N)
resp. zero(N)
(also below)
In fact, instead of fill
you can use zeros(N, p)
, right? (same for ones
and also below)
Does this always result in the correct dimensions, for any n
and p
? It is not easy to read for me...
src/Zonotope.jl
Outdated
A = [[1.; fill(0, p)]'; [fill(0., n) Z.generators]] | ||
b = [0.; (x - Z.center)] | ||
lbounds = [0; fill(-1., p)] | ||
ubounds = [Inf; fill(1., p)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if there is a type-parametric Inf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N(Inf)
should do it
src/Zonotope.jl
Outdated
|
||
lp = linprog(obj, A, sense, b, lbounds, ubounds, solver) | ||
res = (lp.status == :Optimal) # Infeasible of Unboudned => false | ||
return res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return immediately?
src/Zonotope.jl
Outdated
obj = [1.; fill(0, p)] | ||
|
||
lp = linprog(obj, A, sense, b, lbounds, ubounds, solver) | ||
res = (lp.status == :Optimal) # Infeasible of Unboudned => false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "Infeasible of Unboudned" mean?
also a typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
infeasible means that there is no solution satisfying the constraints; unbounded if the feasible set is unbounded towards the direction of descent of the gradient of the objective function (but this is not the case in this instance since we take min x0
and 0<=x0<=infty
, so it will return infeasible if the membership test fails.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it should be "if" instead of "of"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thanks
i improved the docstring (and removed the previous one, i didn't see that it was above!) for the type-parametric issue, i would have to investigate it further how we can enable this, since the computations ultimately relies on the LP solver backend used. |
Thanks. I suggest to just test what happens when you input a |
src/Zonotope.jl
Outdated
- `Z` -- zonotope | ||
- `x` -- point/vector | ||
- `Z` -- zonotope | ||
- `solver` -- (optiona, default: `GLPKSolverLP(method=:Simplex)`) the backend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"optional"
Is there a reason why you use |
it works using julia> lp = linprog(obj, A, sense, b, lbounds, ubounds, GLPKSolverLP(method=:Exact))
glp_exact: 3 rows, 3 columns, 3 non-zeros
GNU MP bignum library is being used
0: infsum = 0.2 (0)
2: infsum = 0 (0)
* 2: objval = 0 (0)
* 2: objval = 0 (0)
OPTIMAL SOLUTION FOUND
MathProgBase.HighLevelInterface.LinprogSolution(:Optimal, 0.0, [0.0, 0.0, 0.0], Dict{Any,Any}(Pair{Any,Any}(:lambda, [0.0, 0.0, 0.0]),Pair{Any,Any}(:redcost, [1.0, 0.0, 0.0]))) and julia> lp = linprog(obj, A, sense, b, lbounds, ubounds, GLPKSolverLP(method=:Simplex))
MathProgBase.HighLevelInterface.LinprogSolution(:Optimal, 0.0, [0.0, 0.0, 0.0], Dict{Any,Any}(Pair{Any,Any}(:lambda, [0.0, 0.0, 0.0]),Pair{Any,Any}(:redcost, [1.0, 0.0, 0.0]))) i wouldn't expect that for the former case it returns values in |
no |
Yes, that looks strange, but maybe it can automatically work with floats if possible for efficiency. |
Closes #246.