-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesign.go
More file actions
539 lines (476 loc) · 17.6 KB
/
design.go
File metadata and controls
539 lines (476 loc) · 17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
package vsm
import (
"errors"
"fmt"
"time"
)
// DesignResult contains the results of the value stream design phase
type DesignResult struct {
ValueStreamID string `json:"value_stream_id"`
ImprovementPotentials []ImprovementPotential `json:"improvement_potentials"`
IdealState *ValueStream `json:"ideal_state"`
FutureState *ValueStream `json:"future_state"`
DesignPrinciples []DesignPrinciple `json:"design_principles"`
ContinuousImprovements []ContinuousImprovement `json:"continuous_improvements"`
DesignedAt time.Time `json:"designed_at"`
}
// ImprovementPotential represents a potential improvement in the value stream
type ImprovementPotential struct {
ID string `json:"id"`
Type string `json:"type"` // "bottleneck", "waste", "flow", "quality", etc.
Location string `json:"location"` // Process or area where improvement applies
Description string `json:"description"`
Priority int `json:"priority"` // 1=high, 2=medium, 3=low
Impact float64 `json:"impact"` // Estimated improvement impact (0-1)
Effort float64 `json:"effort"` // Estimated effort required (0-1)
}
// DesignPrinciple represents the 8 VSM design principles from Rother & Shook
type DesignPrinciple struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Applied bool `json:"applied"`
Status string `json:"status"` // "not_applicable", "planned", "implemented"
}
// ContinuousImprovement represents continuous improvement flashes
type ContinuousImprovement struct {
ID string `json:"id"`
ProcessID string `json:"process_id"`
Description string `json:"description"`
Type string `json:"type"` // "kaizen", "quick_win", "major_change"
Priority int `json:"priority"`
Status string `json:"status"` // "identified", "planned", "implemented"
CreatedAt time.Time `json:"created_at"`
}
// Designer provides methods for designing improved value streams
type Designer struct {
calculator *Calculator
analyzer *Analyzer
}
// NewDesigner creates a new VSM designer
func NewDesigner() *Designer {
return &Designer{
calculator: NewCalculator(),
analyzer: NewAnalyzer(),
}
}
// DesignFutureState performs the complete design phase for a value stream
func (d *Designer) DesignFutureState(current *ValueStream, analysis *AnalysisResult) (*DesignResult, error) {
if current == nil {
return nil, errors.New("current value stream cannot be nil")
}
result := &DesignResult{
ValueStreamID: current.ID,
DesignedAt: time.Now(),
}
// Identify improvement potentials
potentials, err := d.IdentifyImprovementPotentials(current, analysis)
if err != nil {
return nil, fmt.Errorf("failed to identify improvement potentials: %w", err)
}
result.ImprovementPotentials = potentials
// Create ideal state
idealState, err := d.CreateIdealState(current)
if err != nil {
return nil, fmt.Errorf("failed to create ideal state: %w", err)
}
result.IdealState = idealState
// Design future state based on ideal state and practical constraints
futureState, err := d.DesignFutureStateFromIdeal(idealState, current)
if err != nil {
return nil, fmt.Errorf("failed to design future state: %w", err)
}
result.FutureState = futureState
// Apply VSM design principles
principles := d.ApplyDesignPrinciples(current, futureState)
result.DesignPrinciples = principles
// Identify continuous improvements
improvements := d.IdentifyContinuousImprovements(current, analysis)
result.ContinuousImprovements = improvements
return result, nil
}
// IdentifyImprovementPotentials identifies potential improvements based on analysis
func (d *Designer) IdentifyImprovementPotentials(vs *ValueStream, analysis *AnalysisResult) ([]ImprovementPotential, error) {
var potentials []ImprovementPotential
// Based on bottlenecks
for _, bottleneck := range analysis.Bottlenecks {
potentials = append(potentials, ImprovementPotential{
ID: fmt.Sprintf("bottleneck_%s", bottleneck.ProcessID),
Type: "bottleneck",
Location: bottleneck.ProcessName,
Description: fmt.Sprintf("Optimize bottleneck process: %s", bottleneck.Description),
Priority: d.calculatePriorityFromUtilization(bottleneck.Utilization),
Impact: bottleneck.Utilization - 0.7, // Improvement needed to reach 70% utilization
Effort: 0.6, // Medium effort
})
}
// Based on waste analysis
for wasteType, amount := range analysis.WasteAnalysis.WasteByType {
if amount > 0 {
potentials = append(potentials, ImprovementPotential{
ID: fmt.Sprintf("waste_%s", wasteType),
Type: "waste",
Location: "Value Stream",
Description: fmt.Sprintf("Reduce %s waste (%.2f time units)", wasteType, amount),
Priority: 2,
Impact: d.calculateWasteImpact(wasteType),
Effort: 0.4,
})
}
}
// Based on flow analysis
if analysis.FlowAnalysis.FlowType == FlowTypePush {
potentials = append(potentials, ImprovementPotential{
ID: "flow_push_to_pull",
Type: "flow",
Location: "Value Stream",
Description: "Transition from push to pull system",
Priority: 1,
Impact: 0.8,
Effort: 0.8,
})
}
for _, interruption := range analysis.FlowAnalysis.FlowInterruptions {
potentials = append(potentials, ImprovementPotential{
ID: fmt.Sprintf("flow_%s_%s", interruption.Type, interruption.Location),
Type: "flow",
Location: interruption.Location,
Description: interruption.Description,
Priority: 2,
Impact: interruption.Impact / 100, // Normalize impact
Effort: 0.5,
})
}
// Sort by priority and impact
for i := range potentials {
potentials[i].Priority = d.calculateOverallPriority(potentials[i])
}
return potentials, nil
}
// calculatePriorityFromUtilization calculates priority based on utilization
func (d *Designer) calculatePriorityFromUtilization(utilization float64) int {
if utilization > 0.9 {
return 1 // High priority
} else if utilization > 0.8 {
return 2 // Medium priority
}
return 3 // Low priority
}
// calculateWasteImpact calculates the impact of reducing specific waste types
func (d *Designer) calculateWasteImpact(wasteType string) float64 {
switch wasteType {
case "transportation":
return 0.3
case "inventory":
return 0.4
case "waiting":
return 0.5
case "defects":
return 0.6
case "over_processing":
return 0.4
case "over_production":
return 0.3
case "motion":
return 0.2
default:
return 0.3
}
}
// calculateOverallPriority calculates overall priority considering impact and effort
func (d *Designer) calculateOverallPriority(potential ImprovementPotential) int {
// Simple priority calculation: high impact + low effort = high priority
score := potential.Impact / potential.Effort
if score > 1.5 {
return 1
} else if score > 0.8 {
return 2
}
return 3
}
// CreateIdealState creates an ideal (waste-free) value stream state
func (d *Designer) CreateIdealState(current *ValueStream) (*ValueStream, error) {
ideal := &ValueStream{
ID: current.ID + "_ideal",
Name: current.Name + " (Ideal State)",
State: StateIdeal,
ProductFamily: current.ProductFamily,
Description: "Waste-free ideal state with minimal lead time",
Customer: current.Customer,
Supplier: current.Supplier,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
// In ideal state, all processes are perfectly balanced
// Lead time = Value-adding time only (no waste)
var idealProcesses []Process
for _, process := range current.Processes {
idealProcess := process
idealProcess.ID = process.ID + "_ideal"
idealProcess.Name = process.Name + " (Ideal)"
// In ideal state: only value-adding time remains
idealProcess.Parameters.ProcessTime = process.Parameters.ValueAddingTime
idealProcess.Parameters.IdleTime = 0
idealProcess.Parameters.WaitingTime = 0
idealProcess.Parameters.TransportTime = 0
idealProcess.Parameters.StorageTime = 0
idealProcess.Parameters.NonValueAddingTime = 0
idealProcess.Parameters.NecessaryNonValueAddingTime = 0
idealProcess.Parameters.ScrapRate = 0
idealProcess.Parameters.ReworkRate = 0
idealProcess.Parameters.YieldFactor = 1.0
idealProcesses = append(idealProcesses, idealProcess)
}
ideal.Processes = idealProcesses
// No inventory in ideal state (continuous flow)
ideal.Inventory = []Inventory{}
// Calculate ideal KPIs
ideal.KPIs = d.calculator.CalculateKPIs(ideal)
return ideal, nil
}
// DesignFutureStateFromIdeal creates a practical future state based on the ideal state
func (d *Designer) DesignFutureStateFromIdeal(ideal, current *ValueStream) (*ValueStream, error) {
future := &ValueStream{
ID: current.ID + "_future",
Name: current.Name + " (Future State)",
State: StateFuture,
ProductFamily: current.ProductFamily,
Description: "Improved future state based on ideal state principles",
Customer: current.Customer,
Supplier: current.Supplier,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
// Apply VSM principles to create future state
var futureProcesses []Process
for _, process := range current.Processes {
futureProcess := process
futureProcess.ID = process.ID + "_future"
futureProcess.Name = process.Name + " (Future)"
// Reduce waste by 50-70% compared to current state
futureProcess.Parameters.ProcessTime = process.Parameters.ProcessTime * 0.6
futureProcess.Parameters.IdleTime = process.Parameters.IdleTime * 0.3
futureProcess.Parameters.WaitingTime = process.Parameters.WaitingTime * 0.4
futureProcess.Parameters.TransportTime = process.Parameters.TransportTime * 0.5
futureProcess.Parameters.StorageTime = process.Parameters.StorageTime * 0.5
futureProcess.Parameters.NonValueAddingTime = process.Parameters.NonValueAddingTime * 0.4
futureProcess.Parameters.NecessaryNonValueAddingTime = process.Parameters.NecessaryNonValueAddingTime * 0.6
futureProcess.Parameters.ScrapRate = process.Parameters.ScrapRate * 0.3
futureProcess.Parameters.ReworkRate = process.Parameters.ReworkRate * 0.4
// Improve yield factor
if process.Parameters.YieldFactor < 0.95 {
futureProcess.Parameters.YieldFactor = 0.95
}
futureProcesses = append(futureProcesses, futureProcess)
}
future.Processes = futureProcesses
// Implement supermarket for pull system
if len(current.Inventory) > 0 {
supermarket := Inventory{
ID: "supermarket_1",
Name: "Supermarket",
Quantity: current.Customer.Demand * 0.1, // Small buffer
Range: 0.5, // Half day coverage
Type: "supermarket",
Description: "Pull system supermarket",
}
future.Inventory = []Inventory{supermarket}
}
// Add flow control elements
future.FlowElements = []FlowElement{
{
ID: "fifo_lane_1",
Type: "fifo",
Capacity: 10,
Description: "FIFO lane between processes",
},
{
ID: "kanban_1",
Type: "kanban",
Capacity: 5,
ControlTickets: []string{"ticket_1", "ticket_2", "ticket_3", "ticket_4", "ticket_5"},
Description: "Kanban control system",
},
}
// Calculate future KPIs
future.KPIs = d.calculator.CalculateKPIs(future)
return future, nil
}
// ApplyDesignPrinciples applies the 8 VSM design principles from Rother & Shook
func (d *Designer) ApplyDesignPrinciples(current, future *ValueStream) []DesignPrinciple {
principles := []DesignPrinciple{
{
ID: "takt_time",
Name: "Takt time at pacemaker process",
Description: "Customer takt time determines pace of pacemaker process",
Applied: d.checkTaktTimePrinciple(future),
Status: "planned",
},
{
ID: "supermarket_direct",
Name: "Supermarket or direct shipping",
Description: "Use supermarket for upstream processes, direct shipping for downstream",
Applied: d.checkSupermarketPrinciple(future),
Status: "planned",
},
{
ID: "continuous_flow",
Name: "Continuous product flow",
Description: "Minimize interruptions in product flow between processes",
Applied: d.checkContinuousFlowPrinciple(future),
Status: "planned",
},
{
ID: "pull_system",
Name: "Supermarket pull systems",
Description: "Use pull systems to control production at supermarket locations",
Applied: d.checkPullSystemPrinciple(future),
Status: "planned",
},
{
ID: "pacemaker_definition",
Name: "Definition of pacemaker process",
Description: "Clearly define which process sets the pace for the entire value stream",
Applied: d.checkPacemakerPrinciple(future),
Status: "planned",
},
{
ID: "leveling",
Name: "Levelling of product mix",
Description: "Level product mix at pacemaker process to smooth production",
Applied: false, // Would need more detailed analysis
Status: "not_applicable",
},
{
ID: "pacemaker_release",
Name: "Release at pacemaker process",
Description: "Release work at pacemaker process based on customer demand",
Applied: d.checkReleasePrinciple(future),
Status: "planned",
},
{
ID: "continuous_improvement",
Name: "Further process improvements",
Description: "Continuous improvement of all processes using CIP",
Applied: true, // Always applicable
Status: "planned",
},
}
// Update status based on application
for i := range principles {
if principles[i].Applied {
principles[i].Status = "implemented"
}
}
return principles
}
// checkTaktTimePrinciple checks if takt time principle is applied
func (d *Designer) checkTaktTimePrinciple(vs *ValueStream) bool {
if vs.Customer == nil {
return false
}
// Check if any process has cycle time close to customer takt
for _, process := range vs.Processes {
if process.Parameters.CycleTime > 0 {
ratio := process.Parameters.CycleTime / vs.Customer.TaktTime
if ratio >= 0.9 && ratio <= 1.1 { // Within 10% of takt time
return true
}
}
}
return false
}
// checkSupermarketPrinciple checks if supermarket principle is applied
func (d *Designer) checkSupermarketPrinciple(vs *ValueStream) bool {
for _, inv := range vs.Inventory {
if inv.Type == "supermarket" {
return true
}
}
return false
}
// checkContinuousFlowPrinciple checks if continuous flow principle is applied
func (d *Designer) checkContinuousFlowPrinciple(vs *ValueStream) bool {
// Check for low idle times and waiting times
totalIdle := 0.0
totalProcess := 0.0
for _, process := range vs.Processes {
totalIdle += process.Parameters.IdleTime
totalProcess += d.calculator.CalculateProcessTime(process.Parameters)
}
if totalProcess > 0 {
idleRatio := totalIdle / totalProcess
return idleRatio < 0.5 // Less than 50% idle time indicates good flow
}
return false
}
// checkPullSystemPrinciple checks if pull system principle is applied
func (d *Designer) checkPullSystemPrinciple(vs *ValueStream) bool {
for _, element := range vs.FlowElements {
if element.Type == "kanban" || element.Type == "supermarket" {
return true
}
}
return false
}
// checkPacemakerPrinciple checks if pacemaker principle is properly defined
func (d *Designer) checkPacemakerPrinciple(vs *ValueStream) bool {
// Pacemaker should have the highest utilization or be explicitly defined
maxUtilization := 0.0
for _, process := range vs.Processes {
utilization := d.analyzer.calculateProcessUtilization(process, vs)
if utilization > maxUtilization {
maxUtilization = utilization
}
}
return maxUtilization > 0.8 // Pacemaker should be highly utilized
}
// checkReleasePrinciple checks if release principle is applied
func (d *Designer) checkReleasePrinciple(vs *ValueStream) bool {
// Check if there's a clear release mechanism (kanban, signals, etc.)
return len(vs.FlowElements) > 0
}
// IdentifyContinuousImprovements identifies specific continuous improvement opportunities
func (d *Designer) IdentifyContinuousImprovements(vs *ValueStream, analysis *AnalysisResult) []ContinuousImprovement {
var improvements []ContinuousImprovement
now := time.Now()
// Generate improvements based on bottlenecks
for _, bottleneck := range analysis.Bottlenecks {
improvements = append(improvements, ContinuousImprovement{
ID: fmt.Sprintf("ci_bottleneck_%s", bottleneck.ProcessID),
ProcessID: bottleneck.ProcessID,
Description: fmt.Sprintf("Optimize bottleneck process '%s' to reduce utilization from %.1f%%",
bottleneck.ProcessName, bottleneck.Utilization*100),
Type: "kaizen",
Priority: 1,
Status: "identified",
CreatedAt: now,
})
}
// Generate improvements based on waste
if analysis.WasteAnalysis.TotalWaste > 0 {
improvements = append(improvements, ContinuousImprovement{
ID: "ci_waste_reduction",
ProcessID: "", // System-wide
Description: fmt.Sprintf("Implement 5S and standard work to reduce waste by %.1f%%",
analysis.WasteAnalysis.WasteReductionPotential/analysis.WasteAnalysis.TotalWaste*100),
Type: "major_change",
Priority: 2,
Status: "identified",
CreatedAt: now,
})
}
// Generate improvements based on flow issues
for _, interruption := range analysis.FlowAnalysis.FlowInterruptions {
improvements = append(improvements, ContinuousImprovement{
ID: fmt.Sprintf("ci_flow_%s", interruption.Type),
ProcessID: "", // Location-specific
Description: interruption.Description,
Type: "quick_win",
Priority: 2,
Status: "identified",
CreatedAt: now,
})
}
return improvements
}