Commit 914b19fa authored by danfis's avatar danfis

mutex_pair: Functions for adding mutex pairs from mutex groups.

parent b5a3eae7
......@@ -22,6 +22,7 @@
#include <stdio.h>
#include <boruvka/iset.h>
#include <plan/common.h>
#include <plan/mgroup.h>
#ifdef __cplusplus
extern "C" {
......@@ -121,6 +122,19 @@ void planMutexPairsRemapFacts(plan_mutex_pairs_t *m,
*/
void planMutexPairsReduce(plan_mutex_pairs_t *m, const struct plan_strips *s);
/**
* Add mutex pairs from the given mutex group.
*/
void planMutexPairsAddMGroup(plan_mutex_pairs_t *mutex,
const plan_mgroup_t *mg);
/**
* Add mutex pairs from all the given mutex groups.
*/
void planMutexPairsAddMGroups(plan_mutex_pairs_t *mutex,
const plan_mgroups_t *mgs);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
......
......@@ -160,3 +160,26 @@ void planMutexPairsReduce(plan_mutex_pairs_t *m, const plan_strips_t *s)
planMutexPairsFree(&b);
}
void planMutexPairsAddMGroup(plan_mutex_pairs_t *mutex,
const plan_mgroup_t *mg)
{
const bor_iset_t *facts = &mg->fact;
int size = borISetSize(facts);
for (int i = 0; i < size; ++i){
for (int j = i + 1; j < size; ++j){
planMutexPairsAdd(mutex, borISetGet(facts, i),
borISetGet(facts, j));
}
}
}
void planMutexPairsAddMGroups(plan_mutex_pairs_t *mutex,
const plan_mgroups_t *mgs)
{
for (int mgi = 0; mgi < mgs->mgroup_size; ++mgi){
const plan_mgroup_t *mg = mgs->mgroup + mgi;
planMutexPairsAddMGroup(mutex, mg);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment