random_int_expr_mutation(Node,Mutation) :-
prob_is_ground(Node,Res) , Res = true ,
replace_ground_with_expr(Node,Mutation).
random_int_expr_mutation(b(Expression,integer,Info),b(NewExpression,integer,Info)) :-
Expression =.. [Type,Expr1,Expr2] ,
member(Type,[add,minus,multiplication,div,modulo,power_of]) ,
% random choice heuristic for argument
random(0,3,R) ,
% if expression is ground replace its value by an arithmetic expression
random_int_expr_mutation_aux(R,Expr1,Expr2,NewExpr1,NewExpr2) ,
NewExpression =.. [Type,NewExpr1,NewExpr2].
random_int_expr_mutation(b(Expression,integer,Info),b(NewExpression,integer,Info)) :-
Expression =.. [Type,Expr1,Expr2] ,
random_int_expr_mutation(Expr1,NewExpr1) ,
random_int_expr_mutation(Expr2,NewExpr2) ,
NewExpression =.. [Type,NewExpr1,NewExpr2].
random_int_expr_mutation(b(Expression,integer,Info),b(NewExpression,integer,Info)) :-
Expression =.. [Type,_] ,
\+member(Type,[max,min]) ,
(prob_is_ground(b(Expression,integer,Info),true)
-> replace_ground_with_expr(b(Expression,integer,Info),NewExpr)
; random_int_expr_mutation(b(Expression,integer,Info),NewExpr)) ,
NewExpression =.. [Type,NewExpr].
random_int_expr_mutation(Expression,Expression).