/// <summary> /// Associates the input icon data structure to an icon which the networks belives in /// </summary> /// <param name="iconInputDataStructure">input icon</param> /// <returns>icon shich the network believes in</returns> public IconInputDataStructure Associate(IconInputDataStructure iconInputDataStructure) { var biPolarIcon = _binaryToBiPolarVecConvertor.ConvertBinaryVecToBiPolar(iconInputDataStructure.IconVector); var biPolarPhoneNumber = _phoneNumberToBiPolarConvertor.ConvertStringPhoneNumberToBiPolar(iconInputDataStructure.PhoneNumber); // convert the input arguments to biPolar and run associate _bamNeuralNetwork.Associate(biPolarIcon, biPolarPhoneNumber); var phoneNumber = _phoneNumberToBiPolarConvertor.ConvertBiPolarPhoneNumberToString(biPolarPhoneNumber); var icon = _binaryToBiPolarVecConvertor.ConvertBiPolarVecToBinary(biPolarIcon); return new IconInputDataStructure(icon, phoneNumber); }
/// <summary> /// /// </summary> /// <param name="errorPrecentage"></param> /// <returns></returns> public IconInputDataStructure CreateError(int errorPrecentage) { var errorIcon = new IconInputDataStructure(IconVector, PhoneNumber); var numOfPixelsToChange = (int) (RepresentationVectorSize*((double) errorPrecentage/100)); var rand = new Random(DateTime.Now.Millisecond); for (var i = 0; i < numOfPixelsToChange; i++) { // Get a random index and change it's value var index = rand.Next(0, RepresentationVectorSize - 1); // Flip bit errorIcon.IconVector[index] = 1 - errorIcon.IconVector[index]; } return errorIcon; }