From 4bf9491970e5010290a89a82fc10edecb6208c5f Mon Sep 17 00:00:00 2001 From: Smoren Date: Mon, 9 Dec 2024 01:39:30 +0300 Subject: [PATCH] Chart added to genetic algo. --- package.json | 5 ++- .../components/sections/genetic-section.vue | 23 ++++++++-- .../components/sections/summary-section.vue | 10 ++--- .../widgets/{chart.vue => chart-flow.vue} | 0 .../components/widgets/chart-static.vue | 42 +++++++++++++++++++ src/web/store/genetic.ts | 7 ++-- 6 files changed, 73 insertions(+), 14 deletions(-) rename src/web/components/config-editor/components/widgets/{chart.vue => chart-flow.vue} (100%) create mode 100644 src/web/components/config-editor/components/widgets/chart-static.vue diff --git a/package.json b/package.json index a8ffc1fb..92e5ce1c 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "bootstrap": "^5.2.3", "bootstrap-icons": "^1.10.3", "browser-process": "^0.0.1", - "genetic-search-multiprocess": "^1.1.1", + "genetic-search-multiprocess": "^1.2.1", "itertools-ts": "^1.27.1", "mdb-vue-ui-kit": "^4.1.1", "multiprocess-pool": "^1.4.5", @@ -34,7 +34,8 @@ "pinia": "^2.0.28", "smoothie": "^1.36.1", "unplugin-vue-macros": "^2.7.9", - "vue": "^3.4.15" + "vue": "^3.4.15", + "vue3-charts": "^1.1.33" }, "devDependencies": { "@types/jest": "^29.5.12", diff --git a/src/web/components/config-editor/components/sections/genetic-section.vue b/src/web/components/config-editor/components/sections/genetic-section.vue index 8eb95ede..311466db 100644 --- a/src/web/components/config-editor/components/sections/genetic-section.vue +++ b/src/web/components/config-editor/components/sections/genetic-section.vue @@ -3,12 +3,13 @@ import { useGeneticStore } from "@/web/store/genetic"; import { round } from "@/lib/math"; import InputHeader from "@/web/components/base/input-header.vue"; -import { ref } from "vue"; +import { computed, ref } from "vue"; import { MDBAccordion, MDBAccordionItem } from "mdb-vue-ui-kit"; +import ChartStatic from "@/web/components/config-editor/components/widgets/chart-static.vue"; const geneticStore = useGeneticStore(); - const activeAccordionItem = ref('collapse-macro'); +const fitnessChartData = computed(() => geneticStore.populationFitness.map((y, x) => ({x, y}))); @@ -28,7 +29,6 @@ const activeAccordionItem = ref('collapse-macro');
-
@@ -36,6 +36,10 @@ const activeAccordionItem = ref('collapse-macro'); + + + + @@ -55,6 +59,10 @@ const activeAccordionItem = ref('collapse-macro');
Generation {{ geneticStore.generation }}
Stagnation counter{{ geneticStore.populationSummary!.stagnationCounter }}
Best genome ID {{ geneticStore.bestGenome!.id }}
+
+
Population fitness
+ +
@@ -155,4 +163,13 @@ const activeAccordionItem = ref('collapse-macro'); width: 100%; } +.genetic-charts-container { + margin-top: 30px; + margin-bottom: 30px; + + h6 { + margin-bottom: 15px; + } +} + diff --git a/src/web/components/config-editor/components/sections/summary-section.vue b/src/web/components/config-editor/components/sections/summary-section.vue index 31e9a755..b7df0fd7 100644 --- a/src/web/components/config-editor/components/sections/summary-section.vue +++ b/src/web/components/config-editor/components/sections/summary-section.vue @@ -3,8 +3,8 @@ import { ref, type Ref } from 'vue'; import ConfigSection from '@/web/components/config-editor/components/containers/config-section.vue'; import { useSimulationStore } from '@/web/store/simulation'; -import type { TimeSeriesConfig } from "@/web/components/config-editor/components/widgets/chart.vue"; -import Chart from "@/web/components/config-editor/components/widgets/chart.vue"; +import type { TimeSeriesConfig } from "@/web/components/config-editor/components/widgets/chart-flow.vue"; +import ChartFlow from "@/web/components/config-editor/components/widgets/chart-flow.vue"; import Flag from '@/web/components/inputs/flag.vue'; const { getCurrentSimulation } = useSimulationStore(); @@ -255,7 +255,7 @@ const timeSeriesConfigMean: ChartConfig[] = [