Browse Source

Библиотека Combinatorics

master
parent
commit
4946f24dd9
  1. BIN
      .vs/comivoyar/v15/.suo
  2. BIN
      .vs/comivoyar/v15/Server/sqlite3/storage.ide
  3. BIN
      .vs/comivoyar/v15/Server/sqlite3/storage.ide-shm
  4. BIN
      .vs/comivoyar/v15/Server/sqlite3/storage.ide-wal
  5. 18
      comivoyar/App.config
  6. 116
      comivoyar/Program.cs
  7. BIN
      comivoyar/bin/Debug/comivoyar.exe
  8. 18
      comivoyar/bin/Debug/comivoyar.exe.config
  9. BIN
      comivoyar/bin/Debug/comivoyar.pdb
  10. 4
      comivoyar/bin/Debug/coord.txt
  11. 56
      comivoyar/comivoyar.csproj
  12. BIN
      comivoyar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
  13. 2
      comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache
  14. 20
      comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt
  15. BIN
      comivoyar/obj/Debug/comivoyar.csprojAssemblyReference.cache
  16. BIN
      comivoyar/obj/Debug/comivoyar.exe
  17. BIN
      comivoyar/obj/Debug/comivoyar.pdb
  18. 51
      comivoyar/packages.config

BIN
.vs/comivoyar/v15/.suo

Binary file not shown.

BIN
.vs/comivoyar/v15/Server/sqlite3/storage.ide

Binary file not shown.

BIN
.vs/comivoyar/v15/Server/sqlite3/storage.ide-shm

Binary file not shown.

BIN
.vs/comivoyar/v15/Server/sqlite3/storage.ide-wal

Binary file not shown.

18
comivoyar/App.config

@ -1,6 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.X509Certificates" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Win32.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

116
comivoyar/Program.cs

@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Diagnostics;
using Combinatorics.Collections;
using System.Collections.Generic;
using static System.Console;
namespace komvo
@ -44,21 +45,29 @@ namespace komvo
WriteLine();
}
string formP = string.Empty;
for (int i = 2; i <= Points.Count; i++) formP += i.ToString();
int[] toSwap = new int[Points.Count];
for (int i = 0; i < toSwap.Length; i++) toSwap[i] = i + 2;
for (int i = 0; i < toSwap.Length; i++) WriteLine(toSwap[i]);
int fct = Fact(Points.Count - 1);
WriteLine("\n{0} {1}\n\n\n", formP, fct);
int[] routes = new int[fct];
double[] leng = new double[fct];
int[] routes = new int[Fact(Points.Count)];
double[] leng = new double[Fact(Points.Count)];
int waves = fct / 6;
double optim = leng[0];
int oIndex = 0;
string inf = formP;
Swapper(0, inf, ref routes, waves);
Permutations<int> perm = new Permutations<int>(toSwap);
int index = 0;
foreach(IList<int> p in perm)
{
string res = string.Empty;
for (int i = 0; i < toSwap.Length; i++) res += p[i].ToString();
routes[index++] = int.Parse(res);
}
CountLen(ref leng, Matrix, routes);
SearchBest(ref optim, ref oIndex, routes, leng);
Debug(routes);
@ -71,28 +80,6 @@ namespace komvo
ReadKey();
}
public static string Swap(string value, int first, int second)
{
char[] res = value.ToCharArray();
res[first] = value[second];
res[second] = value[first];
value = new string(res);
return value;
}
public static string Swap(string value, int first, int second, int debug)
{
int d = debug;
char[] res = value.ToCharArray();
res[first] = value[second];
res[second] = value[first];
value = new string(res);
return value;
}
public static void CountLen (ref double[] result, double[,] mtr, int[] rts)
{
for (int i = 0; i < rts.Length; i++)
@ -101,74 +88,23 @@ namespace komvo
char[] ch = rts[i].ToString().ToCharArray();
for (int j = 0; j < ch.Length; j++)
{
int db = int.Parse(ch[j].ToString()) - 1; //debug
int db = int.Parse(ch[j].ToString()) - 2; //debug
string db1 = rts[i].ToString(); //debug
if (j == 0) res += mtr[0, int.Parse(ch[j].ToString()) - 1];
if (j == 0) res += mtr[0, int.Parse(ch[j].ToString()) - 2];
else if (j == ch.Length - 1)
{
res += mtr[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1];
res += mtr[0, int.Parse(ch[j].ToString()) - 1];
res += mtr[int.Parse(ch[j - 1].ToString()) - 2, int.Parse(ch[j].ToString()) - 2];
res += mtr[0, int.Parse(ch[j].ToString()) - 2];
}
else
{
res += mtr[int.Parse(ch[j - 1].ToString()) - 1, int.Parse(ch[j].ToString()) - 1];
res += mtr[int.Parse(ch[j - 1].ToString()) - 2, int.Parse(ch[j].ToString()) - 2];
}
}
result[i] = res;
}
}
public static void Swapper(int counter, string inf, ref int[] routes, int waves)
{
string formP = inf;
if (counter >= waves) WriteLine("\nEnd");
else
{
if (counter == 0)
{
Infinitives.Add(inf);
formP = Infinitives[0];
}
else if (counter % 4 == 0)
{
Infinitives.Add(Swap(inf, counter / 4 - 1, inf.Length - 1, counter));
formP = Infinitives[counter / 4];
}
else if (waves > 1)
{
formP = Swap(Infinitives[counter / 4], counter % 4 - 1, 3);
}
BlockOfSix(formP, ref routes, counter);
Swapper(counter + 1, inf, ref routes, waves);
}
}
public static void BlockOfSix(string formP, ref int[] routes, int start)
{
for (int j = 0; j < 6; j++)
{
if (j == 0)
{
routes[j + start * 6] = int.Parse(formP);
WriteLine(routes[j + start * 6]);
}
else if (j % 2 == 0)
{
routes[j + start * 6] = int.Parse(formP = Swap(formP, 0, j / 2));
WriteLine(routes[j + start * 6]);
}
else
{
routes[j + start * 6] = int.Parse(Swap(formP, 1, 2));
WriteLine(routes[j + start * 6]);
}
}
}
public static void SearchBest(ref double optim, ref int oIndex, int[] routes, double[] leng)
{
optim = leng[0];
@ -193,16 +129,12 @@ namespace komvo
}
}
public partial struct Point
{
public int X { get; set; }
public int Y { get; set; }
}
static int Fact(int a) => a <= 1 ? 1 : a * Fact(a - 1);
}
}

