private void AddRecodeForEOS(PairInfo p) { if (Math.Abs(p.amount) >= 2500) { this.SetListView(p, "eosusd"); } }
IEnumerator PairRoutine(string side) { while (true) { yield return(new WaitForSeconds(pairTryRate)); WWW www = new WWW(url + "Pair.php?id=" + id + "&roundID=" + roundID + "&side=" + side); yield return(www); if (www.text != "NO") { PairInfo pair = JsonUtility.FromJson <PairInfo>(www.text); roundID = pair.id; if (pair.attackerID > 0 && pair.defenderID > 0) { if (pair.attackerID == id) { enemyID = pair.defenderID; isAttacker = true; } else { enemyID = pair.attackerID; isAttacker = false; } SceneManager.LoadScene(gameSceneName); break; } } } }
private void AddRecodeForBCH(PairInfo p) { if (Math.Abs(p.amount) >= 150) { this.SetListView(p, "bchusd"); } }
private void AddRecodeForBTC(PairInfo p) { if (Math.Abs(p.amount) >= 20) { this.SetListView(p, "btcusd"); } }
double ComputeScore() { const int minSupportingEdges = 1; const double distanceErrorFlatness = 0.69; const double angleErrorFlatness = 0.27; const double pairCountFactor = 0.032; const double pairFractionFactor = 8.98; const double correctTypeFactor = 0.629; const double supportedCountFactor = 0.193; const double edgeCountFactor = 0.265; const double distanceAccuracyFactor = 9.9; const double angleAccuracyFactor = 2.79; double score = pairCountFactor * PairCount; score += pairFractionFactor * (PairCount / (double)Template.Minutiae.Count + PairCount / (double)Candidate.Minutiae.Count) / 2; for (int i = 0; i < PairCount; ++i) { PairInfo pair = PairList[i]; if (pair.SupportingEdges >= minSupportingEdges) { score += supportedCountFactor; } score += edgeCountFactor * (pair.SupportingEdges + 1); if (Template.Minutiae[pair.Pair.Probe].Type == Candidate.Minutiae[pair.Pair.Candidate].Type) { score += correctTypeFactor; } } var innerDistanceRadius = Convert.ToInt32(distanceErrorFlatness * FingerprintMatcher.MaxDistanceError); var innerAngleRadius = Convert.ToInt32(angleErrorFlatness * FingerprintMatcher.MaxAngleError); var distanceErrorSum = 0; var angleErrorSum = 0; for (int i = 1; i < PairCount; ++i) { PairInfo pair = PairList[i]; var probeEdge = new EdgeShape(Template, pair.Reference.Probe, pair.Pair.Probe); var candidateEdge = new EdgeShape(Candidate, pair.Reference.Candidate, pair.Pair.Candidate); distanceErrorSum += Math.Abs(probeEdge.Length - candidateEdge.Length); angleErrorSum += Math.Max(innerDistanceRadius, Angle.Distance(probeEdge.ReferenceAngle, candidateEdge.ReferenceAngle)); angleErrorSum += Math.Max(innerAngleRadius, Angle.Distance(probeEdge.NeighborAngle, candidateEdge.NeighborAngle)); } if (PairCount >= 2) { var maxDistanceError = FingerprintMatcher.MaxDistanceError * (PairCount - 1); score += distanceAccuracyFactor * (maxDistanceError - distanceErrorSum) / maxDistanceError; var maxAngleError = FingerprintMatcher.MaxAngleError * (PairCount - 1) * 2; score += angleAccuracyFactor * (maxAngleError - angleErrorSum) / maxAngleError; } return(score); }
public FingerprintMatcher(FingerprintTemplate template) { Template = template; BuildEdgeHash(); PairsByProbe = new PairInfo[Template.Minutiae.Count]; PairList = new PairInfo[Template.Minutiae.Count]; for (int i = 0; i < PairList.Length; ++i) PairList[i] = new PairInfo(); }
public FingerprintMatcher(FingerprintTemplate template) { Template = template; BuildEdgeHash(); PairsByProbe = new PairInfo[Template.Minutiae.Count]; PairList = new PairInfo[Template.Minutiae.Count]; for (int i = 0; i < PairList.Length; ++i) { PairList[i] = new PairInfo(); } }
/// <summary> /// Get random pair of students for random plan, if no pair are possible with the ones already on db returns an empty list /// </summary> /// <param name="classroomId">Id of the classroom</param> /// <returns>List of array of 2 instances of StudentInfo</returns> private List <StudentInfo[]> GetRandomPair(int classroomId) { List <StudentInfo[]> studentPairList = new List <StudentInfo[]>(); List <PairInfo> alreadyDonePair = Database.Get.Pair.GetAllPairsFromClassroomId(classroomId); List <StudentInfo> allStudents = Database.Get.Student.AllFromClassroomId(classroomId); if (allStudents.Count % 2 != 0) { MessageBox.Show("Le nombre d'élèves est impair"); return(studentPairList); } int iterationWithoutSuccess = 0; while (allStudents.Count > 1) { Random random = new Random(); int randomIndex1 = random.Next(allStudents.Count); int randomIndex2 = random.Next(allStudents.Count); if (randomIndex1 == randomIndex2) { continue; } int studentId1 = allStudents[randomIndex1].studentId; int studentId2 = allStudents[randomIndex2].studentId; PairInfo isPairDone = alreadyDonePair.Find(x => (x.StudentId1 == studentId1 || x.StudentId1 == studentId2) && (x.StudentId2 == studentId1 || x.StudentId2 == studentId2)); if (isPairDone != null) { iterationWithoutSuccess++; continue; } iterationWithoutSuccess = 0; Database.Insert.Pair.One(studentId1, studentId2, classroomId); StudentInfo[] studentPair = new StudentInfo[] { allStudents[randomIndex1], allStudents[randomIndex2] }; studentPairList.Add(studentPair); allStudents.RemoveAt(randomIndex1); allStudents.RemoveAt(randomIndex2); if (iterationWithoutSuccess > 10) { Database.Remove.Pair.AllFromClassroomId(classroomId); return(new List <StudentInfo[]>()); } } return(studentPairList); }
void generateDrop() { List <PairInfo <float> > drops = enemyInfo.drop; var selectedDrop = Utils.randomList(drops); if (selectedDrop == null) { return; } List <PairInfo <int> > res = new List <PairInfo <int> >(); int randId; switch (selectedDrop) { case "seed": var unlockedSeeds = ResourceManager.Instance.unlockedSeed(); if (unlockedSeeds.Count == 0) { return; } randId = Random.Range(0, unlockedSeeds.Count); var pairInfo = new PairInfo <int>(unlockedSeeds[randId], 1); res = new List <PairInfo <int> >() { pairInfo }; break; case "resource": var dropableResource = ResourceManager.Instance.unlockedSeed(); if (dropableResource.Count == 0) { return; } randId = Random.Range(0, dropableResource.Count); var pairInfo2 = new PairInfo <int>(dropableResource[randId], 1); res = new List <PairInfo <int> >() { pairInfo2 }; break; } ClickToCollect.createClickToCollectItem(res, transform.position); }
public List <SymbolPairsInfo> GetListSymbols() { List <SymbolPairsInfo> result = new List <SymbolPairsInfo>(); GetInfoResponse info = yobitClient.Info(); foreach (var pair in info.pairs) { string pairName = pair.Key; PairInfo pairInfo = pair.Value; result.Add(new SymbolPairsInfo { Name = pairName, LimitNumberDecimalPlaces = pairInfo.decimal_places }); } return(result); }
private void SetListView(PairInfo p, string symbol) { if (!tokenSource.IsCancellationRequested) { if (this.tradeDitail.InvokeRequired) { SetListCallBack d = new SetListCallBack(SetListView); this.tradeDitail.Invoke(d, new object[] { p, symbol }); } else { var item = this.getTradeRec(p, symbol); this.tradeDitail.Items.Add(item); //让滑动条显示在最下面 tradeDitail.Items[tradeDitail.Items.Count - 1].EnsureVisible(); } } }
public void Analyze(MinutiaPairing pairing, EdgeLookup lookup, Template probe, Template candidate) { MaxDistanceError = lookup.MaxDistanceError; MaxAngleError = lookup.MaxAngleError; var innerDistanceRadius = Convert.ToInt32(DistanceErrorFlatness * MaxDistanceError); var innerAngleRadius = Convert.ToInt32(AngleErrorFlatness * MaxAngleError); PairCount = pairing.Count; EdgeCount = 0; SupportedCount = 0; CorrectTypeCount = 0; DistanceErrorSum = 0; AngleErrorSum = 0; for (int i = 0; i < PairCount; ++i) { PairInfo pair = pairing.GetPair(i); if (pair.SupportingEdges >= MinSupportingEdges) { ++SupportedCount; } EdgeCount += pair.SupportingEdges + 1; if (probe.Minutiae[pair.Pair.Probe].Type == candidate.Minutiae[pair.Pair.Candidate].Type) { ++CorrectTypeCount; } if (i > 0) { var probeEdge = EdgeConstructor.Construct(probe, pair.Reference.Probe, pair.Pair.Probe); var candidateEdge = EdgeConstructor.Construct(candidate, pair.Reference.Candidate, pair.Pair.Candidate); DistanceErrorSum += Math.Abs(probeEdge.Length - candidateEdge.Length); AngleErrorSum += Math.Max(innerDistanceRadius, Angle.Distance(probeEdge.ReferenceAngle, candidateEdge.ReferenceAngle)); AngleErrorSum += Math.Max(innerAngleRadius, Angle.Distance(probeEdge.NeighborAngle, candidateEdge.NeighborAngle)); } } float probeFraction = PairCount / (float)probe.Minutiae.Length; float candidateFraction = PairCount / (float)candidate.Minutiae.Length; PairFraction = (probeFraction + candidateFraction) / 2; }
public static List <PairInfo> GetAllPairsFromClassroomId(int classroomId) { using SQLiteCommand cmd = GlobalFunction.OpenDbConnection(); cmd.CommandText = "SELECT * FROM pairs WHERE classroomId = @classroomId"; cmd.Parameters.AddWithValue("classroomId", classroomId); List <PairInfo> pairs = new List <PairInfo>(); cmd.Prepare(); using SQLiteDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { PairInfo pair = new PairInfo() { PairId = rdr.GetInt32(0), StudentId1 = rdr.GetInt32(1), StudentId2 = rdr.GetInt32(2), ClassroomId = rdr.GetInt32(3) }; pairs.Add(pair); } return(pairs); }
//构造大单交易数据:时间、名称、方向、数量、价格 public ListViewItem getTradeRec(PairInfo pairinfo, string symbol) { ListViewItem lvi = new ListViewItem(); lvi.Text = pairinfo.timestamp.ToString(); lvi.SubItems.Add(symbol); string direction = ""; // if (pairinfo.amount > 0) { direction = "买入"; lvi.ForeColor = Color.Green; } else { direction = "卖出"; lvi.ForeColor = Color.Red; } lvi.SubItems.Add(direction); lvi.SubItems.Add(Math.Abs(pairinfo.amount).ToString()); lvi.SubItems.Add(pairinfo.price.ToString()); return(lvi); }
public void RunTests(Action <ObjectSignerBuilder> binarySerialiserBuilder, Action <ObjectSignerBuilder> signerBuilder, PairInfo validAndInvalidPair, int expectedSignaureLength) { MessagePackSerializer.SetDefaultResolver(MessagePack.Resolvers.ContractlessStandardResolver.Instance); var factory = new ObjectSignerFactory(); using (var objectSigner = factory.Build(cfg => { signerBuilder(cfg); binarySerialiserBuilder(cfg); })) { var signature = objectSigner.GenerateSignature(validAndInvalidPair.Valid()); signature.Length.Should().Be(expectedSignaureLength, "the signer should prduce consistently lengthed signatures"); objectSigner.Verify( validAndInvalidPair.Valid(), signature ).Should().BeTrue("the same object should produce the same signature"); objectSigner.Verify( validAndInvalidPair.Invalid(), signature ).Should().BeFalse("a different object should produce a different signature"); } }
public Lesson(PairInfo pi, DropInformation dropInfo, DropInformation dropInfoTwo) { pairInfo = new PairInfo(pi.Pair, pi.Day); this.dropInfo = dropInfo?.Copy(); this.dropInfoTwo = dropInfoTwo?.Copy(); }
public Lesson(PairInfo pairinfo, DropInformation dropInformation) : this(dropInformation) { pairInfo = pairinfo; }
public IEnumerable <DropItem> ReadClasses(Group[] groups, string nameofschedule) { if (Open()) { using (FbTransaction dbtran = conn.BeginTransaction()) { using (FbCommand selectCommand = new FbCommand()) { selectCommand.CommandText = "select Classes.id_teacher, fio, post, mail, id_departmentsteacher, d1.name_of_department, f1.id_faculty, f1.name_of_faculty," + //7 "id_subject, name_of_subject, subjects.id_department, d2.name_of_department, f2.id_faculty, f2.name_of_faculty," + //13 "id_classroom, number_of_classroom, classrooms.specific, classrooms.id_department, d3.name_of_department, f3.id_faculty, f3.name_of_faculty," + //20 "id_group, name_of_group, groups.id_department, d4.name_of_department, f4.id_faculty, f4.name_of_faculty," + //26 "specifics, NUMERATOR_DENOMINATOR, pair, daytime, keyy, typekey, isreadlecture" + //33 " from ((((Classes join teachers using (id_teacher) join departments d1 on d1.id_department = Classes.id_departmentsteacher join faculty f1 on d1.id_faculty = f1.id_faculty join teachersanddepartments on teachersanddepartments.id_department = d1.id_department and teachersanddepartments.id_teacher = Classes.id_teacher)" + "join subjects using (id_subject) join departments d2 on d2.id_department = subjects.id_department join faculty f2 on d2.id_faculty = f2.id_faculty)" + "join classrooms using (id_classroom) join departments d3 on d3.id_department = classrooms.id_department join faculty f3 on d3.id_faculty = f3.id_faculty)" + "join groups using (id_group) join departments d4 on d4.id_department = groups.id_department join faculty f4 on d4.id_faculty = f4.id_faculty) where nameofschedule = @nameofschedule"; selectCommand.Connection = conn; selectCommand.Transaction = dbtran; selectCommand.Parameters.AddWithValue("@nameofschedule", nameofschedule); FbDataReader reader = selectCommand.ExecuteReader(); while (reader.Read()) { PairInfo info = new PairInfo(reader.GetInt32(29), (DayOfWeek)Enum.Parse(typeof(DayOfWeek), reader.GetString(30))); var type = typeof(Group); var key = ReturnObjectFromCollections(reader.GetString(31), groups); if ((reader.GetInt32(28) == 0) || (reader.GetInt32(28) == 1)) { yield return(new DropItem(key, type, info) { Item = new DropInformation { Teacher = new Teacher { CodeOfTeacher = reader.GetInt32(0), FIO = reader.GetString(1), Post = reader.GetString(2), Mail = reader.GetString(3), IsReadLecture = Convert.ToBoolean(reader.GetInt32(33)), Department = new Department { CodeOfDepartment = reader.GetInt32(4), NameOfDepartment = reader.GetString(5), Faculty = new Faculty { CodeOfFaculty = reader.GetInt32(6), NameOfFaculty = reader.GetString(7) } } }, Subject = new Subject { CodeOfSubject = reader.GetInt32(8), NameOfSubject = reader.GetString(9), Department = new Department { CodeOfDepartment = reader.GetInt32(10), NameOfDepartment = reader.GetString(11), Faculty = new Faculty { CodeOfFaculty = reader.GetInt32(12), NameOfFaculty = reader.GetString(13) } } }, NumberOfClassroom = new ClassRoom { CodeOfClassroom = reader.GetInt32(14), NumberOfClassroom = reader.GetString(15), Specific = reader.GetString(16), Department = new Department { CodeOfDepartment = reader.GetInt32(17), NameOfDepartment = reader.GetString(18), Faculty = new Faculty { CodeOfFaculty = reader.GetInt32(19), NameOfFaculty = reader.GetString(20) } } }, Group = new List <Group> { { new Group { CodeOfGroup = reader.GetInt32(21), NameOfGroup = reader.GetString(22), Department = new Department { CodeOfDepartment = reader.GetInt32(23), NameOfDepartment = reader.GetString(24), Faculty = new Faculty { CodeOfFaculty = reader.GetInt32(25), NameOfFaculty = reader.GetString(26) } } } } }, Specifics = reader.GetString(27), Ndindex = reader.GetInt32(28) }, Info = info, State = reader.GetInt32(28) }); } else if (reader.GetInt32(28) == -1) { yield return(new DropItem(key, type, info) { ItemTwo = new DropInformation { Teacher = new Teacher { CodeOfTeacher = reader.GetInt32(0), FIO = reader.GetString(1), Post = reader.GetString(2), Mail = reader.GetString(3), IsReadLecture = Convert.ToBoolean(reader.GetInt32(33)), Department = new Department { CodeOfDepartment = reader.GetInt32(4), NameOfDepartment = reader.GetString(5), Faculty = new Faculty { CodeOfFaculty = reader.GetInt32(6), NameOfFaculty = reader.GetString(7) } } }, Subject = new Subject { CodeOfSubject = reader.GetInt32(8), NameOfSubject = reader.GetString(9), Department = new Department { CodeOfDepartment = reader.GetInt32(10), NameOfDepartment = reader.GetString(11), Faculty = new Faculty { CodeOfFaculty = reader.GetInt32(12), NameOfFaculty = reader.GetString(13) } } }, NumberOfClassroom = new ClassRoom { CodeOfClassroom = reader.GetInt32(14), NumberOfClassroom = reader.GetString(15), Specific = reader.GetString(16), Department = new Department { CodeOfDepartment = reader.GetInt32(17), NameOfDepartment = reader.GetString(18), Faculty = new Faculty { CodeOfFaculty = reader.GetInt32(19), NameOfFaculty = reader.GetString(20) } } }, Group = new List <Group> { { new Group { CodeOfGroup = reader.GetInt32(21), NameOfGroup = reader.GetString(22), Department = new Department { CodeOfDepartment = reader.GetInt32(23), NameOfDepartment = reader.GetString(24), Faculty = new Faculty { CodeOfFaculty = reader.GetInt32(25), NameOfFaculty = reader.GetString(26) } } } } }, Specifics = reader.GetString(27), Ndindex = reader.GetInt32(28) }, Info = info, State = reader.GetInt32(28) }); } } } dbtran.Commit(); } } }
private static object ParseString(string strValue, Type t) { if (t == typeof(bool)) { return(strValue.ToLower() == "true"); } else if (t == typeof(List <PairInfo <int> >)) { List <PairInfo <int> > res = new List <PairInfo <int> >(); if (strValue.Length == 0) { return(res); } var arr = strValue.Split('|'); foreach (var pair in arr) { var splitedPair = pair.Split(':'); if (splitedPair.Length == 2) { PairInfo <int> info = new PairInfo <int>(splitedPair[0], int.Parse(splitedPair[1])); res.Add(info); } else { Debug.LogError(pair + " can not be splited into two"); } } return(res); } else if (t == typeof(List <PairInfo <float> >)) { List <PairInfo <float> > res = new List <PairInfo <float> >(); if (strValue.Length == 0) { return(res); } var arr = strValue.Split('|'); foreach (var pair in arr) { var splitedPair = pair.Split(':'); if (splitedPair.Length == 2) { PairInfo <float> info = new PairInfo <float>(splitedPair[0], float.Parse(splitedPair[1])); res.Add(info); } else { Debug.LogError(pair + " can not be splited into two"); } } return(res); } else if (t.IsGenericType && (t.GetGenericTypeDefinition() == typeof(List <>))) { Type type = Utils.GetInnerListType(t); Type listType = typeof(List <>).MakeGenericType(new[] { type }); IList res = (IList)Activator.CreateInstance(listType); //List<T> res = new List<type>(); if (strValue.Length == 0) { return(res); } var arr = strValue.Split('|'); foreach (var value in arr) { var newCV = TypeDescriptor.GetConverter(type); try { var newValue = newCV.ConvertFromInvariantString(value); res.Add(newValue); } catch (Exception e) { return(null); } } return(res); } var cv = TypeDescriptor.GetConverter(t); try { return(cv.ConvertFromInvariantString(strValue)); }catch (Exception e) { return(null); } }