diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..35410ca
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/deployment.xml b/.idea/deployment.xml
new file mode 100644
index 0000000..9bc19b1
--- /dev/null
+++ b/.idea/deployment.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..1a7194a
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..cb6b5a8
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ac86cb7
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/neatax.iml b/.idea/neatax.iml
new file mode 100644
index 0000000..6a5a346
--- /dev/null
+++ b/.idea/neatax.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/algorithms/__pycache__/__init__.cpython-311.pyc b/algorithms/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..914934a
Binary files /dev/null and b/algorithms/__pycache__/__init__.cpython-311.pyc differ
diff --git a/algorithms/neat/__pycache__/__init__.cpython-311.pyc b/algorithms/neat/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..e5019e8
Binary files /dev/null and b/algorithms/neat/__pycache__/__init__.cpython-311.pyc differ
diff --git a/algorithms/neat/__pycache__/function_factory.cpython-311.pyc b/algorithms/neat/__pycache__/function_factory.cpython-311.pyc
new file mode 100644
index 0000000..519e3f0
Binary files /dev/null and b/algorithms/neat/__pycache__/function_factory.cpython-311.pyc differ
diff --git a/algorithms/neat/__pycache__/pipeline.cpython-311.pyc b/algorithms/neat/__pycache__/pipeline.cpython-311.pyc
new file mode 100644
index 0000000..c8a913b
Binary files /dev/null and b/algorithms/neat/__pycache__/pipeline.cpython-311.pyc differ
diff --git a/algorithms/neat/__pycache__/species.cpython-311.pyc b/algorithms/neat/__pycache__/species.cpython-311.pyc
new file mode 100644
index 0000000..7ac4fd4
Binary files /dev/null and b/algorithms/neat/__pycache__/species.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/__init__.cpython-311.pyc b/algorithms/neat/genome/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..27827d1
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/__init__.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/activations.cpython-311.pyc b/algorithms/neat/genome/__pycache__/activations.cpython-311.pyc
new file mode 100644
index 0000000..f64667f
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/activations.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/aggregations.cpython-311.pyc b/algorithms/neat/genome/__pycache__/aggregations.cpython-311.pyc
new file mode 100644
index 0000000..b79e718
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/aggregations.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/crossover.cpython-311.pyc b/algorithms/neat/genome/__pycache__/crossover.cpython-311.pyc
new file mode 100644
index 0000000..28a8c51
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/crossover.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/distance.cpython-311.pyc b/algorithms/neat/genome/__pycache__/distance.cpython-311.pyc
new file mode 100644
index 0000000..4cdf786
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/distance.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/forward.cpython-311.pyc b/algorithms/neat/genome/__pycache__/forward.cpython-311.pyc
new file mode 100644
index 0000000..2687d14
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/forward.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/genome.cpython-311.pyc b/algorithms/neat/genome/__pycache__/genome.cpython-311.pyc
new file mode 100644
index 0000000..781f1de
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/genome.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/graph.cpython-311.pyc b/algorithms/neat/genome/__pycache__/graph.cpython-311.pyc
new file mode 100644
index 0000000..91a6cd7
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/graph.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/mutate.cpython-311.pyc b/algorithms/neat/genome/__pycache__/mutate.cpython-311.pyc
new file mode 100644
index 0000000..c6750b0
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/mutate.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/__pycache__/utils.cpython-311.pyc b/algorithms/neat/genome/__pycache__/utils.cpython-311.pyc
new file mode 100644
index 0000000..fd6d129
Binary files /dev/null and b/algorithms/neat/genome/__pycache__/utils.cpython-311.pyc differ
diff --git a/algorithms/neat/genome/genome.py b/algorithms/neat/genome/genome.py
index 535b352..6a34cbe 100644
--- a/algorithms/neat/genome/genome.py
+++ b/algorithms/neat/genome/genome.py
@@ -193,6 +193,13 @@ def pop_analysis(pop_nodes, pop_connections, input_keys, output_keys):
return res
+@jit
+def count(nodes, connections):
+ node_cnt = jnp.sum(~jnp.isnan(nodes[:, 0]))
+ connections_cnt = jnp.sum(~jnp.isnan(connections[0, :, :]))
+ return node_cnt, connections_cnt
+
+
@jit
def add_node(new_node_key: int, nodes: Array, connections: Array,
bias: float = 0.0, response: float = 1.0, act: int = 0, agg: int = 0) -> Tuple[Array, Array]:
diff --git a/algorithms/neat/pipeline.py b/algorithms/neat/pipeline.py
index c8009a5..9396556 100644
--- a/algorithms/neat/pipeline.py
+++ b/algorithms/neat/pipeline.py
@@ -7,7 +7,7 @@ import numpy as np
from .species import SpeciesController
from .genome import expand, expand_single
from .function_factory import FunctionFactory
-
+from .genome.genome import count
class Pipeline:
"""
diff --git a/examples/__pycache__/__init__.cpython-311.pyc b/examples/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..c75c8b1
Binary files /dev/null and b/examples/__pycache__/__init__.cpython-311.pyc differ
diff --git a/examples/__pycache__/time_utils.cpython-311.pyc b/examples/__pycache__/time_utils.cpython-311.pyc
new file mode 100644
index 0000000..4b8c3ab
Binary files /dev/null and b/examples/__pycache__/time_utils.cpython-311.pyc differ
diff --git a/examples/jax_playground.py b/examples/jax_playground.py
index 5748071..29526a8 100644
--- a/examples/jax_playground.py
+++ b/examples/jax_playground.py
@@ -1,21 +1,5 @@
-import jax
import jax.numpy as jnp
-import numpy as np
-from jax import random
-from jax import vmap, jit
-from functools import partial
-from examples.time_utils import using_cprofile
+EMPTY_NODE = jnp.full((1, 5), jnp.nan)
-
-@jit
-def func(x, y):
- return x + y
-
-
-a, b, c = jnp.array([1]), jnp.array([2]), jnp.array([3])
-li = [a, b, c]
-
-cpu_li = jax.device_get(li)
-
-print(cpu_li)
\ No newline at end of file
+print(EMPTY_NODE)
\ No newline at end of file
diff --git a/examples/xor.py b/examples/xor.py
index a8dba00..8d629fb 100644
--- a/examples/xor.py
+++ b/examples/xor.py
@@ -6,35 +6,14 @@ from time_utils import using_cprofile
from problems import Sin, Xor, DIY
-# xor_inputs = np.array([[0, 0], [0, 1], [1, 0], [1, 1]], dtype=np.float32)
-# xor_outputs = np.array([[0], [1], [1], [0]])
-#
-#
-# def evaluate(forward_func: Callable) -> List[float]:
-# """
-# :param forward_func: (4: batch, 2: input size) -> (pop_size, 4: batch, 1: output size)
-# :return:
-# """
-# outs = forward_func(xor_inputs)
-# outs = jax.device_get(outs)
-# fitnesses = 4 - np.sum((outs - xor_outputs) ** 2, axis=(1, 2))
-# return fitnesses.tolist() # returns a list
-
-
# @using_cprofile
@partial(using_cprofile, root_abs_path='/mnt/e/neat-jax/', replace_pattern="/mnt/e/neat-jax/")
def main():
config = Configer.load_config()
- # config.neat.population.pop_size = 50
problem = Xor()
- # problem = Sin()
- # problem = DIY(func=lambda x: (np.sin(x) + np.exp(x) - x ** 2) / (np.cos(x) + np.sqrt(x)) - np.log(x + 1))
problem.refactor_config(config)
pipeline = Pipeline(config, seed=0)
- best_nodes, best_connections = pipeline.auto_run(problem.evaluate)
- # print(best_nodes, best_connections)
- # func = pipeline.function_factory.ask_batch_forward(best_nodes, best_connections)
- # problem.print(func)
+ pipeline.auto_run(problem.evaluate)
if __name__ == '__main__':
diff --git a/problems/__pycache__/__init__.cpython-311.pyc b/problems/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..f4a7c81
Binary files /dev/null and b/problems/__pycache__/__init__.cpython-311.pyc differ
diff --git a/problems/__pycache__/problem.cpython-311.pyc b/problems/__pycache__/problem.cpython-311.pyc
new file mode 100644
index 0000000..c891c7e
Binary files /dev/null and b/problems/__pycache__/problem.cpython-311.pyc differ
diff --git a/problems/function_fitting/__pycache__/__init__.cpython-311.pyc b/problems/function_fitting/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..2af62b7
Binary files /dev/null and b/problems/function_fitting/__pycache__/__init__.cpython-311.pyc differ
diff --git a/problems/function_fitting/__pycache__/diy.cpython-311.pyc b/problems/function_fitting/__pycache__/diy.cpython-311.pyc
new file mode 100644
index 0000000..e823e16
Binary files /dev/null and b/problems/function_fitting/__pycache__/diy.cpython-311.pyc differ
diff --git a/problems/function_fitting/__pycache__/function_fitting_problem.cpython-311.pyc b/problems/function_fitting/__pycache__/function_fitting_problem.cpython-311.pyc
new file mode 100644
index 0000000..76c9eb0
Binary files /dev/null and b/problems/function_fitting/__pycache__/function_fitting_problem.cpython-311.pyc differ
diff --git a/problems/function_fitting/__pycache__/sin.cpython-311.pyc b/problems/function_fitting/__pycache__/sin.cpython-311.pyc
new file mode 100644
index 0000000..0ef7d2e
Binary files /dev/null and b/problems/function_fitting/__pycache__/sin.cpython-311.pyc differ
diff --git a/problems/function_fitting/__pycache__/xor.cpython-311.pyc b/problems/function_fitting/__pycache__/xor.cpython-311.pyc
new file mode 100644
index 0000000..fb01805
Binary files /dev/null and b/problems/function_fitting/__pycache__/xor.cpython-311.pyc differ
diff --git a/problems/gym/__pycache__/__init__.cpython-311.pyc b/problems/gym/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..dd8541b
Binary files /dev/null and b/problems/gym/__pycache__/__init__.cpython-311.pyc differ
diff --git a/utils/__pycache__/__init__.cpython-311.pyc b/utils/__pycache__/__init__.cpython-311.pyc
new file mode 100644
index 0000000..846bd33
Binary files /dev/null and b/utils/__pycache__/__init__.cpython-311.pyc differ
diff --git a/utils/__pycache__/config.cpython-311.pyc b/utils/__pycache__/config.cpython-311.pyc
new file mode 100644
index 0000000..8ba1538
Binary files /dev/null and b/utils/__pycache__/config.cpython-311.pyc differ
diff --git a/utils/__pycache__/dotdict.cpython-311.pyc b/utils/__pycache__/dotdict.cpython-311.pyc
new file mode 100644
index 0000000..692ddce
Binary files /dev/null and b/utils/__pycache__/dotdict.cpython-311.pyc differ
diff --git a/utils/default_config.json b/utils/default_config.json
index 66492b1..993b080 100644
--- a/utils/default_config.json
+++ b/utils/default_config.json
@@ -57,9 +57,9 @@
"compatibility_weight_coefficient": 0.5,
"single_structural_mutation": "False",
"conn_add_prob": 0.5,
- "conn_delete_prob": 0.5,
+ "conn_delete_prob": 0,
"node_add_prob": 0.2,
- "node_delete_prob": 0.2
+ "node_delete_prob": 0
},
"species": {
"compatibility_threshold": 2.5,