| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-10-22 04:25:18 +0200 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-10-22 04:25:18 +0200 | 
| commit | 745e5d1058400266a322ce47dcb3ea2b2cced943 (patch) | |
| tree | 973882a104a5a24d43396fc073bc0f061d3afc38 /src/ataxic_optimize.erl | |
| parent | be2e04aac78b04b4f016c3e0920388bd5c7f5ac6 (diff) | |
Fixes issues with the optimization.
Diffstat (limited to 'src/ataxic_optimize.erl')
| -rw-r--r-- | src/ataxic_optimize.erl | 22 | 
1 files changed, 14 insertions, 8 deletions
| diff --git a/src/ataxic_optimize.erl b/src/ataxic_optimize.erl index cf6cd3a..b1dc048 100644 --- a/src/ataxic_optimize.erl +++ b/src/ataxic_optimize.erl @@ -26,10 +26,10 @@ remove_overridden_operations (List) ->           fun (Elem, CurrentResult) ->              case CurrentResult of                 {done, _} -> CurrentResult; -               {ok, List} -> +               {ok, L} ->                    case Elem of -                     #const{} -> {done, [Elem|List]}; -                     _ -> {ok, [Elem|List]} +                     #const{} -> {done, [Elem|L]}; +                     _ -> {ok, [Elem|L]}                    end              end           end, @@ -166,7 +166,7 @@ optimize_generic_update_sequence     optimize_generic_update_sequence     (        PotentialUpdates, -      (CurrentResults ++ MergedUpdates ++ ImportantOPs), +      (CurrentResults ++ lists:reverse(MergedUpdates) ++ ImportantOPs),        IsCompatible,        IndexIsBefore,        NewUpdate, @@ -233,14 +233,14 @@ optimize_update_orddict_sequence (List) ->           OP        end,        fun (E) -> -         [IX|_] = E#apply_fun.params, +         [#const{ value = IX }|_] = E#apply_fun.params,           IX        end     ).  -spec flatten_sequence (list(ataxic:basic())) -> list(ataxic:basic()).  flatten_sequence (OPs) -> -   lists:foldl +   lists:foldr     (        fun (E, CurrentOPs) ->           case is_record(E, seq) of @@ -285,7 +285,10 @@ aggressive (#seq{ ops = S0OPs }) ->           _ -> S1Result        end, -   S2Result; +   case S2Result of +      #seq{ ops = [OP] } -> OP; +      _ -> S2Result +   end;  aggressive (In = #apply_fun{ params = OPs }) ->     In#apply_fun     { @@ -340,5 +343,8 @@ light (#seq{ ops = S0OPs }) ->           _ -> S1Result        end, -   S2Result; +   case S2Result of +      #seq{ ops = [OP] } -> OP; +      _ -> S2Result +   end;  light (OP) -> OP. | 


