add simulation module
This commit is contained in:
37
src/modules/simulation/SimulationControls.vue
Normal file
37
src/modules/simulation/SimulationControls.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import { useSimulationStore } from '@/modules/simulation/simulation-store'
|
||||
const simulationStore = useSimulationStore()
|
||||
const NUMBER_OF_SIMULATION = 300
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="simulation-controls">
|
||||
<button @click="simulationStore.simulate('push')">
|
||||
simulate push system
|
||||
</button>
|
||||
<button @click="simulationStore.simulate('pull')">
|
||||
simulate pull system
|
||||
</button>
|
||||
<button @click="simulationStore.simulate('problem-solving')">
|
||||
simulate pull and problem solving
|
||||
</button>
|
||||
<button
|
||||
@click="simulationStore.multiSimulation(NUMBER_OF_SIMULATION, 'push')"
|
||||
>
|
||||
simulate {{ NUMBER_OF_SIMULATION }} push system
|
||||
</button>
|
||||
<button
|
||||
@click="simulationStore.multiSimulation(NUMBER_OF_SIMULATION, 'pull')"
|
||||
>
|
||||
simulate {{ NUMBER_OF_SIMULATION }} pull system
|
||||
</button>
|
||||
<button
|
||||
@click="
|
||||
simulationStore.multiSimulation(NUMBER_OF_SIMULATION, 'problem-solving')
|
||||
"
|
||||
>
|
||||
simulate {{ NUMBER_OF_SIMULATION }} pull and problem solving
|
||||
</button>
|
||||
<button @click="simulationStore.clearDashboard()">clear dashboard</button>
|
||||
</div>
|
||||
</template>
|
||||
43
src/modules/simulation/SimulationDashboard.vue
Normal file
43
src/modules/simulation/SimulationDashboard.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import { useSimulationStore } from '@/modules/simulation/simulation-store'
|
||||
|
||||
const simulationStore = useSimulationStore()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="simulation-dashboard">
|
||||
Dashboard ({{ simulationStore.simulationsDone }} /
|
||||
{{ simulationStore.requestedSimulation }}
|
||||
simulations)
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>push</th>
|
||||
<th>pull</th>
|
||||
<th>pull and DPS</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>lead time</td>
|
||||
<td>
|
||||
{{ simulationStore.meanPushLeadTime }}
|
||||
</td>
|
||||
<td>
|
||||
{{ simulationStore.meanPullLeadTime }}
|
||||
</td>
|
||||
<td>
|
||||
{{ simulationStore.meanPullDPSLeadTime }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.simulation-dashboard {
|
||||
color: var(--background-color);
|
||||
}
|
||||
</style>
|
||||
108
src/modules/simulation/simulation-store.ts
Normal file
108
src/modules/simulation/simulation-store.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { featureSteps } from '@/modules/feature/feature-steps'
|
||||
import { Strategy } from '@/modules/lean/strategy'
|
||||
import { Dashboard, Meta } from '@/store-type'
|
||||
import { getMean } from '@/utils'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
type State = {
|
||||
dashboards: Dashboard[]
|
||||
requestedSimulation: number
|
||||
simulationsDone: number
|
||||
}
|
||||
|
||||
const instance = new ComlinkWorker<typeof import('../feature/feature-board')>(
|
||||
new URL('../feature/feature-board', import.meta.url)
|
||||
)
|
||||
|
||||
const resetMeta = (): Meta => ({
|
||||
totalDays: 0,
|
||||
daysWithProblemSolving: 0,
|
||||
strategy: {
|
||||
push: 0,
|
||||
pull: 0,
|
||||
'problem-solving': 0
|
||||
}
|
||||
})
|
||||
|
||||
export const useSimulationStore = defineStore('dashboard', {
|
||||
state: (): State => {
|
||||
return {
|
||||
dashboards: [],
|
||||
requestedSimulation: 0,
|
||||
simulationsDone: 0
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
newDashboard(dashboard: Dashboard) {
|
||||
this.dashboards.push(dashboard)
|
||||
},
|
||||
async simulate(strategy: Strategy) {
|
||||
const steps = featureSteps
|
||||
const backlog = await instance.newBacklog()
|
||||
const features = await instance.initBoard(steps, backlog)
|
||||
|
||||
const newState = await instance.simulate(
|
||||
{
|
||||
backlog,
|
||||
steps,
|
||||
features,
|
||||
meta: resetMeta()
|
||||
},
|
||||
strategy
|
||||
)
|
||||
|
||||
const [worstFeature] = newState.features.sort((a, b) =>
|
||||
a.qualityIssue > b.qualityIssue ? -1 : 1
|
||||
)
|
||||
|
||||
this.newDashboard({
|
||||
uuid: new Date().getTime().toString(),
|
||||
meta: newState.meta,
|
||||
analysis: {
|
||||
meanComplexity: await instance.getMeanComplexity(newState.features),
|
||||
meanLeadTime: await instance.getMeanLeadTime(newState.features),
|
||||
meanQualityIssue: await instance.getMeanQualityIssue(
|
||||
newState.features
|
||||
),
|
||||
worstFeature,
|
||||
strategy
|
||||
}
|
||||
})
|
||||
},
|
||||
async multiSimulation(simulations: number, strategy: Strategy) {
|
||||
this.requestedSimulation += simulations
|
||||
for (let i = 0; i < simulations; i++) {
|
||||
await this.simulate(strategy)
|
||||
this.simulationsDone++
|
||||
}
|
||||
},
|
||||
clearDashboard() {
|
||||
this.dashboards = []
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
meanPushLeadTime: (state) => {
|
||||
return getMean(
|
||||
state.dashboards
|
||||
.filter((dashboard) => dashboard.analysis.strategy === 'push')
|
||||
.map((dashboard) => dashboard.analysis.meanLeadTime)
|
||||
)
|
||||
},
|
||||
meanPullLeadTime: (state) => {
|
||||
return getMean(
|
||||
state.dashboards
|
||||
.filter((dashboard) => dashboard.analysis.strategy === 'pull')
|
||||
.map((dashboard) => dashboard.analysis.meanLeadTime)
|
||||
)
|
||||
},
|
||||
meanPullDPSLeadTime: (state) => {
|
||||
return getMean(
|
||||
state.dashboards
|
||||
.filter(
|
||||
(dashboard) => dashboard.analysis.strategy === 'problem-solving'
|
||||
)
|
||||
.map((dashboard) => dashboard.analysis.meanLeadTime)
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user