BIN
comivoyar/bin/Debug/comivoyar.exe

Binary file not shown.

18
comivoyar/bin/Debug/comivoyar.exe.config

@ -1,6 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Security.Cryptography.X509Certificates" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Win32.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

BIN
comivoyar/bin/Debug/comivoyar.pdb

Binary file not shown.

4
comivoyar/bin/Debug/coord.txt

@ -1,6 +1,4 @@
0 0
0 20
10 10
20 20
20 0
40 40
30 30

56
comivoyar/comivoyar.csproj

@ -32,13 +32,66 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Combinatorics, Version=1.1.0.19, Culture=neutral, PublicKeyToken=d5738f21cd5d2f66, processorArchitecture=MSIL">
<HintPath>..\packages\Combinatorics.1.1.0.19\lib\netstandard1.2\Combinatorics.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Win32.Primitives.4.0.1\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.AppContext.4.1.0\lib\net46\System.AppContext.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.0.0\lib\net46\System.Console.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Globalization.Calendars, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Globalization.Calendars.4.0.1\lib\net46\System.Globalization.Calendars.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.1.0\lib\net46\System.IO.Compression.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.ZipFile.4.0.1\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
</Reference>
<Reference Include="System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll</HintPath>
</Reference>
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.1.0\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Sockets, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Sockets.4.1.0\lib\net46\System.Net.Sockets.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.0.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.0.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.1.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
@ -47,6 +100,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

BIN
comivoyar/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache

Binary file not shown.

2
comivoyar/obj/Debug/comivoyar.csproj.CoreCompileInputs.cache

@ -1 +1 @@
6eed873852f8ce9c50ebe974dac1f20cc4ef270e
47ece507326a3ff73baa3b75434a7d03f71dc86d

20
comivoyar/obj/Debug/comivoyar.csproj.FileListAbsolute.txt

