Compare commits

...

2 Commits

  1. 18
      predprs/App.config
  2. 82
      predprs/Program.cs
  3. 51
      predprs/packages.config
  4. 74
      predprs/predprs.csproj

18
predprs/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>

82
predprs/Program.cs

@ -48,42 +48,96 @@ namespace predprs
Variations<int> variations = new Variations<int>(data2, 5);
//Permutations<int> variations = new Permutations<int>(data, GenerateOption.WithRepetition);
double result = 0, best = 0;
string bestStr = string.Empty;
Stopwatch sw = new Stopwatch();
sw.Start();
List<string> resus = new List<string>();
//List<string> resus = new List<string>();
List<Routes> bestResult = new List<Routes>();
bestResult.Add(new Routes { Inc = 0, Route = "" });
//Results str = new Results();
//str.Res = 0;
//str.BestSt = string.Empty;
foreach (IList<int> v in variations)
{
if (v[0] + v[1] + v[2] + v[3] + v[4] == 10)
{
result = matrix[v[0], 0] + matrix[v[1], 1] + matrix[v[2], 2] + matrix[v[3], 3] + matrix[v[4], 4];
if (result > best)
double result = matrix[v[0], 0] + matrix[v[1], 1] + matrix[v[2], 2] + matrix[v[3], 3] + matrix[v[4], 4];
//result.CompareTo(bestResult[0].Inc);
if (result > bestResult[0].Inc)
{
best = result;
// на всякий случай поля объекта делую нулевыми
//str.Res = 0;
//str.BestSt = string.Empty;
bestResult.Clear(); // отчистка листа при нахождении большего результата
//запись в поля объекта данных
//str.Res = result;
bestStr = string.Format("[{0} {1} {2} {3} {4}]", v[0], v[1], v[2], v[3], v[4]);
}
bestResult.Add(new Routes { Inc = result, Route = bestStr }); //добавление объекта в лист
//best = result;
//bestStr = string.Format("[{0} {1} {2} {3} {4}]", v[0], v[1], v[2], v[3], v[4]);
bool tr = false;
string r = string.Format("[{0} {1} {2} {3} {4}]", v[0], v[1], v[2], v[3], v[4]);
foreach (var vr in resus) if (r != vr) tr = true;
if (result == 5.4 && tr)
}
// если результаты совпали но строки отличаются (что-то тут странное происходит)
else if (result == bestResult[0].Inc)// && str.BestSt != string.Format("[{0} {1} {2} {3} {4}]", v[0], v[1], v[2], v[3], v[4]))
{
resus.Add(r);
tr = false;
// на всякий случай поля объекта делую нулевыми
//str.Res = 0;
//str.BestSt = string.Empty;
bool check = true;
string temp = string.Format("[{0} {1} {2} {3} {4}]", v[0], v[1], v[2], v[3], v[4]);
foreach (var vr in bestResult) if (temp == vr.Route) check = false;
if (check)
{
bestResult.Add(new Routes { Inc = result, Route = temp });
}
//запись в поля объекта данных
//str.Res = result;
//str.BestSt = string.Format("[{0} {1} {2} {3} {4}]", v[0], v[1], v[2], v[3], v[4]);
//bestResult.Add(str);//добавление объекта в лист
}
//if (result == 5.4 && tr)
//{
// resus.Add(r);
// tr = false;
//}
//WriteLine("[{0} {1} {2} {3} {4}] {5}", v[0], v[1], v[2], v[3], v[4], result);
//Thread.Sleep(100);
}
}
foreach (string s in resus) WriteLine(s);
//foreach (string s in resus) WriteLine(s);
sw.Stop();
WriteLine("Наибольшая прибыль при {0} со значением {1}\n{2} ms", bestStr, best, sw.ElapsedMilliseconds);
// вывод листа
WriteLine(bestResult.Count);
foreach (var route in bestResult)
{
WriteLine("Наибольшая прибыль при {0} со значением {1}", route.Inc, route.Route);
}
WriteLine("{0} ms", sw.ElapsedMilliseconds);
ReadKey();
}
class Routes
{
public double Inc { get; set; }
public string Route { get; set; }
}
}
}

51
predprs/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>

74
predprs/predprs.csproj

@ -33,16 +33,83 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Combinatorics">
<HintPath>..\..\..\vs\pacs\Combinatorics.1.1.0.19\lib\netstandard1.2\Combinatorics.dll</HintPath>
<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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
<Private>True</Private>
</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>
@ -51,6 +118,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Loading…
Cancel
Save