1+ /**
2+ * DGM System Demo
3+ *
4+ * Demonstrates the Darwin Gƶdel Machine capabilities
5+ */
6+
7+ import { createDGMSystem , DGMSystemFactory } from '../src/core/dgm/index.js' ;
8+ import { Logger } from '../src/utils/logger.js' ;
9+
10+ const logger = new Logger ( 'DGMDemo' ) ;
11+
12+ async function runDGMDemo ( ) {
13+ console . log ( '𧬠Darwin Gödel Machine (DGM) System Demo' ) ;
14+ console . log ( '=' . repeat ( 50 ) ) ;
15+
16+ try {
17+ // 1. Create a balanced DGM system
18+ console . log ( '\n1. Creating DGM System...' ) ;
19+ const dgmSystem = DGMSystemFactory . createBalanced ( process . cwd ( ) ) ;
20+
21+ // 2. Initialize the system
22+ console . log ( '\n2. Initializing DGM...' ) ;
23+ await dgmSystem . initialize ( ) ;
24+ console . log ( 'ā
DGM system initialized successfully' ) ;
25+
26+ // 3. Get initial system status
27+ const initialStatus = dgmSystem . getSystemStatus ( ) ;
28+ console . log ( `\n3. Initial System Health: ${ initialStatus . systemHealth . toFixed ( 1 ) } %` ) ;
29+ console . log ( ` Debt Metrics:` , Object . entries ( initialStatus . debtMetrics )
30+ . map ( ( [ key , value ] ) => `${ key } : ${ ( ( value as number ) * 100 ) . toFixed ( 1 ) } %` )
31+ . join ( ', ' ) ) ;
32+
33+ // 4. Start the system
34+ console . log ( '\n4. Starting DGM System...' ) ;
35+ await dgmSystem . start ( ) ;
36+ console . log ( 'ā
DGM system is now active' ) ;
37+
38+ // 5. Execute an evolution cycle
39+ console . log ( '\n5. Executing Evolution Cycle...' ) ;
40+ const evolutionReport = await dgmSystem . executeEvolutionCycle ( ) ;
41+
42+ console . log ( `\nš Evolution Results:` ) ;
43+ console . log ( ` Strategies Evaluated: ${ evolutionReport . strategiesEvaluated } ` ) ;
44+ console . log ( ` Fitness Improvement: ${ evolutionReport . fitnessImprovement > 0 ? '+' : '' } ${ evolutionReport . fitnessImprovement . toFixed ( 3 ) } ` ) ;
45+ console . log ( ` Patterns Archived: ${ evolutionReport . patternsArchived } ` ) ;
46+ console . log ( ` Status: ${ evolutionReport . status } ` ) ;
47+ console . log ( ` Execution Time: ${ evolutionReport . executionTime } ms` ) ;
48+
49+ if ( evolutionReport . bestStrategy ) {
50+ console . log ( `\nš Best Strategy: ${ evolutionReport . bestStrategy . name } ` ) ;
51+ console . log ( ` Fitness Score: ${ evolutionReport . bestStrategy . fitness . toFixed ( 3 ) } ` ) ;
52+ console . log ( ` Generation: ${ evolutionReport . bestStrategy . generation } ` ) ;
53+ }
54+
55+ if ( evolutionReport . recommendations . length > 0 ) {
56+ console . log ( `\nš” Recommendations:` ) ;
57+ evolutionReport . recommendations . slice ( 0 , 3 ) . forEach ( ( rec , i ) => {
58+ console . log ( ` ${ i + 1 } . ${ rec } ` ) ;
59+ } ) ;
60+ }
61+
62+ // 6. Generate system insights
63+ console . log ( '\n6. Generating System Insights...' ) ;
64+ const insights = await dgmSystem . generateSystemInsights ( ) ;
65+
66+ console . log ( `\nš§ System Insights:` ) ;
67+ if ( insights . evolutionInsights . length > 0 ) {
68+ console . log ( ` Evolution: ${ insights . evolutionInsights [ 0 ] } ` ) ;
69+ }
70+ if ( insights . patternInsights . length > 0 ) {
71+ console . log ( ` Patterns: ${ insights . patternInsights [ 0 ] } ` ) ;
72+ }
73+ if ( insights . performanceInsights . length > 0 ) {
74+ console . log ( ` Performance: ${ insights . performanceInsights [ 0 ] } ` ) ;
75+ }
76+
77+ // 7. Query archived patterns
78+ console . log ( '\n7. Querying Archived Patterns...' ) ;
79+ const patterns = await dgmSystem . queryPatterns ( {
80+ minFitnessScore : 0.5 ,
81+ limit : 3
82+ } ) ;
83+
84+ console . log ( `\nš Found ${ patterns . length } archived patterns` ) ;
85+ patterns . forEach ( ( pattern , i ) => {
86+ console . log ( ` ${ i + 1 } . ${ pattern . strategy . name } - Fitness: ${ pattern . successMetrics . fitnessScore . toFixed ( 3 ) } ` ) ;
87+ } ) ;
88+
89+ // 8. Final status
90+ const finalStatus = dgmSystem . getSystemStatus ( ) ;
91+ console . log ( `\n8. Final System Health: ${ finalStatus . systemHealth . toFixed ( 1 ) } %` ) ;
92+ const improvement = finalStatus . systemHealth - initialStatus . systemHealth ;
93+ console . log ( ` Health Improvement: ${ improvement > 0 ? '+' : '' } ${ improvement . toFixed ( 1 ) } %` ) ;
94+
95+ // 9. Evolution history
96+ const history = dgmSystem . getEvolutionHistory ( 5 ) ;
97+ console . log ( `\nš Evolution History: ${ history . length } cycles completed` ) ;
98+
99+ // 10. Stop the system
100+ console . log ( '\n9. Stopping DGM System...' ) ;
101+ await dgmSystem . stop ( ) ;
102+ console . log ( 'ā
DGM system stopped successfully' ) ;
103+
104+ console . log ( '\nš DGM Demo Complete!' ) ;
105+ console . log ( '\nThe Darwin Gƶdel Machine has demonstrated:' ) ;
106+ console . log ( '⢠Baseline establishment and validation framework' ) ;
107+ console . log ( '⢠Evolutionary strategy generation and A/B testing' ) ;
108+ console . log ( '⢠Fitness evaluation and benchmarking' ) ;
109+ console . log ( '⢠Pattern archiving for future learning' ) ;
110+ console . log ( '⢠Autonomous monitoring and recommendations' ) ;
111+ console . log ( '⢠Continuous system improvement capabilities' ) ;
112+
113+ } catch ( error ) {
114+ console . error ( '\nā Demo failed:' , error ) ;
115+ process . exit ( 1 ) ;
116+ }
117+ }
118+
119+ // Run the demo
120+ if ( require . main === module ) {
121+ runDGMDemo ( ) ;
122+ }
123+
124+ export { runDGMDemo } ;
0 commit comments