Skip to content

Commit

Permalink
Put a cap on the number of parallel tasks. Currently hardcoded to 25.
Browse files Browse the repository at this point in the history
TODO: Make it configurable.
  • Loading branch information
smbadiwe committed Aug 3, 2016
1 parent 42ff7d6 commit 2fdab58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions MODA.Impl/ModaAlgorithms.2.Modified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private List<Mapping> Algorithm2_Modified(UndirectedGraph<string, Edge<string>>
var h_ = queryGraph.Vertices.First(); // var queryGraphVertices = queryGraph.Vertices.ToList();
var degSeq = inputGraph.GetDegreeSequence();
var tasks = new List<Task>();
List<string>[] chunks = new List<string>[numberOfSamples < 20 ? 1 : numberOfSamples / 20];
List<string>[] chunks = new List<string>[numberOfSamples < 20 ? 1 : Math.Min(numberOfSamples / 20, 25)];
for (int i = 0; i < chunks.Length; i++)
{
chunks[i] = new List<string>();
Expand Down Expand Up @@ -284,6 +284,7 @@ private bool IsNeighbourIncompatible(UndirectedGraph<string, Edge<string>> input
// return false;
// }
//}

neighborsOfM = null;
neighboursOfN = null;
return false;
Expand Down Expand Up @@ -325,15 +326,15 @@ private HashSet<string> ChooseNeighboursOfRange(string[] used_range, UndirectedG
try
{
local.Remove(local[j - counter]);
if (local.Count == 0)
{
break;
}
counter++;
}
catch (Exception ex)
{
throw new ArgumentOutOfRangeException(string.Format("ERROR in 'ChooseNeighboursOfRange' trying to remove from local:\n\t in Index (j - counter) = {0}; j = {1}; counter = {2}; local.Count = {3}.", (j - counter), j, counter, local.Count), ex);
//throw new ArgumentOutOfRangeException(string.Format("ERROR in 'ChooseNeighboursOfRange' trying to remove from local:\n\t in Index (j - counter) = {0}; j = {1}; counter = {2}; local.Count = {3}.", (j - counter), j, counter, local.Count), ex);
}
if (local.Count == 0)
{
break;
}
}
}
Expand Down Expand Up @@ -401,15 +402,15 @@ private string GetMostConstrainedNeighbour(string[] domain, UndirectedGraph<stri
try
{
local.Remove(local[j - counter]);
if (local.Count == 0)
{
break;
}
counter++;
}
catch (Exception ex)
{
throw new ArgumentOutOfRangeException(string.Format("ERROR in 'GetMostConstrainedNeighbour' trying to remove from local:\n\t in Index (j - counter) = {0}; j = {1}; counter = {2}; local.Count = {3}.", (j - counter), j, counter, local.Count), ex);
//throw new ArgumentOutOfRangeException(string.Format("ERROR in 'GetMostConstrainedNeighbour' trying to remove from local:\n\t in Index (j - counter) = {0}; j = {1}; counter = {2}; local.Count = {3}.", (j - counter), j, counter, local.Count), ex);
}
if (local.Count == 0)
{
break;
}
}
}
Expand Down Expand Up @@ -451,7 +452,7 @@ private bool CanSupport(UndirectedGraph<string, Edge<string>> queryGraph, string

//So, deg(g) >= deg(h).
//2. Based on the degree of their neighbors
var gNeighbors = inputGraph.GetNeighbors(node_G);
var gNeighbors = inputGraph.GetNeighbors(node_G);
var hNeighbors = queryGraph.GetNeighbors(node_H);
for (int i = 0; i < hNeighbors.Count; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion MODA.Impl/ModaAlgorithms.3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private List<Mapping> Algorithm3(UndirectedGraph<string, Edge<string>> queryGrap
var theMappings = new List<Mapping>();

var tasks = new List<Task>();
List<Mapping>[] chunks = new List<Mapping>[mappings.Count < 40 ? 1 : mappings.Count / 40];
List<Mapping>[] chunks = new List<Mapping>[mappings.Count < 40 ? 1 : Math.Min(mappings.Count / 40, 25)];
for (int i = 0; i < chunks.Length; i++)
{
chunks[i] = new List<Mapping>();
Expand Down

0 comments on commit 2fdab58

Please sign in to comment.