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

Known bugs, TODO, FIXME #1

Closed
Lecrapouille opened this issue Sep 8, 2019 · 9 comments
Closed

Known bugs, TODO, FIXME #1

Lecrapouille opened this issue Sep 8, 2019 · 9 comments

Comments

@Lecrapouille
Copy link
Owner

Lecrapouille commented Sep 8, 2019

  • [JULIA BUG] Patch inside MaxPlus made against Julia >= 0.7 regession concerning identity matrices: calling [bool(true) zero(MP); zero(MP) bool(true)] instead of [one(MP) zero(MP); zero(MP) one(MP)] like done in Julia 0.4 See Matrix identity not calling one() ? JuliaLang/LinearAlgebra.jl#659 but could be nice to find a correct fix for Julia.
  • [JULIA BUG] A^0 does not return the correct MP identity matrix because of the Julia bug of identity.
  • [JULIA BUG] SparseMatrixCSC == Still because of erroneous zero() https://github.com/JuliaLang/julia/issues/33332
  • SparseMatrixCSC
julia> A = MP(sparse([1, 2], [1, 2], [0.0, 0]))
2×2 SparseMatrixCSC{MP{Float64},Int64} with 2 stored entries:
  [1, 1]  =  0
  [2, 2]  =  0

julia> B = mpzeros(Float64, 2,2)
2×2 SparseMatrixCSC{MP{Float64},Int64} with 0 stored entries

julia> A == B
true # Should be false

No because sparse() can store 0 elements and 0 elements are not Max-Plus 0 elements. MP(sparse([1, 2], [1, 2], [-Inf, -Inf])) == mpzeros(Float64, 2,2) will return true

  • [JULIA BUG] SparseMatrixCSC = Still because of same reason: confusion with zero()
julia> A=spzeros(Float64, 2,2)
julia> A[1,1] = 0.0
julia> A
2×2 SparseMatrixCSC{Float64,Int64} with 0 stored entries
# Should be
# 2×2 SparseMatrixCSC{MP{Float64},Int64} with 1 stored entries:
#  [1, 1]  =  0
  • [JULIA BUG] Do not use length() and isempty() for sparse. This returns wrong informations. See
    issue 33360
  • [TODO] A^-k A: matrix or sparce
  • [TODO] add full mpzeros and sparse mpeye
  • [MP BUG] mp0 - mp0 return NaN instead of mp0 Same behavior than Scilab
  • [MP BUG] mptop * mp0 shall return mp0 but return NaN
  • [TODO] Upgrade syslin() to add B, C, D matrixes
  • [UPGRADE] syslin: union entre sparse et dense
  • [UPGRADE] flowshop: Petri transition are for the moment displayed with arrows.
  • [MP BUG] star(mpeye) is incorrect (cannot reproduce)
  • [UPGRADE] syslin: use dense matrices instead of sparse (only used for D and x0 in ScicosLab)
  • [UPGRADE] syslin: pretty print show()
    | .  3 |    | .  1 |    | 1 |
x = | .  . |x + | .  . |x'+ | 1 |u   
 
y = | 1  1 |x 
  • [UPGRADE] syslin: show() print if implicit or explicit sys lin in this last case do not show D matrix.
  • [UPGRADE] Check if simul() uses explicit system? Add security for composition? Avoid computing mpexplicit if already explicit. Avoid to compute identity matrix as optimisation ?
  • [UPGRADE] Faire: mpeye(2,2) = mpeye(Float64,2,2) idem pout mpzeros, mpones
  • [MP BUG] Cannot write mpzero(Float32): infinite loop.
  • [MP BUG] Regression: show() seems to have regressed. There are unwanted extra spaces. This is strange because in early commits of this package I could show matrices mixing epsilon or '.' and integers. Now
2×2 Array{MP{Float64},2}:
 ε    e
  e  ε 

Fixed!

  • [UPGRADE] is it possible to define in Julia  Base.:(*)(x::Val(IdentityMatrix), y::Array{MP]) = y ?
@Lecrapouille Lecrapouille changed the title TODO TODO / FIXME Sep 9, 2019
@Lecrapouille Lecrapouille changed the title TODO / FIXME Known bugs Sep 22, 2019
@Lecrapouille Lecrapouille changed the title Known bugs Known bugs, TODO, FIXME Sep 23, 2019
@hurak
Copy link
Collaborator

hurak commented Oct 6, 2022

I hope that my comment/advice will not be viewed as trying to lecture you, but I think that keeping a separate Github Issue for each entry in your list will make the whole process more convenient (rather then keeping all issues in a single text file). Both for you and possibly for users. But of course it is completely up to you. I only wanted to share my own experience.

@Lecrapouille
Copy link
Owner Author

@hurak :) thank you are right! And better than opening several issues for my todo list is to use directly the GitHub dashboard feature.

I also apply what you say but since my projects usually does not interest many people (25 view, 2 clones on 2 weeks), and because of my family disturb me interrupting my work I accustomed committing partial/uncompleted commit/work not to lose it and I rebase and git push force (yeah not nice!).

For this particular project, the git history is quite dirty because I did some stop, stalled and go steps. The master is stable and on Julia store, but the dev branch is undone, the comments do no longer match code and I do not remember what I've done in the code and I should end it to merge to the master branch and on Julia.

Tell me if you are interested in this project, I can free up some time to make the dev branch in stable state. I also think that Julia is missing petri net editor (the other repo you posted tickets) and to follow https://discourse.julialang.org/t/good-way-for-creating-a-julia-project-binding-a-c-project/85595

@hurak
Copy link
Collaborator

hurak commented Oct 7, 2022

