170 likes | 250 Views
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
E N D
Refactoring and Bugfixes February 18th, 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 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
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
BubbleSort Example Target module int∗ bubbleSort(int∗ numbers, int array size ); Source pre-conditions Target pre-conditions
BubbleSort Example Target post-conditions Source post-conditions
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) )
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) ) )
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))) )
QuickSort-ish Example Target module int∗ quickSort(int∗∗ numbers_2D_array, intlow_index, inthigh_index); Source pre-conditions Target pre-conditions
QuickSort Example Target post-conditions Source post-conditions
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) )
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) ) )
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) )
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
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; }
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