agentdb 1.0.11 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +196 -838
- package/dist/benchmarks/comprehensive-benchmark.js +664 -0
- package/dist/benchmarks/frontier-benchmark.js +419 -0
- package/dist/benchmarks/reflexion-benchmark.js +370 -0
- package/dist/cli/agentdb-cli.d.ts +117 -0
- package/dist/cli/agentdb-cli.d.ts.map +1 -0
- package/dist/cli/agentdb-cli.js +718 -0
- package/dist/cli/agentdb-cli.js.map +1 -0
- package/dist/controllers/CausalMemoryGraph.d.ts +125 -0
- package/dist/controllers/CausalMemoryGraph.d.ts.map +1 -0
- package/dist/controllers/CausalMemoryGraph.js +323 -0
- package/dist/controllers/CausalMemoryGraph.js.map +1 -0
- package/dist/controllers/CausalRecall.d.ts +111 -0
- package/dist/controllers/CausalRecall.d.ts.map +1 -0
- package/dist/controllers/CausalRecall.js +282 -0
- package/dist/controllers/CausalRecall.js.map +1 -0
- package/dist/controllers/EmbeddingService.d.ts +37 -0
- package/dist/controllers/EmbeddingService.d.ts.map +1 -0
- package/dist/controllers/EmbeddingService.js +119 -0
- package/dist/controllers/EmbeddingService.js.map +1 -0
- package/dist/controllers/ExplainableRecall.d.ts +138 -0
- package/dist/controllers/ExplainableRecall.d.ts.map +1 -0
- package/dist/controllers/ExplainableRecall.js +388 -0
- package/dist/controllers/ExplainableRecall.js.map +1 -0
- package/dist/controllers/NightlyLearner.d.ts +113 -0
- package/dist/controllers/NightlyLearner.d.ts.map +1 -0
- package/dist/controllers/NightlyLearner.js +383 -0
- package/dist/controllers/NightlyLearner.js.map +1 -0
- package/dist/controllers/ReflexionMemory.d.ts +84 -0
- package/dist/controllers/ReflexionMemory.d.ts.map +1 -0
- package/dist/controllers/ReflexionMemory.js +240 -0
- package/dist/controllers/ReflexionMemory.js.map +1 -0
- package/dist/controllers/SkillLibrary.d.ts +96 -0
- package/dist/controllers/SkillLibrary.d.ts.map +1 -0
- package/dist/controllers/SkillLibrary.js +277 -0
- package/dist/controllers/SkillLibrary.js.map +1 -0
- package/dist/controllers/frontier-index.d.ts +14 -0
- package/dist/controllers/frontier-index.d.ts.map +1 -0
- package/dist/controllers/frontier-index.js +10 -0
- package/dist/controllers/frontier-index.js.map +1 -0
- package/dist/controllers/index.d.ts +12 -0
- package/dist/controllers/index.d.ts.map +1 -0
- package/dist/controllers/index.js +9 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/optimizations/BatchOperations.d.ts +61 -0
- package/dist/optimizations/BatchOperations.d.ts.map +1 -0
- package/dist/optimizations/BatchOperations.js +199 -0
- package/dist/optimizations/BatchOperations.js.map +1 -0
- package/dist/optimizations/QueryOptimizer.d.ts +82 -0
- package/dist/optimizations/QueryOptimizer.d.ts.map +1 -0
- package/dist/optimizations/QueryOptimizer.js +226 -0
- package/dist/optimizations/QueryOptimizer.js.map +1 -0
- package/dist/optimizations/index.d.ts +10 -0
- package/dist/optimizations/index.d.ts.map +1 -0
- package/dist/optimizations/index.js +8 -0
- package/dist/optimizations/index.js.map +1 -0
- package/dist/schemas/frontier-schema.sql +341 -0
- package/dist/schemas/schema.sql +382 -0
- package/dist/tests/frontier-features.test.js +665 -0
- package/package.json +54 -117
- package/src/cli/agentdb-cli.ts +861 -0
- package/src/cli/examples.sh +83 -0
- package/src/controllers/CausalMemoryGraph.ts +504 -0
- package/src/controllers/CausalRecall.ts +395 -0
- package/src/controllers/EmbeddingService.ts +141 -0
- package/src/controllers/ExplainableRecall.ts +577 -0
- package/src/controllers/NightlyLearner.ts +475 -0
- package/src/controllers/ReflexionMemory.ts +349 -0
- package/src/controllers/SkillLibrary.ts +391 -0
- package/src/controllers/frontier-index.ts +35 -0
- package/src/controllers/index.ts +13 -0
- package/src/optimizations/BatchOperations.ts +292 -0
- package/src/optimizations/QueryOptimizer.ts +294 -0
- package/src/optimizations/index.ts +11 -0
- package/src/schemas/frontier-schema.sql +341 -0
- package/src/schemas/schema.sql +382 -0
- package/CHANGELOG.md +0 -166
- package/LICENSE +0 -38
- package/LICENSE-APACHE +0 -190
- package/LICENSE-MIT +0 -21
- package/bin/agentdb.js +0 -733
- package/bin/benchmark.js +0 -162
- package/bin/plugin-cli-wrapper.mjs +0 -21
- package/dist/agentdb.js +0 -5352
- package/dist/agentdb.js.map +0 -7
- package/dist/agentdb.min.js +0 -143
- package/dist/agentdb.min.js.map +0 -7
- package/dist/cache/query-cache.d.ts +0 -105
- package/dist/cache/query-cache.d.ts.map +0 -1
- package/dist/cache/query-cache.js +0 -224
- package/dist/cache/query-cache.js.map +0 -1
- package/dist/cache/query-cache.mjs +0 -219
- package/dist/cli/cache/query-cache.d.ts +0 -104
- package/dist/cli/cache/query-cache.js +0 -244
- package/dist/cli/cli/db-commands.d.ts +0 -48
- package/dist/cli/cli/db-commands.js +0 -613
- package/dist/cli/commands.d.ts +0 -7
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -113
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/commands.mjs +0 -104
- package/dist/cli/core/backend-interface.d.ts +0 -70
- package/dist/cli/core/backend-interface.js +0 -15
- package/dist/cli/core/native-backend.d.ts +0 -140
- package/dist/cli/core/native-backend.js +0 -432
- package/dist/cli/core/vector-db.d.ts +0 -126
- package/dist/cli/core/vector-db.js +0 -338
- package/dist/cli/core/wasm-backend.d.ts +0 -95
- package/dist/cli/core/wasm-backend.js +0 -418
- package/dist/cli/db-commands.d.ts +0 -49
- package/dist/cli/db-commands.d.ts.map +0 -1
- package/dist/cli/db-commands.js +0 -533
- package/dist/cli/db-commands.js.map +0 -1
- package/dist/cli/db-commands.mjs +0 -522
- package/dist/cli/generator.d.ts +0 -11
- package/dist/cli/generator.d.ts.map +0 -1
- package/dist/cli/generator.js +0 -567
- package/dist/cli/generator.js.map +0 -1
- package/dist/cli/generator.mjs +0 -527
- package/dist/cli/help.d.ts +0 -18
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -676
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/help.mjs +0 -667
- package/dist/cli/index/hnsw.d.ts +0 -164
- package/dist/cli/index/hnsw.js +0 -558
- package/dist/cli/plugin-cli.d.ts +0 -7
- package/dist/cli/plugin-cli.d.ts.map +0 -1
- package/dist/cli/plugin-cli.js +0 -295
- package/dist/cli/plugin-cli.js.map +0 -1
- package/dist/cli/plugin-cli.mjs +0 -289
- package/dist/cli/quantization/product-quantization.d.ts +0 -108
- package/dist/cli/quantization/product-quantization.js +0 -350
- package/dist/cli/query/query-builder.d.ts +0 -322
- package/dist/cli/query/query-builder.js +0 -600
- package/dist/cli/templates.d.ts +0 -14
- package/dist/cli/templates.d.ts.map +0 -1
- package/dist/cli/templates.js +0 -182
- package/dist/cli/templates.js.map +0 -1
- package/dist/cli/templates.mjs +0 -176
- package/dist/cli/types/index.d.ts +0 -116
- package/dist/cli/types/index.js +0 -5
- package/dist/cli/types.d.ts +0 -91
- package/dist/cli/types.d.ts.map +0 -1
- package/dist/cli/types.js +0 -6
- package/dist/cli/types.js.map +0 -1
- package/dist/cli/types.mjs +0 -4
- package/dist/cli/wizard/index.d.ts +0 -6
- package/dist/cli/wizard/index.d.ts.map +0 -1
- package/dist/cli/wizard/index.js +0 -138
- package/dist/cli/wizard/index.js.map +0 -1
- package/dist/cli/wizard/index.mjs +0 -131
- package/dist/cli/wizard/prompts.d.ts +0 -11
- package/dist/cli/wizard/prompts.d.ts.map +0 -1
- package/dist/cli/wizard/prompts.js +0 -482
- package/dist/cli/wizard/prompts.js.map +0 -1
- package/dist/cli/wizard/prompts.mjs +0 -470
- package/dist/cli/wizard/validator.d.ts +0 -13
- package/dist/cli/wizard/validator.d.ts.map +0 -1
- package/dist/cli/wizard/validator.js +0 -234
- package/dist/cli/wizard/validator.js.map +0 -1
- package/dist/cli/wizard/validator.mjs +0 -224
- package/dist/core/backend-interface.d.ts +0 -71
- package/dist/core/backend-interface.d.ts.map +0 -1
- package/dist/core/backend-interface.js +0 -16
- package/dist/core/backend-interface.js.map +0 -1
- package/dist/core/backend-interface.mjs +0 -12
- package/dist/core/native-backend.d.ts +0 -141
- package/dist/core/native-backend.d.ts.map +0 -1
- package/dist/core/native-backend.js +0 -457
- package/dist/core/native-backend.js.map +0 -1
- package/dist/core/native-backend.mjs +0 -449
- package/dist/core/vector-db.d.ts +0 -127
- package/dist/core/vector-db.d.ts.map +0 -1
- package/dist/core/vector-db.js +0 -270
- package/dist/core/vector-db.js.map +0 -1
- package/dist/core/vector-db.mjs +0 -265
- package/dist/core/wasm-backend.d.ts +0 -96
- package/dist/core/wasm-backend.d.ts.map +0 -1
- package/dist/core/wasm-backend.js +0 -393
- package/dist/core/wasm-backend.js.map +0 -1
- package/dist/core/wasm-backend.mjs +0 -385
- package/dist/index/hnsw-optimized.d.ts +0 -75
- package/dist/index/hnsw-optimized.d.ts.map +0 -1
- package/dist/index/hnsw-optimized.js +0 -412
- package/dist/index/hnsw-optimized.js.map +0 -1
- package/dist/index/hnsw-optimized.mjs +0 -407
- package/dist/index/hnsw.d.ts +0 -165
- package/dist/index/hnsw.d.ts.map +0 -1
- package/dist/index/hnsw.js +0 -521
- package/dist/index/hnsw.js.map +0 -1
- package/dist/index/hnsw.mjs +0 -516
- package/dist/index.browser.d.ts +0 -47
- package/dist/index.browser.d.ts.map +0 -1
- package/dist/index.browser.js +0 -72
- package/dist/index.browser.js.map +0 -1
- package/dist/index.browser.mjs +0 -54
- package/dist/index.d.ts +0 -59
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -84
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -65
- package/dist/mcp/learning/core/experience-buffer.d.ts +0 -61
- package/dist/mcp/learning/core/experience-buffer.d.ts.map +0 -1
- package/dist/mcp/learning/core/experience-buffer.js +0 -175
- package/dist/mcp/learning/core/experience-buffer.js.map +0 -1
- package/dist/mcp/learning/core/experience-buffer.mjs +0 -170
- package/dist/mcp/learning/core/experience-recorder.d.ts +0 -40
- package/dist/mcp/learning/core/experience-recorder.d.ts.map +0 -1
- package/dist/mcp/learning/core/experience-recorder.js +0 -200
- package/dist/mcp/learning/core/experience-recorder.js.map +0 -1
- package/dist/mcp/learning/core/experience-recorder.mjs +0 -195
- package/dist/mcp/learning/core/learning-manager.d.ts +0 -66
- package/dist/mcp/learning/core/learning-manager.d.ts.map +0 -1
- package/dist/mcp/learning/core/learning-manager.js +0 -252
- package/dist/mcp/learning/core/learning-manager.js.map +0 -1
- package/dist/mcp/learning/core/learning-manager.mjs +0 -247
- package/dist/mcp/learning/core/policy-optimizer.d.ts +0 -53
- package/dist/mcp/learning/core/policy-optimizer.d.ts.map +0 -1
- package/dist/mcp/learning/core/policy-optimizer.js +0 -251
- package/dist/mcp/learning/core/policy-optimizer.js.map +0 -1
- package/dist/mcp/learning/core/policy-optimizer.mjs +0 -246
- package/dist/mcp/learning/core/reward-estimator.d.ts +0 -44
- package/dist/mcp/learning/core/reward-estimator.d.ts.map +0 -1
- package/dist/mcp/learning/core/reward-estimator.js +0 -158
- package/dist/mcp/learning/core/reward-estimator.js.map +0 -1
- package/dist/mcp/learning/core/reward-estimator.mjs +0 -153
- package/dist/mcp/learning/core/session-manager.d.ts +0 -63
- package/dist/mcp/learning/core/session-manager.d.ts.map +0 -1
- package/dist/mcp/learning/core/session-manager.js +0 -202
- package/dist/mcp/learning/core/session-manager.js.map +0 -1
- package/dist/mcp/learning/core/session-manager.mjs +0 -197
- package/dist/mcp/learning/index.d.ts +0 -19
- package/dist/mcp/learning/index.d.ts.map +0 -1
- package/dist/mcp/learning/index.js +0 -30
- package/dist/mcp/learning/index.js.map +0 -1
- package/dist/mcp/learning/index.mjs +0 -19
- package/dist/mcp/learning/tools/mcp-learning-tools.d.ts +0 -369
- package/dist/mcp/learning/tools/mcp-learning-tools.d.ts.map +0 -1
- package/dist/mcp/learning/tools/mcp-learning-tools.js +0 -361
- package/dist/mcp/learning/tools/mcp-learning-tools.js.map +0 -1
- package/dist/mcp/learning/tools/mcp-learning-tools.mjs +0 -356
- package/dist/mcp/learning/types/index.d.ts +0 -138
- package/dist/mcp/learning/types/index.d.ts.map +0 -1
- package/dist/mcp/learning/types/index.js +0 -6
- package/dist/mcp/learning/types/index.js.map +0 -1
- package/dist/mcp/learning/types/index.mjs +0 -4
- package/dist/mcp-server.d.ts +0 -29
- package/dist/mcp-server.d.ts.map +0 -1
- package/dist/mcp-server.js +0 -862
- package/dist/mcp-server.js.map +0 -1
- package/dist/mcp-server.mjs +0 -857
- package/dist/plugins/base-plugin.d.ts +0 -114
- package/dist/plugins/base-plugin.d.ts.map +0 -1
- package/dist/plugins/base-plugin.js +0 -313
- package/dist/plugins/base-plugin.js.map +0 -1
- package/dist/plugins/base-plugin.mjs +0 -275
- package/dist/plugins/implementations/active-learning.d.ts +0 -135
- package/dist/plugins/implementations/active-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/active-learning.js +0 -372
- package/dist/plugins/implementations/active-learning.js.map +0 -1
- package/dist/plugins/implementations/active-learning.mjs +0 -367
- package/dist/plugins/implementations/actor-critic.d.ts +0 -64
- package/dist/plugins/implementations/actor-critic.d.ts.map +0 -1
- package/dist/plugins/implementations/actor-critic.js +0 -363
- package/dist/plugins/implementations/actor-critic.js.map +0 -1
- package/dist/plugins/implementations/actor-critic.mjs +0 -358
- package/dist/plugins/implementations/adversarial-training.d.ts +0 -133
- package/dist/plugins/implementations/adversarial-training.d.ts.map +0 -1
- package/dist/plugins/implementations/adversarial-training.js +0 -409
- package/dist/plugins/implementations/adversarial-training.js.map +0 -1
- package/dist/plugins/implementations/adversarial-training.mjs +0 -404
- package/dist/plugins/implementations/curriculum-learning.d.ts +0 -132
- package/dist/plugins/implementations/curriculum-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/curriculum-learning.js +0 -354
- package/dist/plugins/implementations/curriculum-learning.js.map +0 -1
- package/dist/plugins/implementations/curriculum-learning.mjs +0 -349
- package/dist/plugins/implementations/decision-transformer.d.ts +0 -77
- package/dist/plugins/implementations/decision-transformer.d.ts.map +0 -1
- package/dist/plugins/implementations/decision-transformer.js +0 -422
- package/dist/plugins/implementations/decision-transformer.js.map +0 -1
- package/dist/plugins/implementations/decision-transformer.mjs +0 -417
- package/dist/plugins/implementations/federated-learning.d.ts +0 -126
- package/dist/plugins/implementations/federated-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/federated-learning.js +0 -436
- package/dist/plugins/implementations/federated-learning.js.map +0 -1
- package/dist/plugins/implementations/federated-learning.mjs +0 -431
- package/dist/plugins/implementations/index.d.ts +0 -30
- package/dist/plugins/implementations/index.d.ts.map +0 -1
- package/dist/plugins/implementations/index.js +0 -45
- package/dist/plugins/implementations/index.js.map +0 -1
- package/dist/plugins/implementations/index.mjs +0 -31
- package/dist/plugins/implementations/multi-task-learning.d.ts +0 -115
- package/dist/plugins/implementations/multi-task-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/multi-task-learning.js +0 -369
- package/dist/plugins/implementations/multi-task-learning.js.map +0 -1
- package/dist/plugins/implementations/multi-task-learning.mjs +0 -364
- package/dist/plugins/implementations/neural-architecture-search.d.ts +0 -148
- package/dist/plugins/implementations/neural-architecture-search.d.ts.map +0 -1
- package/dist/plugins/implementations/neural-architecture-search.js +0 -379
- package/dist/plugins/implementations/neural-architecture-search.js.map +0 -1
- package/dist/plugins/implementations/neural-architecture-search.mjs +0 -374
- package/dist/plugins/implementations/q-learning.d.ts +0 -98
- package/dist/plugins/implementations/q-learning.d.ts.map +0 -1
- package/dist/plugins/implementations/q-learning.js +0 -435
- package/dist/plugins/implementations/q-learning.js.map +0 -1
- package/dist/plugins/implementations/q-learning.mjs +0 -430
- package/dist/plugins/implementations/sarsa.d.ts +0 -103
- package/dist/plugins/implementations/sarsa.d.ts.map +0 -1
- package/dist/plugins/implementations/sarsa.js +0 -347
- package/dist/plugins/implementations/sarsa.js.map +0 -1
- package/dist/plugins/implementations/sarsa.mjs +0 -342
- package/dist/plugins/index.d.ts +0 -107
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -179
- package/dist/plugins/index.js.map +0 -1
- package/dist/plugins/index.mjs +0 -168
- package/dist/plugins/interface.d.ts +0 -439
- package/dist/plugins/interface.d.ts.map +0 -1
- package/dist/plugins/interface.js +0 -12
- package/dist/plugins/interface.js.map +0 -1
- package/dist/plugins/interface.mjs +0 -10
- package/dist/plugins/learning-plugin.interface.d.ts +0 -257
- package/dist/plugins/learning-plugin.interface.d.ts.map +0 -1
- package/dist/plugins/learning-plugin.interface.js +0 -7
- package/dist/plugins/learning-plugin.interface.js.map +0 -1
- package/dist/plugins/learning-plugin.interface.mjs +0 -5
- package/dist/plugins/plugin-exports.d.ts +0 -71
- package/dist/plugins/plugin-exports.d.ts.map +0 -1
- package/dist/plugins/plugin-exports.js +0 -78
- package/dist/plugins/plugin-exports.js.map +0 -1
- package/dist/plugins/plugin-exports.mjs +0 -69
- package/dist/plugins/registry.d.ts +0 -206
- package/dist/plugins/registry.d.ts.map +0 -1
- package/dist/plugins/registry.js +0 -365
- package/dist/plugins/registry.js.map +0 -1
- package/dist/plugins/registry.mjs +0 -356
- package/dist/plugins/validator.d.ts +0 -63
- package/dist/plugins/validator.d.ts.map +0 -1
- package/dist/plugins/validator.js +0 -464
- package/dist/plugins/validator.js.map +0 -1
- package/dist/plugins/validator.mjs +0 -458
- package/dist/presets.d.ts +0 -65
- package/dist/presets.d.ts.map +0 -1
- package/dist/presets.js +0 -145
- package/dist/presets.js.map +0 -1
- package/dist/presets.mjs +0 -140
- package/dist/quantization/binary-quantization.d.ts +0 -104
- package/dist/quantization/binary-quantization.d.ts.map +0 -1
- package/dist/quantization/binary-quantization.js +0 -246
- package/dist/quantization/binary-quantization.js.map +0 -1
- package/dist/quantization/binary-quantization.mjs +0 -240
- package/dist/quantization/optimized-pq.d.ts +0 -138
- package/dist/quantization/optimized-pq.d.ts.map +0 -1
- package/dist/quantization/optimized-pq.js +0 -320
- package/dist/quantization/optimized-pq.js.map +0 -1
- package/dist/quantization/optimized-pq.mjs +0 -313
- package/dist/quantization/product-quantization.d.ts +0 -109
- package/dist/quantization/product-quantization.d.ts.map +0 -1
- package/dist/quantization/product-quantization.js +0 -287
- package/dist/quantization/product-quantization.js.map +0 -1
- package/dist/quantization/product-quantization.mjs +0 -282
- package/dist/quantization/scalar-quantization.d.ts +0 -100
- package/dist/quantization/scalar-quantization.d.ts.map +0 -1
- package/dist/quantization/scalar-quantization.js +0 -324
- package/dist/quantization/scalar-quantization.js.map +0 -1
- package/dist/quantization/scalar-quantization.mjs +0 -319
- package/dist/query/index.d.ts +0 -6
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/index.js +0 -9
- package/dist/query/index.js.map +0 -1
- package/dist/query/index.mjs +0 -4
- package/dist/query/query-builder.d.ts +0 -323
- package/dist/query/query-builder.d.ts.map +0 -1
- package/dist/query/query-builder.js +0 -524
- package/dist/query/query-builder.js.map +0 -1
- package/dist/query/query-builder.mjs +0 -519
- package/dist/reasoning/context-synthesizer.d.ts +0 -57
- package/dist/reasoning/context-synthesizer.d.ts.map +0 -1
- package/dist/reasoning/context-synthesizer.js +0 -224
- package/dist/reasoning/context-synthesizer.js.map +0 -1
- package/dist/reasoning/context-synthesizer.mjs +0 -219
- package/dist/reasoning/experience-curator.d.ts +0 -66
- package/dist/reasoning/experience-curator.d.ts.map +0 -1
- package/dist/reasoning/experience-curator.js +0 -288
- package/dist/reasoning/experience-curator.js.map +0 -1
- package/dist/reasoning/experience-curator.mjs +0 -283
- package/dist/reasoning/memory-optimizer.d.ts +0 -69
- package/dist/reasoning/memory-optimizer.d.ts.map +0 -1
- package/dist/reasoning/memory-optimizer.js +0 -331
- package/dist/reasoning/memory-optimizer.js.map +0 -1
- package/dist/reasoning/memory-optimizer.mjs +0 -326
- package/dist/reasoning/pattern-matcher.d.ts +0 -59
- package/dist/reasoning/pattern-matcher.d.ts.map +0 -1
- package/dist/reasoning/pattern-matcher.js +0 -229
- package/dist/reasoning/pattern-matcher.js.map +0 -1
- package/dist/reasoning/pattern-matcher.mjs +0 -224
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts +0 -118
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts.map +0 -1
- package/dist/reasoningbank/adapter/agentdb-adapter.js +0 -477
- package/dist/reasoningbank/adapter/agentdb-adapter.js.map +0 -1
- package/dist/reasoningbank/adapter/types.d.ts +0 -113
- package/dist/reasoningbank/adapter/types.d.ts.map +0 -1
- package/dist/reasoningbank/adapter/types.js +0 -9
- package/dist/reasoningbank/adapter/types.js.map +0 -1
- package/dist/reasoningbank/cli/commands.d.ts +0 -16
- package/dist/reasoningbank/cli/commands.d.ts.map +0 -1
- package/dist/reasoningbank/cli/commands.js +0 -272
- package/dist/reasoningbank/cli/commands.js.map +0 -1
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts +0 -319
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts.map +0 -1
- package/dist/reasoningbank/mcp/agentdb-tools.js +0 -301
- package/dist/reasoningbank/mcp/agentdb-tools.js.map +0 -1
- package/dist/reasoningbank/migration/migrate.d.ts +0 -25
- package/dist/reasoningbank/migration/migrate.d.ts.map +0 -1
- package/dist/reasoningbank/migration/migrate.js +0 -178
- package/dist/reasoningbank/migration/migrate.js.map +0 -1
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts +0 -37
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts.map +0 -1
- package/dist/reasoningbank/reasoning/context-synthesizer.js +0 -114
- package/dist/reasoningbank/reasoning/context-synthesizer.js.map +0 -1
- package/dist/reasoningbank/reasoning/experience-curator.d.ts +0 -39
- package/dist/reasoningbank/reasoning/experience-curator.d.ts.map +0 -1
- package/dist/reasoningbank/reasoning/experience-curator.js +0 -98
- package/dist/reasoningbank/reasoning/experience-curator.js.map +0 -1
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts +0 -44
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts.map +0 -1
- package/dist/reasoningbank/reasoning/memory-optimizer.js +0 -184
- package/dist/reasoningbank/reasoning/memory-optimizer.js.map +0 -1
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts +0 -40
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts.map +0 -1
- package/dist/reasoningbank/reasoning/pattern-matcher.js +0 -87
- package/dist/reasoningbank/reasoning/pattern-matcher.js.map +0 -1
- package/dist/reasoningbank/sync/quic-sync.d.ts +0 -77
- package/dist/reasoningbank/sync/quic-sync.d.ts.map +0 -1
- package/dist/reasoningbank/sync/quic-sync.js +0 -165
- package/dist/reasoningbank/sync/quic-sync.js.map +0 -1
- package/dist/sync/conflict.d.ts +0 -78
- package/dist/sync/conflict.d.ts.map +0 -1
- package/dist/sync/conflict.js +0 -202
- package/dist/sync/conflict.js.map +0 -1
- package/dist/sync/conflict.mjs +0 -196
- package/dist/sync/coordinator.d.ts +0 -111
- package/dist/sync/coordinator.d.ts.map +0 -1
- package/dist/sync/coordinator.js +0 -256
- package/dist/sync/coordinator.js.map +0 -1
- package/dist/sync/coordinator.mjs +0 -250
- package/dist/sync/delta.d.ts +0 -81
- package/dist/sync/delta.d.ts.map +0 -1
- package/dist/sync/delta.js +0 -245
- package/dist/sync/delta.js.map +0 -1
- package/dist/sync/delta.mjs +0 -238
- package/dist/sync/index.d.ts +0 -11
- package/dist/sync/index.d.ts.map +0 -1
- package/dist/sync/index.js +0 -22
- package/dist/sync/index.js.map +0 -1
- package/dist/sync/index.mjs +0 -9
- package/dist/sync/quic-sync.d.ts +0 -81
- package/dist/sync/quic-sync.d.ts.map +0 -1
- package/dist/sync/quic-sync.js +0 -329
- package/dist/sync/quic-sync.js.map +0 -1
- package/dist/sync/quic-sync.mjs +0 -323
- package/dist/sync/types.d.ts +0 -168
- package/dist/sync/types.d.ts.map +0 -1
- package/dist/sync/types.js +0 -8
- package/dist/sync/types.js.map +0 -1
- package/dist/sync/types.mjs +0 -6
- package/dist/types/index.d.ts +0 -117
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -6
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -4
- package/dist/wasm/sql-wasm-debug.js +0 -6989
- package/dist/wasm/sql-wasm-debug.wasm +0 -0
- package/dist/wasm/sql-wasm.js +0 -188
- package/dist/wasm/sql-wasm.wasm +0 -0
- package/dist/wasm-loader.d.ts +0 -32
- package/dist/wasm-loader.d.ts.map +0 -1
- package/dist/wasm-loader.js +0 -78
- package/dist/wasm-loader.js.map +0 -1
- package/dist/wasm-loader.mjs +0 -67
- package/examples/adaptive-learning.ts +0 -284
- package/examples/browser/README.md +0 -732
- package/examples/browser/adaptive-recommendations/index.html +0 -427
- package/examples/browser/collaborative-filtering/index.html +0 -310
- package/examples/browser/continual-learning/index.html +0 -736
- package/examples/browser/experience-replay/index.html +0 -616
- package/examples/browser/index.html +0 -369
- package/examples/browser/meta-learning/index.html +0 -789
- package/examples/browser/neuro-symbolic/index.html +0 -692
- package/examples/browser/pattern-learning/index.html +0 -620
- package/examples/browser/quantum-inspired/index.html +0 -728
- package/examples/browser/rag/index.html +0 -624
- package/examples/browser/swarm-intelligence/index.html +0 -811
- package/examples/browser-basic.html +0 -170
- package/examples/browser-wasm-real.html +0 -231
- package/examples/hnsw-example.ts +0 -148
- package/examples/mcp-learning-example.ts +0 -220
- package/examples/node-basic.js +0 -70
- package/examples/quic-sync-example.ts +0 -310
- package/examples/quick-start.js +0 -68
- package/examples/test-v1.0.7-cdn.html +0 -190
- package/examples/wasm-example.ts +0 -222
|
@@ -1,728 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Quantum-Inspired Optimization - AgentDB WASM</title>
|
|
7
|
-
<style>
|
|
8
|
-
* {
|
|
9
|
-
margin: 0;
|
|
10
|
-
padding: 0;
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
body {
|
|
15
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
16
|
-
background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
|
|
17
|
-
min-height: 100vh;
|
|
18
|
-
padding: 2rem;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.container {
|
|
22
|
-
max-width: 1400px;
|
|
23
|
-
margin: 0 auto;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
header {
|
|
27
|
-
text-align: center;
|
|
28
|
-
color: white;
|
|
29
|
-
margin-bottom: 2rem;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
h1 {
|
|
33
|
-
font-size: 2rem;
|
|
34
|
-
margin-bottom: 0.5rem;
|
|
35
|
-
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.subtitle {
|
|
39
|
-
opacity: 0.9;
|
|
40
|
-
font-size: 1rem;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.main-grid {
|
|
44
|
-
display: grid;
|
|
45
|
-
grid-template-columns: 1.5fr 1fr;
|
|
46
|
-
gap: 1.5rem;
|
|
47
|
-
margin-bottom: 1.5rem;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.card {
|
|
51
|
-
background: white;
|
|
52
|
-
border-radius: 12px;
|
|
53
|
-
padding: 1.5rem;
|
|
54
|
-
box-shadow: 0 8px 24px rgba(0,0,0,0.2);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.card h2 {
|
|
58
|
-
color: #333;
|
|
59
|
-
margin-bottom: 1rem;
|
|
60
|
-
font-size: 1.3rem;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#canvas {
|
|
64
|
-
width: 100%;
|
|
65
|
-
height: 500px;
|
|
66
|
-
border: 2px solid #e0e0e0;
|
|
67
|
-
border-radius: 8px;
|
|
68
|
-
background: #000;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.description {
|
|
72
|
-
background: #e8eaf6;
|
|
73
|
-
padding: 1rem;
|
|
74
|
-
border-radius: 8px;
|
|
75
|
-
margin-bottom: 1rem;
|
|
76
|
-
line-height: 1.6;
|
|
77
|
-
color: #555;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.quantum-params {
|
|
81
|
-
display: grid;
|
|
82
|
-
grid-template-columns: 1fr 1fr;
|
|
83
|
-
gap: 1rem;
|
|
84
|
-
margin-bottom: 1rem;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.param-group {
|
|
88
|
-
background: #f5f5f5;
|
|
89
|
-
padding: 1rem;
|
|
90
|
-
border-radius: 8px;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.param-label {
|
|
94
|
-
font-size: 0.85rem;
|
|
95
|
-
color: #666;
|
|
96
|
-
margin-bottom: 0.5rem;
|
|
97
|
-
font-weight: 600;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.param-value {
|
|
101
|
-
font-size: 1.2rem;
|
|
102
|
-
color: #1a237e;
|
|
103
|
-
font-weight: bold;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
input[type="range"] {
|
|
107
|
-
width: 100%;
|
|
108
|
-
margin-top: 0.5rem;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.btn {
|
|
112
|
-
padding: 0.75rem 1.5rem;
|
|
113
|
-
background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
|
|
114
|
-
color: white;
|
|
115
|
-
border: none;
|
|
116
|
-
border-radius: 6px;
|
|
117
|
-
font-weight: 600;
|
|
118
|
-
cursor: pointer;
|
|
119
|
-
transition: opacity 0.3s;
|
|
120
|
-
width: 100%;
|
|
121
|
-
margin-bottom: 0.5rem;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.btn:hover {
|
|
125
|
-
opacity: 0.9;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.stat-grid {
|
|
129
|
-
display: grid;
|
|
130
|
-
grid-template-columns: repeat(2, 1fr);
|
|
131
|
-
gap: 1rem;
|
|
132
|
-
margin-bottom: 1rem;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.stat-item {
|
|
136
|
-
background: #f5f5f5;
|
|
137
|
-
padding: 1rem;
|
|
138
|
-
border-radius: 8px;
|
|
139
|
-
text-align: center;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.stat-label {
|
|
143
|
-
font-size: 0.85rem;
|
|
144
|
-
color: #666;
|
|
145
|
-
margin-bottom: 0.5rem;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.stat-value {
|
|
149
|
-
font-size: 1.5rem;
|
|
150
|
-
font-weight: bold;
|
|
151
|
-
color: #1a237e;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.superposition-visual {
|
|
155
|
-
background: #f5f5f5;
|
|
156
|
-
padding: 1rem;
|
|
157
|
-
border-radius: 8px;
|
|
158
|
-
margin-bottom: 1rem;
|
|
159
|
-
height: 150px;
|
|
160
|
-
display: flex;
|
|
161
|
-
align-items: center;
|
|
162
|
-
justify-content: center;
|
|
163
|
-
position: relative;
|
|
164
|
-
overflow: hidden;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.quantum-state {
|
|
168
|
-
position: absolute;
|
|
169
|
-
width: 20px;
|
|
170
|
-
height: 20px;
|
|
171
|
-
border-radius: 50%;
|
|
172
|
-
background: radial-gradient(circle, #00ffff 0%, #1a237e 100%);
|
|
173
|
-
animation: quantumFluctuation 2s infinite;
|
|
174
|
-
box-shadow: 0 0 20px #00ffff;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@keyframes quantumFluctuation {
|
|
178
|
-
0%, 100% { transform: scale(1); opacity: 1; }
|
|
179
|
-
50% { transform: scale(1.5); opacity: 0.5; }
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.energy-landscape {
|
|
183
|
-
width: 100%;
|
|
184
|
-
height: 100px;
|
|
185
|
-
background: linear-gradient(to right, #1a237e 0%, #00ffff 50%, #1a237e 100%);
|
|
186
|
-
border-radius: 8px;
|
|
187
|
-
margin-bottom: 1rem;
|
|
188
|
-
position: relative;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.energy-marker {
|
|
192
|
-
position: absolute;
|
|
193
|
-
width: 4px;
|
|
194
|
-
height: 100%;
|
|
195
|
-
background: #ff0000;
|
|
196
|
-
transition: left 0.3s;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
#log {
|
|
200
|
-
max-height: 200px;
|
|
201
|
-
overflow-y: auto;
|
|
202
|
-
background: #f9f9f9;
|
|
203
|
-
padding: 1rem;
|
|
204
|
-
border-radius: 8px;
|
|
205
|
-
font-family: 'Courier New', monospace;
|
|
206
|
-
font-size: 0.85rem;
|
|
207
|
-
line-height: 1.6;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
.log-entry {
|
|
211
|
-
margin-bottom: 0.5rem;
|
|
212
|
-
color: #555;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.log-entry.success {
|
|
216
|
-
color: #2e7d32;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.log-entry.info {
|
|
220
|
-
color: #1976d2;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
.algorithm-select {
|
|
224
|
-
display: grid;
|
|
225
|
-
grid-template-columns: 1fr 1fr;
|
|
226
|
-
gap: 0.5rem;
|
|
227
|
-
margin-bottom: 1rem;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.algo-btn {
|
|
231
|
-
padding: 0.75rem;
|
|
232
|
-
background: white;
|
|
233
|
-
border: 2px solid #ddd;
|
|
234
|
-
border-radius: 6px;
|
|
235
|
-
cursor: pointer;
|
|
236
|
-
transition: all 0.3s;
|
|
237
|
-
text-align: center;
|
|
238
|
-
font-weight: 600;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.algo-btn.active {
|
|
242
|
-
background: #1a237e;
|
|
243
|
-
color: white;
|
|
244
|
-
border-color: #1a237e;
|
|
245
|
-
}
|
|
246
|
-
</style>
|
|
247
|
-
</head>
|
|
248
|
-
<body>
|
|
249
|
-
<div class="container">
|
|
250
|
-
<header>
|
|
251
|
-
<h1>⚛️ Quantum-Inspired Optimization</h1>
|
|
252
|
-
<p class="subtitle">Superposition, Entanglement & Quantum Tunneling for Global Optimization</p>
|
|
253
|
-
</header>
|
|
254
|
-
|
|
255
|
-
<div class="main-grid">
|
|
256
|
-
<div class="card">
|
|
257
|
-
<h2>Quantum Search Space</h2>
|
|
258
|
-
<canvas id="canvas"></canvas>
|
|
259
|
-
|
|
260
|
-
<div class="algorithm-select">
|
|
261
|
-
<button class="algo-btn active" onclick="setAlgorithm('qpso')">🌊 QPSO</button>
|
|
262
|
-
<button class="algo-btn" onclick="setAlgorithm('qga')">🧬 Quantum GA</button>
|
|
263
|
-
<button class="algo-btn" onclick="setAlgorithm('tunnel')">🚇 Tunneling</button>
|
|
264
|
-
<button class="algo-btn" onclick="setAlgorithm('anneal')">❄️ Annealing</button>
|
|
265
|
-
</div>
|
|
266
|
-
|
|
267
|
-
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;">
|
|
268
|
-
<button class="btn" onclick="startOptimization()">⚛️ Start Quantum Search</button>
|
|
269
|
-
<button class="btn" onclick="reset()">⟲ Reset</button>
|
|
270
|
-
</div>
|
|
271
|
-
</div>
|
|
272
|
-
|
|
273
|
-
<div class="card">
|
|
274
|
-
<h2>Quantum Parameters</h2>
|
|
275
|
-
|
|
276
|
-
<div class="description">
|
|
277
|
-
Quantum-inspired algorithms use principles from quantum mechanics (superposition, entanglement, tunneling) to escape local optima and find global solutions faster than classical methods.
|
|
278
|
-
</div>
|
|
279
|
-
|
|
280
|
-
<h3 style="margin-bottom: 0.5rem; color: #333;">Superposition States</h3>
|
|
281
|
-
<div class="superposition-visual" id="superposition">
|
|
282
|
-
<!-- Quantum states rendered dynamically -->
|
|
283
|
-
</div>
|
|
284
|
-
|
|
285
|
-
<div class="quantum-params">
|
|
286
|
-
<div class="param-group">
|
|
287
|
-
<div class="param-label">Particles</div>
|
|
288
|
-
<div class="param-value" id="particleCount">30</div>
|
|
289
|
-
<input type="range" id="particleSlider" min="10" max="100" value="30" oninput="updateParam('particles')">
|
|
290
|
-
</div>
|
|
291
|
-
<div class="param-group">
|
|
292
|
-
<div class="param-label">Quantum Potential</div>
|
|
293
|
-
<div class="param-value" id="quantumPotential">0.7</div>
|
|
294
|
-
<input type="range" id="potentialSlider" min="0" max="1" step="0.1" value="0.7" oninput="updateParam('potential')">
|
|
295
|
-
</div>
|
|
296
|
-
<div class="param-group">
|
|
297
|
-
<div class="param-label">Tunneling Prob</div>
|
|
298
|
-
<div class="param-value" id="tunnelingProb">0.2</div>
|
|
299
|
-
<input type="range" id="tunnelingSlider" min="0" max="1" step="0.05" value="0.2" oninput="updateParam('tunneling')">
|
|
300
|
-
</div>
|
|
301
|
-
<div class="param-group">
|
|
302
|
-
<div class="param-label">Entanglement</div>
|
|
303
|
-
<div class="param-value" id="entanglement">0.5</div>
|
|
304
|
-
<input type="range" id="entanglementSlider" min="0" max="1" step="0.1" value="0.5" oninput="updateParam('entanglement')">
|
|
305
|
-
</div>
|
|
306
|
-
</div>
|
|
307
|
-
|
|
308
|
-
<h3 style="margin-bottom: 0.5rem; color: #333;">Energy Landscape</h3>
|
|
309
|
-
<div class="energy-landscape">
|
|
310
|
-
<div class="energy-marker" id="energyMarker" style="left: 50%"></div>
|
|
311
|
-
</div>
|
|
312
|
-
|
|
313
|
-
<div class="stat-grid">
|
|
314
|
-
<div class="stat-item">
|
|
315
|
-
<div class="stat-label">Best Energy</div>
|
|
316
|
-
<div class="stat-value" id="bestEnergy">∞</div>
|
|
317
|
-
</div>
|
|
318
|
-
<div class="stat-item">
|
|
319
|
-
<div class="stat-label">Iterations</div>
|
|
320
|
-
<div class="stat-value" id="iterations">0</div>
|
|
321
|
-
</div>
|
|
322
|
-
<div class="stat-item">
|
|
323
|
-
<div class="stat-label">Tunneling Events</div>
|
|
324
|
-
<div class="stat-value" id="tunnelingEvents">0</div>
|
|
325
|
-
</div>
|
|
326
|
-
<div class="stat-item">
|
|
327
|
-
<div class="stat-label">Convergence</div>
|
|
328
|
-
<div class="stat-value" id="convergence">0%</div>
|
|
329
|
-
</div>
|
|
330
|
-
</div>
|
|
331
|
-
</div>
|
|
332
|
-
</div>
|
|
333
|
-
|
|
334
|
-
<div class="card">
|
|
335
|
-
<h2>📊 Quantum Optimization Log</h2>
|
|
336
|
-
<div id="log"></div>
|
|
337
|
-
</div>
|
|
338
|
-
</div>
|
|
339
|
-
|
|
340
|
-
<script>
|
|
341
|
-
// Quantum-Inspired Optimization with AgentDB
|
|
342
|
-
class QuantumOptimizationDB {
|
|
343
|
-
constructor() {
|
|
344
|
-
this.states = [];
|
|
345
|
-
this.bestState = null;
|
|
346
|
-
this.history = [];
|
|
347
|
-
this.entangledPairs = new Map();
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
initializeQuantumStates(count, bounds) {
|
|
351
|
-
this.states = [];
|
|
352
|
-
for (let i = 0; i < count; i++) {
|
|
353
|
-
this.states.push({
|
|
354
|
-
position: [
|
|
355
|
-
Math.random() * (bounds.xMax - bounds.xMin) + bounds.xMin,
|
|
356
|
-
Math.random() * (bounds.yMax - bounds.yMin) + bounds.yMin
|
|
357
|
-
],
|
|
358
|
-
superposition: this.createSuperposition(),
|
|
359
|
-
phase: Math.random() * Math.PI * 2,
|
|
360
|
-
energy: Infinity,
|
|
361
|
-
pBest: null
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
createSuperposition() {
|
|
367
|
-
// Quantum state in superposition (complex amplitudes)
|
|
368
|
-
const states = [];
|
|
369
|
-
const numBasis = 4;
|
|
370
|
-
|
|
371
|
-
for (let i = 0; i < numBasis; i++) {
|
|
372
|
-
states.push({
|
|
373
|
-
amplitude: Math.random(),
|
|
374
|
-
phase: Math.random() * Math.PI * 2
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// Normalize
|
|
379
|
-
const norm = Math.sqrt(states.reduce((sum, s) => sum + s.amplitude * s.amplitude, 0));
|
|
380
|
-
states.forEach(s => s.amplitude /= norm);
|
|
381
|
-
|
|
382
|
-
return states;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
measureQuantumState(state) {
|
|
386
|
-
// Collapse superposition to classical state
|
|
387
|
-
const rand = Math.random();
|
|
388
|
-
let cumulative = 0;
|
|
389
|
-
|
|
390
|
-
for (let i = 0; i < state.superposition.length; i++) {
|
|
391
|
-
cumulative += state.superposition[i].amplitude * state.superposition[i].amplitude;
|
|
392
|
-
if (rand < cumulative) {
|
|
393
|
-
return i;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
return state.superposition.length - 1;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
quantumTunneling(state, targetEnergy, probability) {
|
|
401
|
-
// Quantum tunneling through energy barriers
|
|
402
|
-
if (Math.random() < probability) {
|
|
403
|
-
const tunnelingVector = [
|
|
404
|
-
(Math.random() - 0.5) * 2,
|
|
405
|
-
(Math.random() - 0.5) * 2
|
|
406
|
-
];
|
|
407
|
-
|
|
408
|
-
state.position[0] += tunnelingVector[0];
|
|
409
|
-
state.position[1] += tunnelingVector[1];
|
|
410
|
-
|
|
411
|
-
return true;
|
|
412
|
-
}
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
createEntanglement(state1, state2) {
|
|
417
|
-
// Create quantum entanglement between states
|
|
418
|
-
this.entangledPairs.set(state1, state2);
|
|
419
|
-
this.entangledPairs.set(state2, state1);
|
|
420
|
-
|
|
421
|
-
// Synchronize phases
|
|
422
|
-
const avgPhase = (state1.phase + state2.phase) / 2;
|
|
423
|
-
state1.phase = avgPhase;
|
|
424
|
-
state2.phase = avgPhase;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
async QPSO(fitnessFunc, params, iterations) {
|
|
428
|
-
logMessage('🌊 Starting Quantum Particle Swarm Optimization...', 'info');
|
|
429
|
-
|
|
430
|
-
const { quantumPotential, entanglement } = params;
|
|
431
|
-
let gBest = { position: null, energy: Infinity };
|
|
432
|
-
|
|
433
|
-
for (let iter = 0; iter < iterations; iter++) {
|
|
434
|
-
// Evaluate fitness
|
|
435
|
-
this.states.forEach(state => {
|
|
436
|
-
state.energy = fitnessFunc(state.position[0], state.position[1]);
|
|
437
|
-
|
|
438
|
-
if (!state.pBest || state.energy < state.pBest.energy) {
|
|
439
|
-
state.pBest = { position: [...state.position], energy: state.energy };
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
if (state.energy < gBest.energy) {
|
|
443
|
-
gBest = { position: [...state.position], energy: state.energy };
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
// Quantum PSO update
|
|
448
|
-
this.states.forEach((state, idx) => {
|
|
449
|
-
// Measure quantum state
|
|
450
|
-
const measurement = this.measureQuantumState(state);
|
|
451
|
-
|
|
452
|
-
// Calculate mean best position (mbest)
|
|
453
|
-
const phi = Math.random();
|
|
454
|
-
const mbest = [
|
|
455
|
-
phi * state.pBest.position[0] + (1 - phi) * gBest.position[0],
|
|
456
|
-
phi * state.pBest.position[1] + (1 - phi) * gBest.position[1]
|
|
457
|
-
];
|
|
458
|
-
|
|
459
|
-
// Quantum update with potential well
|
|
460
|
-
const u = Math.random();
|
|
461
|
-
const sign = Math.random() < 0.5 ? 1 : -1;
|
|
462
|
-
|
|
463
|
-
state.position[0] = mbest[0] + sign * quantumPotential *
|
|
464
|
-
Math.abs(mbest[0] - state.position[0]) * Math.log(1 / u);
|
|
465
|
-
state.position[1] = mbest[1] + sign * quantumPotential *
|
|
466
|
-
Math.abs(mbest[1] - state.position[1]) * Math.log(1 / u);
|
|
467
|
-
|
|
468
|
-
// Quantum tunneling
|
|
469
|
-
if (this.quantumTunneling(state, gBest.energy, params.tunneling)) {
|
|
470
|
-
stats.tunnelingEvents++;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// Create entanglement
|
|
474
|
-
if (Math.random() < entanglement && idx < this.states.length - 1) {
|
|
475
|
-
this.createEntanglement(state, this.states[idx + 1]);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// Update phase
|
|
479
|
-
state.phase += Math.random() * 0.1;
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
// Update visualization
|
|
483
|
-
if (iter % 5 === 0) {
|
|
484
|
-
stats.iterations = iter;
|
|
485
|
-
stats.bestEnergy = gBest.energy.toFixed(4);
|
|
486
|
-
stats.convergence = Math.min(100, (iter / iterations) * 100).toFixed(0);
|
|
487
|
-
updateStats();
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// Async yield
|
|
491
|
-
if (iter % 10 === 0) {
|
|
492
|
-
await new Promise(resolve => setTimeout(resolve, 10));
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
this.bestState = gBest;
|
|
497
|
-
logMessage(`✅ Optimization complete! Best energy: ${gBest.energy.toFixed(4)}`, 'success');
|
|
498
|
-
return gBest;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
storeOptimizationRun(algorithm, result) {
|
|
502
|
-
const embedding = this.generateRunEmbedding(result);
|
|
503
|
-
this.history.push({
|
|
504
|
-
algorithm,
|
|
505
|
-
result,
|
|
506
|
-
embedding,
|
|
507
|
-
timestamp: Date.now()
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
generateRunEmbedding(result) {
|
|
512
|
-
const embedding = new Array(128).fill(0);
|
|
513
|
-
embedding[0] = result.energy;
|
|
514
|
-
embedding[1] = result.position[0];
|
|
515
|
-
embedding[2] = result.position[1];
|
|
516
|
-
embedding[3] = stats.tunnelingEvents;
|
|
517
|
-
|
|
518
|
-
for (let i = 4; i < embedding.length; i++) {
|
|
519
|
-
embedding[i] = Math.sin(result.energy * i) * Math.cos(result.position[0] * i);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
return embedding;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
// Fitness function (Rastrigin function - multi-modal optimization)
|
|
527
|
-
function rastriginFunction(x, y) {
|
|
528
|
-
const A = 10;
|
|
529
|
-
return A * 2 + (x*x - A * Math.cos(2 * Math.PI * x)) +
|
|
530
|
-
(y*y - A * Math.cos(2 * Math.PI * y));
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
// Global state
|
|
534
|
-
const db = new QuantumOptimizationDB();
|
|
535
|
-
const canvas = document.getElementById('canvas');
|
|
536
|
-
const ctx = canvas.getContext('2d');
|
|
537
|
-
canvas.width = canvas.offsetWidth;
|
|
538
|
-
canvas.height = canvas.offsetHeight;
|
|
539
|
-
|
|
540
|
-
let running = false;
|
|
541
|
-
let animationId = null;
|
|
542
|
-
let algorithm = 'qpso';
|
|
543
|
-
let params = {
|
|
544
|
-
particles: 30,
|
|
545
|
-
quantumPotential: 0.7,
|
|
546
|
-
tunneling: 0.2,
|
|
547
|
-
entanglement: 0.5
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
let stats = {
|
|
551
|
-
bestEnergy: '∞',
|
|
552
|
-
iterations: 0,
|
|
553
|
-
tunnelingEvents: 0,
|
|
554
|
-
convergence: 0
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
const bounds = { xMin: -5.12, xMax: 5.12, yMin: -5.12, yMax: 5.12 };
|
|
558
|
-
|
|
559
|
-
function drawLandscape() {
|
|
560
|
-
const width = canvas.width;
|
|
561
|
-
const height = canvas.height;
|
|
562
|
-
|
|
563
|
-
// Draw energy landscape
|
|
564
|
-
for (let x = 0; x < width; x += 5) {
|
|
565
|
-
for (let y = 0; y < height; y += 5) {
|
|
566
|
-
const realX = (x / width) * (bounds.xMax - bounds.xMin) + bounds.xMin;
|
|
567
|
-
const realY = (y / height) * (bounds.yMax - bounds.yMin) + bounds.yMin;
|
|
568
|
-
const energy = rastriginFunction(realX, realY);
|
|
569
|
-
|
|
570
|
-
const normalized = 1 - Math.min(energy / 100, 1);
|
|
571
|
-
const hue = normalized * 240; // Blue to red
|
|
572
|
-
ctx.fillStyle = `hsl(${hue}, 70%, 40%)`;
|
|
573
|
-
ctx.fillRect(x, y, 5, 5);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
function drawQuantumStates() {
|
|
579
|
-
db.states.forEach(state => {
|
|
580
|
-
const x = ((state.position[0] - bounds.xMin) / (bounds.xMax - bounds.xMin)) * canvas.width;
|
|
581
|
-
const y = ((state.position[1] - bounds.yMin) / (bounds.yMax - bounds.yMin)) * canvas.height;
|
|
582
|
-
|
|
583
|
-
// Draw quantum wave function
|
|
584
|
-
ctx.beginPath();
|
|
585
|
-
for (let angle = 0; angle < Math.PI * 2; angle += 0.1) {
|
|
586
|
-
const radius = 10 + Math.sin(state.phase + angle * 4) * 3;
|
|
587
|
-
const px = x + Math.cos(angle) * radius;
|
|
588
|
-
const py = y + Math.sin(angle) * radius;
|
|
589
|
-
|
|
590
|
-
if (angle === 0) ctx.moveTo(px, py);
|
|
591
|
-
else ctx.lineTo(px, py);
|
|
592
|
-
}
|
|
593
|
-
ctx.closePath();
|
|
594
|
-
ctx.strokeStyle = 'rgba(0, 255, 255, 0.5)';
|
|
595
|
-
ctx.lineWidth = 2;
|
|
596
|
-
ctx.stroke();
|
|
597
|
-
|
|
598
|
-
ctx.fillStyle = 'rgba(0, 255, 255, 0.8)';
|
|
599
|
-
ctx.beginPath();
|
|
600
|
-
ctx.arc(x, y, 4, 0, Math.PI * 2);
|
|
601
|
-
ctx.fill();
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
// Draw best position
|
|
605
|
-
if (db.bestState) {
|
|
606
|
-
const x = ((db.bestState.position[0] - bounds.xMin) / (bounds.xMax - bounds.xMin)) * canvas.width;
|
|
607
|
-
const y = ((db.bestState.position[1] - bounds.yMin) / (bounds.yMax - bounds.yMin)) * canvas.height;
|
|
608
|
-
|
|
609
|
-
ctx.strokeStyle = '#00ff00';
|
|
610
|
-
ctx.lineWidth = 3;
|
|
611
|
-
ctx.beginPath();
|
|
612
|
-
ctx.arc(x, y, 15, 0, Math.PI * 2);
|
|
613
|
-
ctx.stroke();
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
async function startOptimization() {
|
|
618
|
-
if (running) return;
|
|
619
|
-
|
|
620
|
-
running = true;
|
|
621
|
-
stats.tunnelingEvents = 0;
|
|
622
|
-
|
|
623
|
-
db.initializeQuantumStates(params.particles, bounds);
|
|
624
|
-
|
|
625
|
-
drawLandscape();
|
|
626
|
-
|
|
627
|
-
const result = await db.QPSO(rastriginFunction, params, 100);
|
|
628
|
-
|
|
629
|
-
db.storeOptimizationRun(algorithm, result);
|
|
630
|
-
|
|
631
|
-
running = false;
|
|
632
|
-
animate();
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
function animate() {
|
|
636
|
-
drawLandscape();
|
|
637
|
-
drawQuantumStates();
|
|
638
|
-
updateSuperpositionVisual();
|
|
639
|
-
|
|
640
|
-
if (running) {
|
|
641
|
-
animationId = requestAnimationFrame(animate);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
function updateSuperpositionVisual() {
|
|
646
|
-
const container = document.getElementById('superposition');
|
|
647
|
-
container.innerHTML = '';
|
|
648
|
-
|
|
649
|
-
for (let i = 0; i < 5; i++) {
|
|
650
|
-
const state = document.createElement('div');
|
|
651
|
-
state.className = 'quantum-state';
|
|
652
|
-
state.style.left = `${20 + i * 15}%`;
|
|
653
|
-
state.style.animationDelay = `${i * 0.2}s`;
|
|
654
|
-
container.appendChild(state);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
function reset() {
|
|
659
|
-
running = false;
|
|
660
|
-
if (animationId) cancelAnimationFrame(animationId);
|
|
661
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
662
|
-
drawLandscape();
|
|
663
|
-
stats = { bestEnergy: '∞', iterations: 0, tunnelingEvents: 0, convergence: 0 };
|
|
664
|
-
updateStats();
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
function setAlgorithm(algo) {
|
|
668
|
-
algorithm = algo;
|
|
669
|
-
document.querySelectorAll('.algo-btn').forEach(btn => btn.classList.remove('active'));
|
|
670
|
-
event.target.classList.add('active');
|
|
671
|
-
logMessage(`Algorithm changed to: ${algo.toUpperCase()}`, 'info');
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
function updateParam(type) {
|
|
675
|
-
switch(type) {
|
|
676
|
-
case 'particles':
|
|
677
|
-
params.particles = parseInt(document.getElementById('particleSlider').value);
|
|
678
|
-
document.getElementById('particleCount').textContent = params.particles;
|
|
679
|
-
break;
|
|
680
|
-
case 'potential':
|
|
681
|
-
params.quantumPotential = parseFloat(document.getElementById('potentialSlider').value);
|
|
682
|
-
document.getElementById('quantumPotential').textContent = params.quantumPotential.toFixed(1);
|
|
683
|
-
break;
|
|
684
|
-
case 'tunneling':
|
|
685
|
-
params.tunneling = parseFloat(document.getElementById('tunnelingSlider').value);
|
|
686
|
-
document.getElementById('tunnelingProb').textContent = params.tunneling.toFixed(2);
|
|
687
|
-
break;
|
|
688
|
-
case 'entanglement':
|
|
689
|
-
params.entanglement = parseFloat(document.getElementById('entanglementSlider').value);
|
|
690
|
-
document.getElementById('entanglement').textContent = params.entanglement.toFixed(1);
|
|
691
|
-
break;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function updateStats() {
|
|
696
|
-
document.getElementById('bestEnergy').textContent = stats.bestEnergy;
|
|
697
|
-
document.getElementById('iterations').textContent = stats.iterations;
|
|
698
|
-
document.getElementById('tunnelingEvents').textContent = stats.tunnelingEvents;
|
|
699
|
-
document.getElementById('convergence').textContent = stats.convergence + '%';
|
|
700
|
-
|
|
701
|
-
// Update energy marker
|
|
702
|
-
if (stats.bestEnergy !== '∞') {
|
|
703
|
-
const normalized = 1 - Math.min(parseFloat(stats.bestEnergy) / 100, 1);
|
|
704
|
-
document.getElementById('energyMarker').style.left = (normalized * 100) + '%';
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
function logMessage(message, type = '') {
|
|
709
|
-
const log = document.getElementById('log');
|
|
710
|
-
const entry = document.createElement('div');
|
|
711
|
-
entry.className = `log-entry ${type}`;
|
|
712
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
713
|
-
entry.textContent = `[${timestamp}] ${message}`;
|
|
714
|
-
log.insertBefore(entry, log.firstChild);
|
|
715
|
-
|
|
716
|
-
while (log.children.length > 20) {
|
|
717
|
-
log.removeChild(log.lastChild);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
// Initialize
|
|
722
|
-
drawLandscape();
|
|
723
|
-
updateSuperpositionVisual();
|
|
724
|
-
logMessage('⚛️ Quantum optimization system initialized', 'success');
|
|
725
|
-
logMessage('Using Rastrigin function (highly multi-modal) for testing', 'info');
|
|
726
|
-
</script>
|
|
727
|
-
</body>
|
|
728
|
-
</html>
|