Difference between SXMatrix and MXMatrix?

2012-04-24
2013-04-11
  • Ruge, Vitalij

    Ruge, Vitalij - 2012-04-24

    Hello all,
    I not underunderstand the difference between SXMatrix and MXMatrix.
    In the code examples I see as Input for IpoptSolver MX.
    What is the reason? Why not SX?
    I think SX is faster.

    Thanks,
    Vitalij

     
  • Joel Andersson

    Joel Andersson - 2012-04-24

    Hello Vitalij,

    there is no such thing as an MXMatrix. There is SXMatrix and there is MX, which represent two different ways of representing symbolic expressions. Please check the user's guide, there is some information about it there. In short, SX (and SXMatrix) splits up symbolic expressions into scalar operations. This part of CasADi is relatively mature and fast. MX allows you to build up symbolic expressions that consist of matrix-valued operations. This makes it possible for example to embed integrator calls into symbolic expressions. It is also more economical for very large expressions that are naturally matrix-valued. You can convert a MX symbolic expression into an SX symbolic expression, if it is only made up by simple components like binary operations, assignments etc.

    I am not sure what you mean that MX is "input" to the IpoptSolver. You can indeed embed an IpoptSolver instance into an MX symbolic expression, but I don't see a good reason for doing so. If you mean the constructor of IpoptSolver, it takes a function, which can be formulated using "SX" or "MX", or in several other ways.

    Hope this helped,
    Joel

     
  • Joel Andersson

    Joel Andersson - 2012-04-24

    One more thing, for the code examples, if you pass the option: "expand_f" -> True and  "expand_g" -> True, then all calculations will be made using SX, even if you formulated your problem using MX.

    Best,
    Joel

     
  • Ruge, Vitalij

    Ruge, Vitalij - 2012-04-24

    Thank you Joel.
    Now I understand more.

    Best,
    Vitalij

     

Log in to post a comment.