-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunning.cpp
More file actions
48 lines (40 loc) · 1.61 KB
/
Copy pathRunning.cpp
File metadata and controls
48 lines (40 loc) · 1.61 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
//
// Created by Tomnof on 11/21/2017.
//
#include "Running.h"
map<int, TreeVector> createTrainingData(vector<Graph> graphs, int numberOfTDs = 40){
// for each graph, create the TD's. and its features + solver's running time if needed
map<int, TreeVector> trainingData;
int treeIndex=0;
for(auto g : graphs){
vector<TreeVector> trees = createTreeVectorsPerGraph(g, true, numberOfTDs);
for(auto tree : trees){
trainingData[treeIndex] = tree;
treeIndex++;
}
}
return trainingData;
}
vector<TreeVector> createTreeVectorsPerGraph(Graph g, bool isTraining = true, int numberOfTDs = 40)
{
// building numberOfTDs decomposition trees for the given graph
vector<TreeDecomposition> tds = generateTDsPerGraph(g, numberOfTDs);
// extract features for each tree
vector<TreeVector> tdsRepresentation(numberOfTDs);
for(int i=0; i<numberOfTDs; i++){
tdsRepresentation[i].features = extractTDFeatures(&tds[i]);
// if we're on training mode - calculate the real rank of the tree by running the solver.
if (isTraining){
tdsRepresentation[i].runningTime = calculateTDRuntime(&tds[i], 20);
}else{
tdsRepresentation[i].runningTime = 0;
}
}
// TODO: after we have all the Trees features, we have to normalize it to reduce dependencies between Tree-Graph
return tdsRepresentation;
}
// the function will recieve traingingData, and will learn what is the best weighted vector
// input: traingingData
// output: weitghted vector
vector<double> getWeightVectorML(map<int, TreeVector> traingingData){
}