@ -12,3 +12,23 @@ D:\Git\comvo\comivoyar\obj\Debug\comivoyar.csprojAssemblyReference.cache
D:\Git\comvo\comivoyar\obj\Debug\comivoyar.csproj.CoreCompileInputs.cache
D:\Git\comvo\comivoyar\obj\Debug\comivoyar.exe
D:\Git\comvo\comivoyar\obj\Debug\comivoyar.pdb
E:\кк\прог\comivoyar\comivoyar\bin\Debug\Combinatorics.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\Microsoft.Win32.Primitives.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.AppContext.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Console.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Diagnostics.DiagnosticSource.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Globalization.Calendars.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.IO.Compression.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.IO.Compression.ZipFile.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.IO.FileSystem.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.IO.FileSystem.Primitives.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Net.Http.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Net.Sockets.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Runtime.InteropServices.RuntimeInformation.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Security.Cryptography.Algorithms.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Security.Cryptography.Encoding.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Security.Cryptography.Primitives.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Security.Cryptography.X509Certificates.dll
E:\кк\прог\comivoyar\comivoyar\bin\Debug\Combinatorics.xml
E:\кк\прог\comivoyar\comivoyar\bin\Debug\System.Diagnostics.DiagnosticSource.xml
E:\кк\прог\comivoyar\comivoyar\obj\Debug\comivoyar.csproj.CopyComplete

BIN
comivoyar/obj/Debug/comivoyar.csprojAssemblyReference.cache

Binary file not shown.

BIN
comivoyar/obj/Debug/comivoyar.exe

Binary file not shown.

BIN
comivoyar/obj/Debug/comivoyar.pdb

Binary file not shown.

51
comivoyar/packages.config

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Combinatorics" version="1.1.0.19" targetFramework="net461" />
<package id="Microsoft.NETCore.Platforms" version="1.0.1" targetFramework="net461" />
<package id="Microsoft.NETCore.Portable.Compatibility" version="1.0.1" targetFramework="net461" />
<package id="Microsoft.Win32.Primitives" version="4.0.1" targetFramework="net461" />
<package id="NETStandard.Library" version="1.6.0" targetFramework="net461" />
<package id="System.AppContext" version="4.1.0" targetFramework="net461" />
<package id="System.Collections" version="4.0.11" targetFramework="net461" />
<package id="System.Collections.Concurrent" version="4.0.12" targetFramework="net461" />
<package id="System.Console" version="4.0.0" targetFramework="net461" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net461" />
<package id="System.Diagnostics.DiagnosticSource" version="4.0.0" targetFramework="net461" />
<package id="System.Diagnostics.Tools" version="4.0.1" targetFramework="net461" />
<package id="System.Diagnostics.Tracing" version="4.1.0" targetFramework="net461" />
<package id="System.Globalization" version="4.0.11" targetFramework="net461" />
<package id="System.Globalization.Calendars" version="4.0.1" targetFramework="net461" />
<package id="System.IO" version="4.1.0" targetFramework="net461" />
<package id="System.IO.Compression" version="4.1.0" targetFramework="net461" />
<package id="System.IO.Compression.ZipFile" version="4.0.1" targetFramework="net461" />
<package id="System.IO.FileSystem" version="4.0.1" targetFramework="net461" />
<package id="System.IO.FileSystem.Primitives" version="4.0.1" targetFramework="net461" />
<package id="System.Linq" version="4.1.0" targetFramework="net461" />
<package id="System.Linq.Expressions" version="4.1.0" targetFramework="net461" />
<package id="System.Net.Http" version="4.1.0" targetFramework="net461" />
<package id="System.Net.Primitives" version="4.0.11" targetFramework="net461" />
<package id="System.Net.Sockets" version="4.1.0" targetFramework="net461" />
<package id="System.ObjectModel" version="4.0.12" targetFramework="net461" />
<package id="System.Reflection" version="4.1.0" targetFramework="net461" />
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="net461" />
<package id="System.Reflection.Primitives" version="4.0.1" targetFramework="net461" />
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net461" />
<package id="System.Runtime" version="4.1.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net461" />
<package id="System.Runtime.Handles" version="4.0.1" targetFramework="net461" />
<package id="System.Runtime.InteropServices" version="4.1.0" targetFramework="net461" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="net461" />
<package id="System.Runtime.Numerics" version="4.0.1" targetFramework="net461" />
<package id="System.Security.Cryptography.Algorithms" version="4.2.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Encoding" version="4.0.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Primitives" version="4.0.0" targetFramework="net461" />
<package id="System.Security.Cryptography.X509Certificates" version="4.1.0" targetFramework="net461" />
<package id="System.Text.Encoding" version="4.0.11" targetFramework="net461" />
<package id="System.Text.Encoding.Extensions" version="4.0.11" targetFramework="net461" />
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="net461" />
<package id="System.Threading" version="4.0.11" targetFramework="net461" />
<package id="System.Threading.Tasks" version="4.0.11" targetFramework="net461" />
<package id="System.Threading.Timer" version="4.0.1" targetFramework="net461" />
<package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="net461" />
<package id="System.Xml.XDocument" version="4.0.11" targetFramework="net461" />
</packages>
Loading…
Cancel
Save