Well, I think that having a nice and maintained package for (max,+) algebra in Julia will finally be appreciated by a (reasonably) wider community.

I guess that the computational wisdom and experience implemented in Julia stands a good chance to eventually reach more people than its counterpart in Scilab (or whatever its derivatives). And even a slightly differently composed community, I guess, things changed with the rise of popularity of machine learning. And (max,+) stuff is not far, is it?

I cannot guarantee it, though, because I do not really do research (yet) in this area. As an academic researcher and educator in control systems (my group webpage) I am more focused on the continuous-valued and time-driven dynamics. But I decided to include some discrete-event systems lectures in my brand new graduate course on hybrid systems. And (max,+) algebra is fairly appealing for us, control engineers, for its conceptual closeness with the discrete-time state-space models. I have only recently learnt about this framework. And it appears that some other researchers in control engineering already did quite some interesting work. Just in case you are not aware, there is a series of paper by Bart de Schutter and his colleagues ans students, for example:

  • van den Boom, Ton J. J., and De Schutter, Bart. “Model Predictive Control of Manufacturing Systems with Max-Plus Algebra.” In Formal Methods in Manufacturing, edited by Javier Campos, Carla Seatzu, and Xiaolan Xie, 343--378. Boca Raton: CRC Press, 2014. https://www.dcsc.tudelft.nl/~bdeschutter/pub/rep/14_002.pdf.
  • De Schutter, Bart, and Ton van den Boom. “Model Predictive Control for Max-plus-Linear Discrete Event Systems.” Automatica 37, no. 7 (July 1, 2001): 1049–56. https://doi.org/10.1016/S0005-1098(01)00054-1.
  • De Schutter, Bart, Ton van den Boom, Jia Xu, and Samira S. Farahani. “Analysis and Control of Max-plus Linear Discrete-Event Systems: An Introduction.” Discrete Event Dynamic Systems 30, no. 1 (March 1, 2020): 25–54. https://doi.org/10.1007/s10626-019-00294-w.

At least with this limited exposure, I like the framework. And I am trying to popularize it among my students. And I am directing my students to your package, besides the Matlab toolbox by Jarosław Stańczyk. But obviously I am developing some personal preference for Julia :-)

In fact, I already started rewriting (and shortening a bit) your tutorial Jupyter notebook in English :-) But I only started yesterday :-)

So, yes, if you still enjoy this work, go ahead, it will be appreciated and perhaps somebody even joins you in this :-) I believe that there is indeed some potential if you package is cleverly interfaced to some optimization solvers so the Bart De Schutter's style MPC problems can be formulated and solved. But again, take me with some reservation, I am not really in this research area (yet).

@Lecrapouille
Copy link
Owner Author

@hurak Excellent you have the direct link to Jarosław Stańczyk job. I could not find it anymore (dead url), so I made a fork https://github.com/Lecrapouille/MP else you should have a look to my father webpage https://github.com/jpquadrat/jpquadrat.github.io he worked a lot of (max,+) and his page contains lot of PDF on this point (plus his book https://www.rocq.inria.fr/metalau/cohen/SED/book-online.html).

Ok I will free up some time for updating this package.

@Lecrapouille
Copy link
Owner Author

@hurak I have almost done fixing the code to get back the retro-compatibility (ε .λ, ...) You can commit your changes concerning the tutorial even if unfinished or not working I'll fix it on the fly.

@Lecrapouille
Copy link
Owner Author

@hurak I added some comments in the core part. Hope to be understandable.

Next steps on my side will be:

  • Clean the docstrings.jl
  • Fix some "Max-Plus" printed instead of (max+,) with the show() functions.
  • Fix issues for syslin and hpward algorithm: I hate the Julia distinction between Vector and Matrix.
  • Translate tutorials to English.
  • Implement missing flowshop functions and tutorials

@hurak
Copy link
Collaborator

hurak commented Oct 8, 2022

I hate the Julia distinction between Vector and Matrix

I have finally started liking it. I have been working with Matlab for twenty years, therefore I initially found Julia's style disturbing, but now I think I like it better than Matlab's style. You may find the discussions at https://discourse.julialang.org/t/should-transpose-of-a-vector-be-a-matrix/87444 and JuliaLang/LinearAlgebra.jl#42 interesting. There is also a nice talk https://youtu.be/C2RO34b_oPM. It is certainly complicated. But Julia' convention is reasonably well though-out, I guess.

@Lecrapouille
Copy link
Owner Author

@hurak yes this is a huge topic, I quickly read threads I did not see people talking about the cache-miss specially when seeing Wolfram doc : matrix is a list of list. When iterating along the vector one by one is ok but when iterating on a single element for each vector this takes more time. Also remembering OpenGL specification doing Matrix as M . x where x is column but the implementation x is line major and therefore instead of doing x' . M they keep doing M . x but with a product where they iterate differently ... all beginners are lost specially when reading tutorials people implementing C++ Vector3f as a pure array that can be used either as line or column vector depending on the context of the matrix operation (meaning no compilation checking against dimensions Lecrapouille/OpenGLCppWrapper#3 ) ... whatever :D

@Lecrapouille
Copy link
Owner Author

PS: also in the code I made some non optimized operations sparse => full like

# ==============================================================================

Also to notice that in Scilab zeros(n,m) creates a sparse matrix while Julia is offering dense zeros() and sparse spzeros(). Scilab behavior makes more sense, particularly we can have huge sparse matrices (i.e. flowshops). But I understand Julia API shall offer both.

We have also to check that Julia newer version does not make regressions because a developer did not take care to distinguish between 0 and zero().

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

No branches or pull requests

2 participants