internal static double[] FindEmptyDirection(int numberOfDimensions, VectorSectorIndexCalculator vsic, List <float[]> unitVectorsFromLocalPeerToNeighbors) // solves a linear inequation { foreach (var directionVector in vsic.EnumerateDirections()) { // are all vectors along directionVector? bool neighbor_along_directionVector_exists = false; foreach (var unitVectorFromLocalPeerToNeighbor in unitVectorsFromLocalPeerToNeighbors) { double multProduct = 0; for (int dimensionI = 0; dimensionI < numberOfDimensions; dimensionI++) { multProduct += unitVectorFromLocalPeerToNeighbor[dimensionI] * directionVector[dimensionI]; } if (multProduct > 0) { neighbor_along_directionVector_exists = true; break; } } if (neighbor_along_directionVector_exists == false) { return(directionVector); } } return(null); }
async Task TestDirections(DateTime timeNowUtc) { if (ConnectedNeighborsCanBeUsedForNewRequests.Count() >= _configuration.MinDesiredNumberOfNeighbors) { // enough neighbors if (_latestEmptyDirectionsTestTimeUtc == null || timeNowUtc > _latestEmptyDirectionsTestTimeUtc.Value.AddSeconds(_configuration.TestDirectionsMinIntervalS)) { _latestEmptyDirectionsTestTimeUtc = timeNowUtc; var logger = new Logger(Engine, this, null, DrpPeerEngine.VisionChannelModuleName_p2p); var numberOfDimensions = Engine.Configuration.SandboxModeOnly_NumberOfDimensions; var vsic = new VectorSectorIndexCalculator(numberOfDimensions); foreach (var directionVector in vsic.EnumerateDirections()) { await TestDirection(logger, directionVector); } } } }