Opened 3 years ago

Last modified 4 weeks ago

#2938 reviewing defect

The parser for symbolic expressions in infix form parses negative numbers and fractions strangly

Reported by: gkronber Owned by: mkommend
Priority: medium Milestone: HeuristicLab 3.3.17
Component: Problems.DataAnalysis.Symbolic Version: trunk
Keywords: Cc:

Description (last modified by gkronber)

Some examples:

  • Input: -1.0*x + 2.0
  • Expected:
      (+ 
         (* -1.0 x) 
         2.0)
    
  • Output:
    (+ 
      (- (* 1.0 x))
      2.0)
    
  • Input: exp(-1.0*x - 2.0)
  • Output:
    (exp (* 
           -1.0 
           (+ 
             (* 1.0 x) 
             2.0)))
    
  • Expected:
    (exp (- 
           (* -1.0 x)
            2.0))
    
  • Input: 3/3+2/2+1/1
  • Output:
     ((3 * 1/3) + (2 * 1/2) + (1 * 1/1))
    

Change History (11)

comment:1 Changed 3 years ago by gkronber

  • Owner set to gkronber
  • Status changed from new to accepted

comment:2 Changed 3 years ago by gkronber

  • Description modified (diff)
  • Summary changed from The parser for symbolic expressions in infix form parses negative numbers strangly to The parser for symbolic expressions in infix form parses negative numbers and fractions strangly

comment:3 Changed 3 years ago by gkronber

The main problem is that by parsing "-x" as (-1)*x we effectively introduce an additional constant (see non-linear regression). The same issue occurs when parsing "x/y" as "x * 1/y".

Parsing "-3.14" as "(-1)*3.14" is especially strange.

comment:4 Changed 3 years ago by gkronber

  • Version set to trunk

r16357: added comments for infix parser tests

comment:5 Changed 3 years ago by gkronber

We can merge r16357 now or move this ticket to the next milestone.

comment:6 Changed 3 years ago by gkronber

  • Milestone changed from HeuristicLab 3.3.16 to HeuristicLab 3.3.17

comment:7 Changed 4 weeks ago by gkronber

r18167: changed unit test for InfixParser to actually check the results

comment:8 Changed 4 weeks ago by gkronber

r18169: fixed parsing of subtraction and division as well as parsing of unary sign. Additionally, fixed parsing if negative initial values for number symbol (see #3140)

comment:9 Changed 4 weeks ago by gkronber

  • Owner changed from gkronber to mkommend
  • Status changed from accepted to reviewing

comment:10 Changed 4 weeks ago by gkronber

r18171: fixed a bug in the parser

comment:11 Changed 4 weeks ago by gkronber

r18173: fixed BottomUpSimilarityCalculatorTest because the parser now parses (a - b) as (- a b) instead of (+ a (- b))

Note: See TracTickets for help on using tickets.