@@ -3,7 +3,7 @@ const fs = require('fs');
33const path = require ( 'path' ) ;
44const router = express . Router ( ) ;
55
6- const { getConfigs, getRunConfigs, saveConfig, getAllResults, resetRunConfigs, saveAlgorithms, getAllAlgorithms } = require ( '../utils/fileHandlers' ) ;
6+ const { getConfigs, getRunConfigs, saveConfig, getAllResults, resetRunConfigs, saveAlgorithms, getAllAlgorithms, getFitnessData } = require ( '../utils/fileHandlers' ) ;
77const { runPythonScript } = require ( '../utils/pythonRunner' ) ;
88const { getResults } = require ( '../utils/resultProcessor' ) ;
99const { runExperiments } = require ( '../utils/runExperiments' ) ;
@@ -50,14 +50,6 @@ router.post('/config', asyncHandler(async (req, res) => {
5050 } ) ;
5151} ) ) ;
5252
53- // Run Python script
54- router . post ( '/run-python' , asyncHandler ( async ( req , res ) => {
55- const result = await runPythonScript ( req . body ) ;
56- res . json ( {
57- success : true ,
58- data : result
59- } ) ;
60- } ) ) ;
6153
6254// Get results
6355router . get ( '/results' , asyncHandler ( async ( req , res ) => {
@@ -106,40 +98,7 @@ router.post('/run-algorithms', asyncHandler(async (req, res) => {
10698
10799// Get fitness data for all algorithms from txt files in lca or algorithms folders
108100router . get ( '/fitness/all' , asyncHandler ( async ( req , res ) => {
109- const folders = [ 'lca' , 'algorithms' ] ;
110- const data = { } ;
111-
112- for ( const folder of folders ) {
113- const folderPath = path . join ( process . env . MAIN_DIR , folder ) ;
114-
115- // Check if folder exists
116- if ( ! fs . existsSync ( folderPath ) ) {
117- continue ;
118- }
119-
120- // Get all txt files in the folder
121- const files = fs . readdirSync ( folderPath ) . filter ( file => file . endsWith ( '.txt' ) ) ;
122-
123- for ( const file of files ) {
124- const algoName = path . basename ( file , '.txt' ) ;
125- const filePath = path . join ( folderPath , file ) ;
126-
127- try {
128- const fileContent = fs . readFileSync ( filePath , 'utf8' ) ;
129- data [ algoName ] = fileContent . trim ( ) . split ( '\n' ) . map ( line => {
130- const match = line . match ( / t \s * = ( \d + ) , \s * f _ b e s t = ( \d + \. ? \d * ) / ) ;
131- if ( match ) {
132- const [ , t , f ] = match ;
133- return { t : Number ( t ) , fitness : Number ( f ) } ;
134- }
135- return null ;
136- } ) . filter ( Boolean ) ;
137- } catch ( error ) {
138- console . error ( `Error reading file ${ filePath } :` , error ) ;
139- data [ algoName ] = [ ] ;
140- }
141- }
142- }
101+ data = getFitnessData ( ) ;
143102
144103 res . json ( {
145104 data
0 commit comments