codac icon indicating copy to clipboard operation
codac copied to clipboard

Bug with the Matlab version

Open cviel opened this issue 2 years ago • 1 comments

I have tested the package with Matlab and there are several problems that prevent it from being used :

  • It is impossible to have access to the variable in the interval (ex: for x = Interval(1,2), I have tried to use x[1], x(1) or x{1} but I cannot obtain a value)
  • The function "IntervalVector" return a wrong interval : y = IntervalVector([[3,4],[4,6]]) should give me [y]= [3,4]×[4,6] but matlab return (<3, 3.000000000000001> ; <4, 4.000000000000001> ; <4, 4.000000000000001> ; <6, 6.000000000000001>) i.e. [3,3]x[4,4]x[4,4]x[6,6]
  • the function Interval.EMPTY_SET doesn't work (but you can create an empty set by writing something like "Interval(2,-1)")
  • the function IntervalVector([a,a]) with a = Interval(1,2) doesn't work (with the python module it returns [a,a]x[a,a])
  • the function max() and min() don't work

I can't test the validity of the function "Function" since IntervalVector returns a wrong result, so to be tested. Good luck to fix it, and thank you for your work !

cviel avatar Nov 23 '23 13:11 cviel

Indeed, here are some quick answers:

  • The current workaround would be x.getitem(int32(0)) from

The operator [index] for a Codac object should be replaced with .getitem(int32(index)) [...] indices of Codac objects start at 0...

on https://www.codac.io/install/04-start-matlab-project.html . We plan to try to simplify this notation to something like x.i(0), if there is no side effect.

  • The current workaround would be y = IntervalVector(py.list({Interval(3,4),Interval(4,6)})) from

Python lists of objects should be converted to MATLAB cell arrays. [...] when a Codac function needs a py.list or Vector parameter, the corresponding MATLAB cell array should be given as py.list(…)

I do not know yet if there would be a simple way to simplify this.

  • MATLAB should give a hint to try Interval().EMPTY_SET.
  • IntervalVector(py.list({a,a})), see 2nd point.
  • Maybe x.ub() and x.lb() could be used instead? Maybe we should make max(x) and min(x) return this, I don't think it is currently done for any programming language.

lebarsfa avatar Nov 23 '23 16:11 lebarsfa