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

Zonotope membership test using simplex #247

Merged
merged 5 commits into from
Feb 18, 2018
Merged

Zonotope membership test using simplex #247

merged 5 commits into from
Feb 18, 2018

Conversation

mforets
Copy link
Member

@mforets mforets commented Feb 16, 2018

Closes #246.

Copy link
Member

@schillic schillic left a 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]]
Copy link
Member

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)]
Copy link
Member

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

Copy link
Member Author

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
Copy link
Member

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
Copy link
Member

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

Copy link
Member Author

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.)

Copy link
Member

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"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, thanks

@mforets
Copy link
Member Author

mforets commented Feb 16, 2018

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?

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.

@schillic
Copy link
Member

schillic commented Feb 16, 2018

Thanks. I suggest to just test what happens when you input a Zonotope{Rational{Int}}. If it works, then we can leave it as is. Otherwise we should at least crash with a clear explanation.

src/Zonotope.jl Outdated
- `Z` -- zonotope
- `x` -- point/vector
- `Z` -- zonotope
- `solver` -- (optiona, default: `GLPKSolverLP(method=:Simplex)`) the backend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"optional"

@schillic
Copy link
Member

Is there a reason why you use fill instead of zeros/ones?

@mforets
Copy link
Member Author

mforets commented Feb 17, 2018

it works using method=:Exact; compare:

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 Float64 though. but clearly glp_exact is triggered.

@mforets
Copy link
Member Author

mforets commented Feb 17, 2018

Is there a reason why you use fill instead of zeros/ones?

no

@schillic
Copy link
Member

i wouldn't expect that for the former case it returns values in Float64 though. but clearly glp_exact is triggered.

Yes, that looks strange, but maybe it can automatically work with floats if possible for efficiency.

@mforets mforets merged commit da7d386 into master Feb 18, 2018
@mforets mforets deleted the mforets/246 branch February 18, 2018 14:05
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 this pull request may close these issues.

2 participants