import * as neataptic from "neataptic" import { ActivationFn } from "./activation" export const allMutationName = [ "ADD_NODE", "SUB_NODE", "ADD_CONN", "REMOVE_CONN", "MOD_WEIGHT", "MOD_BIAS", "MOD_ACTIVATION", "ADD_SELF_CONN", "SUB_SELF_CONN", "ADD_GATE", "SUB_GATE", "ADD_BACK_CONN", "SUB_BACK_CONN", "SWAP_NODES", ] as const export type MutationName = typeof allMutationName[number] export type Mutation = { name: MutationName, } & T export const ADD_NODE: Mutation<{}> = neataptic.methods.mutation.ADD_NODE export const SUB_NODE: Mutation<{keep_gates: boolean}> = neataptic.methods.mutation.SUB_NODE export const ADD_CONN: Mutation<{}> = neataptic.methods.mutation.ADD_CONN export const SUB_CONN: Mutation<{}> = neataptic.methods.mutation.SUB_CONN export const REMOVE_CONN: Mutation<{}> = neataptic.methods.mutation.SUB_CONN export const MOD_WEIGHT: Mutation<{min: number, max: number}> = neataptic.methods.mutation.MOD_WEIGHT export const MOD_BIAS: Mutation<{min: number, max: number}> = neataptic.methods.mutation.MOD_BIAS export const MOD_ACTIVATION: Mutation<{mutateOutput: boolean, allowed: ActivationFn[]}> = neataptic.methods.mutation.MOD_ACTIVATION export const ADD_SELF_CONN: Mutation<{}> = neataptic.methods.mutation.ADD_SELF_CONN export const SUB_SELF_CONN: Mutation<{}> = neataptic.methods.mutation.SUB_SELF_CONN export const ADD_GATE: Mutation<{}> = neataptic.methods.mutation.ADD_GATE export const SUB_GATE: Mutation<{}> = neataptic.methods.mutation.SUB_GATE export const ADD_BACK_CONN: Mutation<{}> = neataptic.methods.mutation.ADD_BACK_CONN export const SUB_BACK_CONN: Mutation<{}> = neataptic.methods.mutation.SUB_BACK_CONN export const SWAP_NODES: Mutation<{}> = neataptic.methods.mutation.SWAP_NODES export const ALL: Mutation[] = neataptic.methods.mutation.ALL export const FFW: Mutation[] = neataptic.methods.mutation.FFW export function getMutation(name: MutationName | "SUB_CONN"): Mutation { return (name === "REMOVE_CONN") ? neataptic.methods.mutation.SUB_CONN : neataptic.methods.mutation[name] }