Пример #1
0
        public static TyresSet CreateTyresSet([NotNull] this TyresMachine machine, [NotNull] TyresEntry frontOriginal, [NotNull] TyresEntry rearOriginal,
                                              [CanBeNull] string name, [CanBeNull] string shortName)
        {
            var front = CreateTyresEntry(machine, frontOriginal, name, shortName);
            var rear  = CreateTyresEntry(machine, rearOriginal, name, shortName);

            return(new TyresSet(front, rear));
        }
Пример #2
0
        public static TyresSet CreateTyresSet([NotNull] this TyresMachine machine, [NotNull] CarObject car,
                                              [CanBeNull] string name, [CanBeNull] string shortName)
        {
            var original = car.GetOriginalTyresSet() ?? car.GetTyresSets().First();
            var front    = machine.CreateTyresEntry(original.Front, name, shortName);
            var rear     = machine.CreateTyresEntry(original.Rear, name, shortName);

            return(new TyresSet(front, rear));
        }
Пример #3
0
 private static TyresMachineInfo CreateTyresMachineInfo(FilesStorage.ContentEntry x)
 {
     return(new TyresMachineInfo(Path.GetFileNameWithoutExtension(x.Filename), TyresMachine.LoadFrom(x.Filename, null))
     {
         _filename = x.Filename,
         _lastWriteTime = x.LastWriteTime
     });
 }
Пример #4
0
 public TyresMachineInfo(string displayName, TyresMachine machine)
 {
     _machine    = machine;
     DisplayName = displayName;
     Description = _machine.Sources.Select(x => x.CarId + "/" + x.Name).JoinToReadableString();
 }
Пример #5
0
        public void Main()
        {
            var carsFromWebApp = new[] {
                /*"lotus_exige_s", "lotus_exige_s", "lotus_evora_gte", "lotus_elise_sc", "alfa_mito_qv",
                 * "abarth500", "lotus_elise_sc", "alfa_romeo_giulietta_qv", "bmw_m3_e30", "audi_sport_quattro",
                 * "audi_a1s1", "nissan_skyline_r34", "ford_mustang_2015", "bmw_1m", "bmw_m4", "bmw_m4",
                 * "porsche_991_carrera_s", "porsche_718_boxster_s", "porsche_718_boxster_s", "corvette_c7_stingray",
                 * "porsche_991_carrera_s"*/

                "ks_abarth_595ss_s2", "ks_audi_r8_plus"
            };

            var tyres = Directory.GetDirectories(@"D:\Games\Assetto Corsa\content\cars", "*")
                        .Where(x => carsFromWebApp.ArrayContains(Path.GetFileName(x)))
                        .Select(DataWrapper.FromCarDirectory).SelectMany(NeuralTyresEntry.Get)
                        .Where(x => x.Version == 10).ToList();
            var filteredTyres = tyres.Where(x => x.Name == "Street").ToList();
            // filteredTyres.OrderBy(x => x.Values.GetDouble("RADIUS", 0d)).Select(x => $"{x.Values.GetDouble("RADIUS", 0d)}={x.Values.GetDouble(TestKey, 0d)}").JoinToString("; ").Dump();

            var options = new NeuralTyresOptions {
                OverrideOutputKeys = new[] { "ANGULAR_INERTIA" }
            };
            var checksum      = (filteredTyres.GetEnumerableHashCode() * 397) ^ options.GetHashCode();
            var cacheFilename = Path.Combine("U:\\nt-cache", BitConverter.GetBytes(checksum).ToHexString().ToLowerInvariant() + ".zip");

            Console.WriteLine(checksum);

            TyresMachine neural;

            if (File.Exists(cacheFilename))
            {
                neural = TyresMachine.LoadFrom(cacheFilename, null);
            }
            else
            {
                neural = TyresMachine.CreateAsync(filteredTyres, options).Result;
                FileUtils.EnsureFileDirectoryExists(cacheFilename);
                // neural?.Save(cacheFilename, null);
            }

            if (neural == null)
            {
                return;
            }
            var width   = neural.GetNormalization(NeuralTyresOptions.InputWidth);
            var radius  = neural.GetNormalization(NeuralTyresOptions.InputRadius);
            var profile = neural.GetNormalization(NeuralTyresOptions.InputProfile);

            var testKey = "ANGULAR_INERTIA";

            try {
                BuildChart(Enumerable.Range(0, 7).Select(x => {
                    return((Action <Series>)(s => {
                        for (var i = 0d; i <= 1d; i += 0.01)
                        {
                            var w = width.Denormalize(x / 6d);
                            var r = radius.Denormalize(i);
                            var u = profile.Denormalize(i);
                            s.Points.Add(new DataPoint(r, neural.Conjure(w, r, u)[testKey]));
                            // s.Points.Add(new DataPoint(r, neural.Conjure(testKey, w, r, u)));
                        }

                        s.Color = new[] { Color.Red, Color.Orange, Color.Brown, Color.Lime, Color.Cyan, Color.Blue, Color.Magenta }[x];
                    }));
                }).ToArray());
            } catch (Exception e) {
                Console.WriteLine(e);
            }

            Console.WriteLine(neural.Conjure(width.Denormalize(0.5), radius.Denormalize(0.5), profile.Denormalize(0.5))[testKey]);
        }
Пример #6
0
 public static TyresEntry CreateTyresEntry([NotNull] this TyresMachine machine, [NotNull] TyresEntry original,
                                           [CanBeNull] string name, [CanBeNull] string shortName)
 {
     return(machine.Conjure(original.Width, original.Radius, original.Radius - original.RimRadius)
            .ToTyresEntry(original, name, shortName));
 }
Пример #7
0
 public static TyresEntry CreateTyresEntry([NotNull] this TyresMachine machine, double width, double radius, double profile,
                                           [CanBeNull] string name, [CanBeNull] string shortName)
 {
     return(machine.Conjure(width, radius, profile).ToTyresEntry(null, name, shortName));
 }