forked from UTulsa-Research/ag_gen
Edge Duplication Adjustment
This commit is contained in:
parent
c81c43035b
commit
831c80e74e
BIN
build/ag_gen
BIN
build/ag_gen
Binary file not shown.
3634
build/states.txt
3634
build/states.txt
File diff suppressed because it is too large
Load Diff
@ -1380,18 +1380,6 @@ int initQSize, double mem_threshold, mpi::communicator &world, int state_limit)
|
||||
requests[5] = world.isend(0, 2, 1);
|
||||
}
|
||||
|
||||
//Check for new fact and new state that caused an update in the hash table and facts
|
||||
while(world.iprobe(mpi::any_source, 5) || world.iprobe(mpi::any_source, 6)){
|
||||
NetworkState update_state;
|
||||
Quality update_fact;
|
||||
world.recv(mpi::any_source, 5, update_state);
|
||||
world.recv(mpi::any_source, 6, update_fact);
|
||||
|
||||
//Update
|
||||
instance.facts.hash_table[update_state.compound_assign(update_fact)]=instance.facts.size();
|
||||
instance.facts.length++;
|
||||
instance.facts.str_vector.push_back(update_state.compound_assign(update_fact));
|
||||
}
|
||||
mpi::wait_all(requests, requests+5);
|
||||
} //end worker nodes
|
||||
|
||||
@ -1458,20 +1446,6 @@ int initQSize, double mem_threshold, mpi::communicator &world, int state_limit)
|
||||
finish_count++;
|
||||
}
|
||||
}
|
||||
|
||||
//Check for new fact and new state that caused an update in the hash table and facts
|
||||
while(world.iprobe(mpi::any_source, 5) || world.iprobe(mpi::any_source, 6)){
|
||||
NetworkState update_state;
|
||||
Quality update_fact;
|
||||
|
||||
world.recv(mpi::any_source, 5, update_state);
|
||||
world.recv(mpi::any_source, 6, update_fact);
|
||||
|
||||
//Update
|
||||
instance.facts.hash_table[update_state.compound_assign(update_fact)]=instance.facts.size();
|
||||
instance.facts.length++;
|
||||
instance.facts.str_vector.push_back(update_state.compound_assign(update_fact));
|
||||
}
|
||||
}
|
||||
|
||||
//Check for Hash Table updates
|
||||
@ -1596,7 +1570,7 @@ int initQSize, double mem_threshold, mpi::communicator &world, int state_limit)
|
||||
}
|
||||
|
||||
if(proceed == 1){
|
||||
//Rest State back to ID 0
|
||||
//Reset State back to ID 0
|
||||
send_state.force_set_id(0);
|
||||
mpi::request state_req = world.isend(w, 1, send_state);
|
||||
state_req.wait();
|
||||
@ -1636,8 +1610,9 @@ int initQSize, double mem_threshold, mpi::communicator &world, int state_limit)
|
||||
gettimeofday(&t2,NULL);
|
||||
total_t+=(t2.tv_sec-t1.tv_sec)*1000.0+(t2.tv_usec-t1.tv_usec)/1000.0;
|
||||
printf("AG TOOK %lf ms.\n", total_t);
|
||||
std::cout << "Instance Edges before adjustment: " << instance.edges.size() << std::endl;
|
||||
edge_adjustment(instance, hash_map);
|
||||
|
||||
std::cout << "Instance Edges after adjustment: " << instance.edges.size() << std::endl;
|
||||
auto end = std::chrono::system_clock::now();
|
||||
|
||||
std::chrono::duration<double> elapsed_seconds = end - start;
|
||||
|
||||
@ -34,7 +34,7 @@ Edge::Edge()
|
||||
/**
|
||||
* @return The Edge ID
|
||||
*/
|
||||
int Edge::get_id() { return id; }
|
||||
int Edge::get_id() const { return id; }
|
||||
|
||||
void Edge::set_deleted() { deleted = true; }
|
||||
|
||||
@ -47,7 +47,7 @@ bool Edge::is_deleted() { return deleted; }
|
||||
|
||||
//}
|
||||
|
||||
unsigned long Edge::get_from_id()
|
||||
unsigned long Edge::get_from_id() const
|
||||
{
|
||||
return from_node;
|
||||
}
|
||||
@ -59,12 +59,12 @@ unsigned long Edge::get_from_id()
|
||||
|
||||
//}
|
||||
|
||||
unsigned long Edge::get_to_id()
|
||||
unsigned long Edge::get_to_id() const
|
||||
{
|
||||
return to_node;
|
||||
}
|
||||
|
||||
int Edge::get_exploit_id()
|
||||
int Edge::get_exploit_id() const
|
||||
{
|
||||
|
||||
return exploit.get_id();
|
||||
@ -117,8 +117,7 @@ std::string Edge::get_asset_query() {
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
bool Edge::comparator(Edge& ed2)
|
||||
bool Edge::operator==(const Edge& ed2)
|
||||
{
|
||||
if(get_to_id() == ed2.get_to_id() &&
|
||||
get_from_id() == ed2.get_from_id() &&
|
||||
|
||||
@ -50,18 +50,20 @@ class Edge {
|
||||
std::string get_query();
|
||||
std::string get_asset_query();
|
||||
|
||||
int get_id();
|
||||
int get_id() const;
|
||||
int set_id();
|
||||
//int get_from_id();
|
||||
//int get_to_id();
|
||||
unsigned long get_from_id();
|
||||
unsigned long get_to_id();
|
||||
unsigned long get_from_id() const;
|
||||
unsigned long get_to_id() const;
|
||||
void force_from_id(unsigned long i);
|
||||
void force_to_id(unsigned long i);
|
||||
int get_exploit_id();
|
||||
int get_exploit_id() const;
|
||||
void set_deleted();
|
||||
bool is_deleted();
|
||||
bool comparator(Edge& ed2);
|
||||
bool operator==(const Edge& ed2);
|
||||
|
||||
};
|
||||
|
||||
#endif // AG_GEN_EDGE_H
|
||||
|
||||
@ -525,7 +525,7 @@ void state_merge(std::vector<Factbase> &node_factbases, std::vector<Edge> &node_
|
||||
fb.set_id();
|
||||
|
||||
instance.factbases.push_back(fb);
|
||||
hash_map.insert(std::make_pair(fb.hash(instance.facts), fb.get_id()));
|
||||
hash_map.insert(std::make_pair(hash_num, fb.get_id()));
|
||||
|
||||
//See memory usage. If it exceeds the threshold, store new states in the DB
|
||||
double i_alpha = 0.0;
|
||||
@ -577,5 +577,7 @@ void edge_adjustment(AGGenInstance &instance, std::unordered_map<size_t, int> &h
|
||||
}
|
||||
|
||||
//Remove duplicates
|
||||
instance.edges.erase(unique(instance.edges.begin(), instance.edges.end(), [](Edge& ed1, Edge& ed2){return ed1.comparator(ed2);}), instance.edges.end());
|
||||
//instance.edges.erase(unique(instance.edges.begin(), instance.edges.end(), [](Edge& ed1, Edge& ed2){return ed1.comparator(ed2);}), instance.edges.end());
|
||||
instance.edges.erase(unique(instance.edges.begin(), instance.edges.end()), instance.edges.end());
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user