/
parser.php
77 lines (66 loc) · 1.74 KB
/
parser.php
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
<?php
session_start();
$db_csv='mapping/ParetoSolutions.csv';
$lines=file($db_csv);
//print_r($lines);exit;
$weight_of_object1 = 0.1;
$weight_of_object2 = 0.7;
$weight_of_object3 = 0.8;
$weight_of_object1 = 0.5;
$weight_of_object2 = 0.7;
$weight_of_object3 = 0.8;
$weight_of_object1 = $_SESSION['wt1'];
$weight_of_object2 = $_SESSION['wt2'];
$weight_of_object3 = $_SESSION['wt3'];
// Collect the values
foreach($lines as $line){
$line = chop($line);
$cells=explode(',', $line);
if($cells[0]=='myID')continue; // Skip the first row - headers
if($cells[0]=='ttime'){
for($sol=1;$sol<=30;$sol++){
$ttime[$sol] = $cells[$sol];
}
continue;
}
if($cells[0]=='bs'){
for($sol=1;$sol<=30;$sol++){
$bs[$sol] = $cells[$sol];
}
continue;
}
if($cells[0]=='pop'){
for($sol=1;$sol<=30;$sol++){
$pop[$sol] = $cells[$sol];
}
continue;
}
// These are the arc shade rows
// Collect the arc shades
$arcID=$cells[0];
for($sol=1;$sol<=30;$sol++){
//$arcColor[$sol][$arcID] = $cells[$sol]; // 1 or 0
if($cells[$sol]==1)$arcColor[$sol][$arcID] = $cells[$sol]; // 1 or 0
}
}
// Calculate the solutions
$bestRank=99999999;
$bestSol=0;
for($sol=1;$sol<=30;$sol++){
$rank[$sol]= ($ttime[$sol] * $weight_of_object1) + ($bs[$sol] * $weight_of_object2) + ($pop[$sol] * $weight_of_object3);
if($bestRank > $rank[$sol]) {
$bestRank = $rank[$sol];
$bestSol = $sol;
}
}
//print_r($ttime);
//print_r($bs);
//print_r($pop);
//print_r($arcColor[1]);
//print_r($rank);
// echo "weight_of_object1 = $weight_of_object1\n" ;
// echo "weight_of_object2 = $weight_of_object2\n" ;
// echo "weight_of_object3 = $weight_of_object3\n" ;
// echo "Best solution: $bestRank SolID: $bestSol\n";
// echo "Arcs to be highlighted\n";
// print_r($arcColor[$bestSol]);