1 / 17

Refactoring and Bugfixes

Refactoring and Bugfixes. February 18 th , 2014 Erik Fredericks. Overview. Updates to fitness and grammar Example output Current tasks. Updates. More changes to fitness and grammar Spoiler: it’s working much better now! Grammar Added wrapper and function pointer constructs

love
Download Presentation

Refactoring and Bugfixes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Refactoring and Bugfixes February 18th, 2014 Erik Fredericks

  2. Overview • Updates to fitness and grammar • Example output • Current tasks

  3. Updates • More changes to fitness and grammar • Spoiler: it’s working much better now! • Grammar • Added wrapper and function pointerconstructs • Modularized pre and post-conditions • Example application can be “dropped” in, as they are defined solely by pre and post-conditions • Assuming grammar representation remains constant

  4. Updates • Fitness • Refactored composition and module-level sub-functions • Added fitness for wrapper and function pointers • Similar to module fitness • Added ordering to pre/post-condition matching for terminals • Added extra terminal(s) to satisfy post-condition matching

  5. BubbleSort Example Target module int∗ bubbleSort(int∗ numbers, int array size ); Source pre-conditions Target pre-conditions

  6. BubbleSort Example Target post-conditions Source post-conditions

  7. BubbleSort Example Output Code Injection COMPOSITION( % precondition xforms DOUBLE2INT(convert-me-to-int),ARR-FLOAT2INT(incoming_array), % module invocation MODULE(bubble_sort,incoming_array,convert-me-to-int), % postconditionxforms ARR-INT2FLOAT(sorted_values) ) COMPOSITION( % precondition xforms DOUBLE2INT(convert-me-to-int), FLATTEN(EXPAND(ARR-FLOAT2INT(incoming_array))), % module invocation MODULE(bubble_sort,convert-me-to-int,incoming_array), % postconditionxforms ARR-INT2FLOAT(sorted_values) )

  8. BubbleSort Example Output Wrapper COMPOSITION( NWRAPPER( % precondition xforms FLATTEN(EXPAND(ARR-FLOAT2INT(incoming_array))), DOUBLE2INT(convert-me-to-int), % module invocation MODULE(bubble_sort,incoming_array,convert-me-to-int), % postconditionxforms ARR-INT2FLOAT(sorted_values) ) )

  9. BubbleSort Example Output Function Pointer COMPOSITION( % precondition xforms ARR-FLOAT2INT(incoming_array), DOUBLE2INT(convert-me-to-int), % target module FN_PTR(MODULE(bubble_sort,convert-me-to-int,incoming_array)), % postconditionxforms FLATTEN(EXPAND(FLATTEN(EXPAND(sorted_values)))), ARR-INT2FLOAT(FLATTEN(EXPAND(sorted_values))) )

  10. QuickSort-ish Example Target module int∗ quickSort(int∗∗ numbers_2D_array, intlow_index, inthigh_index); Source pre-conditions Target pre-conditions

  11. QuickSort Example Target post-conditions Source post-conditions

  12. QuickSort Example Output Code Injection COMPOSITION( % precondition xforms DOUBLE2INT(convert-me-to-int), EXPAND(ARR-FLOAT2INT(incoming_array)), CHAR2INT(FLOAT2CHAR(num_cols)), % target module MODULE(quicksort,convert-me-to-int,incoming_array,num_cols), % postconditionxforms EXPAND(sorted_values) )

  13. QuickSort Example Output Wrapper COMPOSITION( NWRAPPER( % precondition xforms EXPAND(ARR-FLOAT2INT(incoming_array)), DOUBLE2INT(convert-me-to-int), FLOAT2INT(num_cols), % target module MODULE(quicksort,convert-me-to-int,incoming_array,num_cols), % postconditionxforms EXPAND(sorted_values) ) )

  14. QuickSort Example Output Function Pointer COMPOSITION( % precondition xforms CHAR2INT(DOUBLE2CHAR(convert-me-to-int)), EXPAND(ARR-FLOAT2INT(incoming_array)), FLOAT2INT(num_cols), % target module FN_PTR(MODULE(quicksort,num_cols,convert-me-to-int,incoming_array)), % postconditionxforms FLATTEN(EXPAND(sorted_values)), EXPAND(sorted_values) )

  15. Current Tasks • Value representation • Working on backend factory implementation • Provide abstract representation of value, based upon run-time context • Updates to get “correct” output took precedence this past week

  16. Current Tasks • Parse tree translator • Working on code generation based on generated parse tree COMPOSITION( WRAPPER( FLOAT2INT(number), TARGET_METHOD(method,number), INT2FLOAT(returned_number) ) ) float module_wrapper(float); void main() { float number; module_wrapper(number); } float module_wrapper(float in_val) { intretval; inttemp_val = (int)in_val; retval = method(temp_val); return (float)retval; }

  17. Discussion Point • One thing I have noticed is that fitness converges quite early • Configured to run for 500 generations, and best fitness is typically found within 50

More Related