Opened 13 years ago
Closed 13 years ago
#1314 closed enhancement (done)
Implement representation of symbolic expressions in MATLAB syntax
Reported by: | swinkler | Owned by: | gkronber |
---|---|---|---|
Priority: | high | Milestone: | HeuristicLab 3.3.3 |
Component: | Problems.DataAnalysis | Version: | 3.3.3 |
Keywords: | Cc: |
Description
Attachments (2)
Change History (27)
comment:1 Changed 13 years ago by swinkler
- Status changed from new to accepted
comment:2 Changed 13 years ago by swinkler
comment:3 Changed 13 years ago by gkronber
Please adhere to our development guidelines.
[...]
- Casing:
- Classes, interfaces, properties, and methods start with an uppercase letter (e.g. Sheep, Weight, LookABitSilly).
- Fields, method parameters, and local variables start with a lowercase letter (e.g. sheep, weight, i).
comment:4 Changed 13 years ago by gkronber
Adapted complex program code in MATLAB exporter and reformatted code to adhere to HL coding guidelines with r5019.
comment:5 Changed 13 years ago by gkronber
ad r5019: if you don't want duplicates, append .Distinct() to the LINQ statement.
comment:6 Changed 13 years ago by swinkler
Thanks for improving the variable names retrieval; updated variable names selection in r5020.
comment:7 Changed 13 years ago by swinkler
Corrected evaluation of logical expressions in r5021.
Changed 13 years ago by swinkler
Script for evaluating MATLAB representations of formulas on the Tower dataset.
comment:8 Changed 13 years ago by swinkler
I have tested MATLAB representations of several formulas including arithmetical as well as logical functions on the Tower dataset; in general, the conversion seems to work properly, the estimated values are equal in HL and in MATLAB. Of course, this still needs more testing and review.
I have identified the following problem: The use of the logarithm function is not straight forward. In HL, Math.Log is used and for a nonpositive number this function returns n.def.; in MATLAB, the log of a negative number is a complex number. If the logarithm of a negative number is the condition of a IF node, then we interpret this as false in HL (because (n.def.>0)==false), and in MATLAB the interpretation is true (because a complex number is not equal to 0). We would therefore have to check if the argument is positive or not. I have not yet found a way to solve this, since I have not (yet) found something like the "?" operator we know from C++/C#, e.g.
comment:9 Changed 13 years ago by gkronber
A quick google search revealed that indeed MATLAB doesn't support a ternary operator and that two solutions are suggested to overcome this problem:
- define an anonymous function that wraps the if statement
- reformulate the expression to use a non-differentiable function like floor(), ceil(), sign(), dirac()
comment:10 Changed 13 years ago by gkronber
Could this work?
log(x) (sign(x) + 1) / 2
comment:11 Changed 13 years ago by swinkler
I suggest that we define a modified version of the log function for MATLAB that behaves like the log function used in HL:
function y = log_(x) if (x<=0) y = NaN; else y = log(x);
comment:12 Changed 13 years ago by gkronber
looks nice
comment:13 Changed 13 years ago by swinkler
Added special version of log function that behaves like Math.Log in r5022.
comment:14 Changed 13 years ago by swinkler
Updated projects in exporters branch reacting on recent changes in the trunk (.NET 4.0, changes in interface of dataset) in r5180.
comment:15 Changed 13 years ago by gkronber
- Owner changed from swinkler to gkronber
- Status changed from accepted to reviewing
comment:16 Changed 13 years ago by gkronber
r5416: Merged changes to symbolic expression encoding related to refactoring text-based export formats for symbolic expression trees.
comment:17 Changed 13 years ago by gkronber
- Status changed from reviewing to assigned
comment:18 Changed 13 years ago by gkronber
r5431: merged MATLAB formatter from branch into trunk and implemented formatting rules for new symbols related to dynamic modeling.
comment:19 Changed 13 years ago by gkronber
- Owner changed from gkronber to swinkler
- Status changed from assigned to reviewing
comment:20 Changed 13 years ago by swinkler
- Status changed from reviewing to assigned
comment:21 Changed 13 years ago by swinkler
- Status changed from assigned to accepted
comment:22 Changed 13 years ago by swinkler
Fixed bugs in r5433.
comment:23 Changed 13 years ago by swinkler
- Owner changed from swinkler to gkronber
- Status changed from accepted to reviewing
comment:24 Changed 13 years ago by gkronber
- Status changed from reviewing to readytorelease
Reviewed r5433. Thanks for fixing the bugs. This feature is ready for release.
comment:25 Changed 13 years ago by mkommend
- Resolution set to done
- Status changed from readytorelease to closed
- Version changed from 3.3.2 to 3.3.3
Added first version of MATLAB exporter in r5017. Improved GUI of symbolic expression view in r5018.