diff --git a/CSV/test_demand.csv b/CSV/test_demand.csv new file mode 100644 index 00000000..be372fd4 --- /dev/null +++ b/CSV/test_demand.csv @@ -0,0 +1,6 @@ +;Height ;Width +0;2,0;1,0 +1;2,0;2,0 +2;1,5;1,5 +3;1,0;1,5 +4;1,0;2,5 diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/.NETFramework,Version=v4.8.AssemblyAttributes.cs b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/.NETFramework,Version=v4.8.AssemblyAttributes.cs new file mode 100644 index 00000000..15efebfc --- /dev/null +++ b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/.NETFramework,Version=v4.8.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.AssemblyInfo.cs b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.AssemblyInfo.cs index 8fb8d6ee..aa9bd111 100644 --- a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.AssemblyInfo.cs +++ b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.AssemblyInfo.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -15,7 +14,7 @@ [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyDescriptionAttribute("Description of FirstPythonComponent")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0+ee82959b717ba2d1f8eb8d224c92e0a34d994b9c")] [assembly: System.Reflection.AssemblyProductAttribute("FirstPythonComponent")] [assembly: System.Reflection.AssemblyTitleAttribute("FirstPythonComponent")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.AssemblyInfoInputs.cache b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.AssemblyInfoInputs.cache index 981ae9a1..4baca82b 100644 --- a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.AssemblyInfoInputs.cache +++ b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.AssemblyInfoInputs.cache @@ -1 +1 @@ -5f18d4b15a818b2f413df39510d3990a80cdec30 +674c324a057b8b4ebf2cf4babef0f003ddee311105319425e88a53a044783464 diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.GeneratedMSBuildEditorConfig.editorconfig b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.GeneratedMSBuildEditorConfig.editorconfig index 19aa0dbc..a55e03c9 100644 --- a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.GeneratedMSBuildEditorConfig.editorconfig +++ b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.GeneratedMSBuildEditorConfig.editorconfig @@ -1,3 +1,5 @@ is_global = true build_property.RootNamespace = FirstPythonComponent -build_property.ProjectDir = C:\Users\sverremh\source\repos\FirstPythonComponent\FirstPythonComponent\ +build_property.ProjectDir = C:\Users\kollb\Master\Master-Thesis-NTNU\app\matchingTool\src\GrasshopperSolution\C#_Python_Component\FirstPythonComponent\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.assets.cache b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.assets.cache index 820f972c..5922b22b 100644 Binary files a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.assets.cache and b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.assets.cache differ diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.csproj.AssemblyReference.cache b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.csproj.AssemblyReference.cache index 4a80d4e9..96fc78de 100644 Binary files a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.csproj.AssemblyReference.cache and b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/Debug/net48/FirstPythonComponent.csproj.AssemblyReference.cache differ diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/FirstPythonComponent.csproj.nuget.dgspec.json b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/FirstPythonComponent.csproj.nuget.dgspec.json index d283381f..b13ddd09 100644 --- a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/FirstPythonComponent.csproj.nuget.dgspec.json +++ b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/FirstPythonComponent.csproj.nuget.dgspec.json @@ -1,20 +1,20 @@ { "format": 1, "restore": { - "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\FirstPythonComponent.csproj": {} + "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\FirstPythonComponent.csproj": {} }, "projects": { - "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\FirstPythonComponent.csproj": { + "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\FirstPythonComponent.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\FirstPythonComponent.csproj", + "projectUniqueName": "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\FirstPythonComponent.csproj", "projectName": "FirstPythonComponent", - "projectPath": "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\FirstPythonComponent.csproj", - "packagesPath": "C:\\Users\\sverremh\\.nuget\\packages\\", - "outputPath": "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\obj\\", + "projectPath": "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\FirstPythonComponent.csproj", + "packagesPath": "C:\\Users\\kollb\\.nuget\\packages\\", + "outputPath": "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\obj\\", "projectStyle": "PackageReference", "configFilePaths": [ - "C:\\Users\\sverremh\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Users\\kollb\\AppData\\Roaming\\NuGet\\NuGet.Config", "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" ], "originalTargetFrameworks": [ @@ -62,7 +62,7 @@ "version": "[5.0.0, )" } }, - "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.102\\RuntimeIdentifierGraph.json" + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.101\\RuntimeIdentifierGraph.json" } } } diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/FirstPythonComponent.csproj.nuget.g.props b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/FirstPythonComponent.csproj.nuget.g.props index 18b385de..03c1debf 100644 --- a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/FirstPythonComponent.csproj.nuget.g.props +++ b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/FirstPythonComponent.csproj.nuget.g.props @@ -5,11 +5,11 @@ NuGet $(MSBuildThisFileDirectory)project.assets.json $(UserProfile)\.nuget\packages\ - C:\Users\sverremh\.nuget\packages\ + C:\Users\kollb\.nuget\packages\ PackageReference - 6.0.1 + 6.8.0 - + \ No newline at end of file diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/project.assets.json b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/project.assets.json index 0c2f3996..4ce4d69a 100644 --- a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/project.assets.json +++ b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/project.assets.json @@ -8,11 +8,17 @@ "RhinoCommon": "[7.13.21348.13001]" }, "compile": { - "lib/net48/GH_IO.dll": {}, - "lib/net48/Grasshopper.dll": {} + "lib/net48/GH_IO.dll": { + "related": ".XML" + }, + "lib/net48/Grasshopper.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net48/_._": {} + "lib/net48/_._": { + "related": ".XML" + } }, "build": { "build/Grasshopper.targets": {} @@ -24,19 +30,27 @@ "System.Threading.Tasks.Extensions": "4.5.4" }, "compile": { - "lib/net461/Microsoft.Bcl.AsyncInterfaces.dll": {} + "lib/net461/Microsoft.Bcl.AsyncInterfaces.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net461/Microsoft.Bcl.AsyncInterfaces.dll": {} + "lib/net461/Microsoft.Bcl.AsyncInterfaces.dll": { + "related": ".xml" + } } }, "Microsoft.Extensions.DependencyInjection.Abstractions/2.0.0": { "type": "package", "compile": { - "lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": { + "related": ".xml" + } }, "runtime": { - "lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": { + "related": ".xml" + } } }, "Microsoft.Extensions.DependencyModel/6.0.0": { @@ -53,10 +67,14 @@ "System.Runtime" ], "compile": { - "lib/net461/Microsoft.Extensions.DependencyModel.dll": {} + "lib/net461/Microsoft.Extensions.DependencyModel.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net461/Microsoft.Extensions.DependencyModel.dll": {} + "lib/net461/Microsoft.Extensions.DependencyModel.dll": { + "related": ".xml" + } } }, "Microsoft.Extensions.Logging/2.0.0": { @@ -67,19 +85,27 @@ "Microsoft.Extensions.Options": "2.0.0" }, "compile": { - "lib/netstandard2.0/Microsoft.Extensions.Logging.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.Logging.dll": { + "related": ".xml" + } }, "runtime": { - "lib/netstandard2.0/Microsoft.Extensions.Logging.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.Logging.dll": { + "related": ".xml" + } } }, "Microsoft.Extensions.Logging.Abstractions/2.0.0": { "type": "package", "compile": { - "lib/netstandard2.0/Microsoft.Extensions.Logging.Abstractions.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.Logging.Abstractions.dll": { + "related": ".xml" + } }, "runtime": { - "lib/netstandard2.0/Microsoft.Extensions.Logging.Abstractions.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.Logging.Abstractions.dll": { + "related": ".xml" + } } }, "Microsoft.Extensions.Options/2.0.0": { @@ -89,10 +115,14 @@ "Microsoft.Extensions.Primitives": "2.0.0" }, "compile": { - "lib/netstandard2.0/Microsoft.Extensions.Options.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.Options.dll": { + "related": ".xml" + } }, "runtime": { - "lib/netstandard2.0/Microsoft.Extensions.Options.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.Options.dll": { + "related": ".xml" + } } }, "Microsoft.Extensions.Primitives/2.0.0": { @@ -101,21 +131,31 @@ "System.Runtime.CompilerServices.Unsafe": "4.4.0" }, "compile": { - "lib/netstandard2.0/Microsoft.Extensions.Primitives.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.Primitives.dll": { + "related": ".xml" + } }, "runtime": { - "lib/netstandard2.0/Microsoft.Extensions.Primitives.dll": {} + "lib/netstandard2.0/Microsoft.Extensions.Primitives.dll": { + "related": ".xml" + } } }, "RhinoCommon/7.13.21348.13001": { "type": "package", "compile": { - "lib/net48/Eto.dll": {}, + "lib/net48/Eto.dll": { + "related": ".xml" + }, "lib/net48/Rhino.UI.dll": {}, - "lib/net48/RhinoCommon.dll": {} + "lib/net48/RhinoCommon.dll": { + "related": ".XML" + } }, "runtime": { - "lib/net48/_._": {} + "lib/net48/_._": { + "related": ".xml" + } }, "build": { "build/RhinoCommon.targets": {} @@ -129,10 +169,14 @@ "System.Core" ], "compile": { - "lib/net47/Serilog.dll": {} + "lib/net47/Serilog.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net47/Serilog.dll": {} + "lib/net47/Serilog.dll": { + "related": ".xml" + } } }, "Serilog.Extensions.Logging/3.1.0": { @@ -142,10 +186,14 @@ "Serilog": "2.9.0" }, "compile": { - "lib/netstandard2.0/Serilog.Extensions.Logging.dll": {} + "lib/netstandard2.0/Serilog.Extensions.Logging.dll": { + "related": ".xml" + } }, "runtime": { - "lib/netstandard2.0/Serilog.Extensions.Logging.dll": {} + "lib/netstandard2.0/Serilog.Extensions.Logging.dll": { + "related": ".xml" + } } }, "Serilog.Sinks.File/5.0.0": { @@ -154,10 +202,14 @@ "Serilog": "2.10.0" }, "compile": { - "lib/net45/Serilog.Sinks.File.dll": {} + "lib/net45/Serilog.Sinks.File.dll": { + "related": ".pdb;.xml" + } }, "runtime": { - "lib/net45/Serilog.Sinks.File.dll": {} + "lib/net45/Serilog.Sinks.File.dll": { + "related": ".pdb;.xml" + } } }, "System.Buffers/4.5.1": { @@ -166,10 +218,14 @@ "mscorlib" ], "compile": { - "ref/net45/System.Buffers.dll": {} + "ref/net45/System.Buffers.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net461/System.Buffers.dll": {} + "lib/net461/System.Buffers.dll": { + "related": ".xml" + } } }, "System.Memory/4.5.4": { @@ -184,10 +240,14 @@ "mscorlib" ], "compile": { - "lib/net461/System.Memory.dll": {} + "lib/net461/System.Memory.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net461/System.Memory.dll": {} + "lib/net461/System.Memory.dll": { + "related": ".xml" + } } }, "System.Numerics.Vectors/4.5.0": { @@ -197,10 +257,14 @@ "mscorlib" ], "compile": { - "ref/net46/System.Numerics.Vectors.dll": {} + "ref/net46/System.Numerics.Vectors.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net46/System.Numerics.Vectors.dll": {} + "lib/net46/System.Numerics.Vectors.dll": { + "related": ".xml" + } } }, "System.Runtime.CompilerServices.Unsafe/6.0.0": { @@ -209,10 +273,14 @@ "mscorlib" ], "compile": { - "lib/net461/System.Runtime.CompilerServices.Unsafe.dll": {} + "lib/net461/System.Runtime.CompilerServices.Unsafe.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net461/System.Runtime.CompilerServices.Unsafe.dll": {} + "lib/net461/System.Runtime.CompilerServices.Unsafe.dll": { + "related": ".xml" + } } }, "System.Runtime.InteropServices.RuntimeInformation/4.3.0": { @@ -242,10 +310,14 @@ "System.Runtime.CompilerServices.Unsafe": "6.0.0" }, "compile": { - "lib/net461/System.Text.Encodings.Web.dll": {} + "lib/net461/System.Text.Encodings.Web.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net461/System.Text.Encodings.Web.dll": {} + "lib/net461/System.Text.Encodings.Web.dll": { + "related": ".xml" + } } }, "System.Text.Json/6.0.0": { @@ -261,10 +333,14 @@ "System.ValueTuple": "4.5.0" }, "compile": { - "lib/net461/System.Text.Json.dll": {} + "lib/net461/System.Text.Json.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net461/System.Text.Json.dll": {} + "lib/net461/System.Text.Json.dll": { + "related": ".xml" + } }, "build": { "build/_._": {} @@ -279,10 +355,14 @@ "mscorlib" ], "compile": { - "lib/net461/System.Threading.Tasks.Extensions.dll": {} + "lib/net461/System.Threading.Tasks.Extensions.dll": { + "related": ".xml" + } }, "runtime": { - "lib/net461/System.Threading.Tasks.Extensions.dll": {} + "lib/net461/System.Threading.Tasks.Extensions.dll": { + "related": ".xml" + } } }, "System.ValueTuple/4.5.0": { @@ -294,7 +374,9 @@ "ref/net47/System.ValueTuple.dll": {} }, "runtime": { - "lib/net47/System.ValueTuple.dll": {} + "lib/net47/System.ValueTuple.dll": { + "related": ".xml" + } } } } @@ -846,19 +928,19 @@ ] }, "packageFolders": { - "C:\\Users\\sverremh\\.nuget\\packages\\": {} + "C:\\Users\\kollb\\.nuget\\packages\\": {} }, "project": { "version": "1.0.0", "restore": { - "projectUniqueName": "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\FirstPythonComponent.csproj", + "projectUniqueName": "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\FirstPythonComponent.csproj", "projectName": "FirstPythonComponent", - "projectPath": "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\FirstPythonComponent.csproj", - "packagesPath": "C:\\Users\\sverremh\\.nuget\\packages\\", - "outputPath": "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\obj\\", + "projectPath": "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\FirstPythonComponent.csproj", + "packagesPath": "C:\\Users\\kollb\\.nuget\\packages\\", + "outputPath": "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\obj\\", "projectStyle": "PackageReference", "configFilePaths": [ - "C:\\Users\\sverremh\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Users\\kollb\\AppData\\Roaming\\NuGet\\NuGet.Config", "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" ], "originalTargetFrameworks": [ @@ -906,7 +988,7 @@ "version": "[5.0.0, )" } }, - "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.102\\RuntimeIdentifierGraph.json" + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.101\\RuntimeIdentifierGraph.json" } } } diff --git a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/project.nuget.cache b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/project.nuget.cache index a09fe362..c8597347 100644 --- a/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/project.nuget.cache +++ b/GrasshopperSolution/C#_Python_Component/FirstPythonComponent/obj/project.nuget.cache @@ -1,30 +1,30 @@ { "version": 2, - "dgSpecHash": "Ug8Cak8kLExTWp6LN5ww0wTd20TVPvP8EQrVDmnskKVPvAVmcUbNtchmPrahq/IMzMs+HVoZmFCe6uM7BZHgXw==", + "dgSpecHash": "py00i1mxsCVCU1VquSIbg5uZNt26aFfc6pufc+FEgofBNUq0zZTU+6GfK7J+J89v+BpNk05+3kCRy38dFFuxCA==", "success": true, - "projectFilePath": "C:\\Users\\sverremh\\source\\repos\\FirstPythonComponent\\FirstPythonComponent\\FirstPythonComponent.csproj", + "projectFilePath": "C:\\Users\\kollb\\Master\\Master-Thesis-NTNU\\app\\matchingTool\\src\\GrasshopperSolution\\C#_Python_Component\\FirstPythonComponent\\FirstPythonComponent.csproj", "expectedPackageFiles": [ - "C:\\Users\\sverremh\\.nuget\\packages\\grasshopper\\7.13.21348.13001\\grasshopper.7.13.21348.13001.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\microsoft.bcl.asyncinterfaces\\6.0.0\\microsoft.bcl.asyncinterfaces.6.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\microsoft.extensions.dependencyinjection.abstractions\\2.0.0\\microsoft.extensions.dependencyinjection.abstractions.2.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\microsoft.extensions.dependencymodel\\6.0.0\\microsoft.extensions.dependencymodel.6.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\microsoft.extensions.logging\\2.0.0\\microsoft.extensions.logging.2.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\microsoft.extensions.logging.abstractions\\2.0.0\\microsoft.extensions.logging.abstractions.2.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\microsoft.extensions.options\\2.0.0\\microsoft.extensions.options.2.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\microsoft.extensions.primitives\\2.0.0\\microsoft.extensions.primitives.2.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\rhinocommon\\7.13.21348.13001\\rhinocommon.7.13.21348.13001.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\serilog\\2.12.0\\serilog.2.12.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\serilog.extensions.logging\\3.1.0\\serilog.extensions.logging.3.1.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\serilog.sinks.file\\5.0.0\\serilog.sinks.file.5.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.buffers\\4.5.1\\system.buffers.4.5.1.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.memory\\4.5.4\\system.memory.4.5.4.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.numerics.vectors\\4.5.0\\system.numerics.vectors.4.5.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.runtime.compilerservices.unsafe\\6.0.0\\system.runtime.compilerservices.unsafe.6.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.runtime.interopservices.runtimeinformation\\4.3.0\\system.runtime.interopservices.runtimeinformation.4.3.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.text.encodings.web\\6.0.0\\system.text.encodings.web.6.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.text.json\\6.0.0\\system.text.json.6.0.0.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.threading.tasks.extensions\\4.5.4\\system.threading.tasks.extensions.4.5.4.nupkg.sha512", - "C:\\Users\\sverremh\\.nuget\\packages\\system.valuetuple\\4.5.0\\system.valuetuple.4.5.0.nupkg.sha512" + "C:\\Users\\kollb\\.nuget\\packages\\grasshopper\\7.13.21348.13001\\grasshopper.7.13.21348.13001.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\microsoft.bcl.asyncinterfaces\\6.0.0\\microsoft.bcl.asyncinterfaces.6.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\microsoft.extensions.dependencyinjection.abstractions\\2.0.0\\microsoft.extensions.dependencyinjection.abstractions.2.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\microsoft.extensions.dependencymodel\\6.0.0\\microsoft.extensions.dependencymodel.6.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\microsoft.extensions.logging\\2.0.0\\microsoft.extensions.logging.2.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\microsoft.extensions.logging.abstractions\\2.0.0\\microsoft.extensions.logging.abstractions.2.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\microsoft.extensions.options\\2.0.0\\microsoft.extensions.options.2.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\microsoft.extensions.primitives\\2.0.0\\microsoft.extensions.primitives.2.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\rhinocommon\\7.13.21348.13001\\rhinocommon.7.13.21348.13001.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\serilog\\2.12.0\\serilog.2.12.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\serilog.extensions.logging\\3.1.0\\serilog.extensions.logging.3.1.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\serilog.sinks.file\\5.0.0\\serilog.sinks.file.5.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.buffers\\4.5.1\\system.buffers.4.5.1.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.memory\\4.5.4\\system.memory.4.5.4.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.numerics.vectors\\4.5.0\\system.numerics.vectors.4.5.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.runtime.compilerservices.unsafe\\6.0.0\\system.runtime.compilerservices.unsafe.6.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.runtime.interopservices.runtimeinformation\\4.3.0\\system.runtime.interopservices.runtimeinformation.4.3.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.text.encodings.web\\6.0.0\\system.text.encodings.web.6.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.text.json\\6.0.0\\system.text.json.6.0.0.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.threading.tasks.extensions\\4.5.4\\system.threading.tasks.extensions.4.5.4.nupkg.sha512", + "C:\\Users\\kollb\\.nuget\\packages\\system.valuetuple\\4.5.0\\system.valuetuple.4.5.0.nupkg.sha512" ], "logs": [] } \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index b506634b..00000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Artur Tomczak - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Matching/helper_methods.py b/Matching/helper_methods.py index 7e0675d1..ddc32a40 100644 --- a/Matching/helper_methods.py +++ b/Matching/helper_methods.py @@ -11,7 +11,7 @@ import json # Opening JSON file -with open('Matching\Data\LCA_data.json') as json_file: +with open('app\matchingTool\src\Matching\Data\LCA_data.json') as json_file: data = json.load(json_file) # ==== HELPER METHODS ==== @@ -455,6 +455,25 @@ def generate_score_function_string(constants): score_function_string = f"@lca.calculate_price(length=Length, area =Area, include_transportation = {transportation}, distance = Distance, price = Price, density = Density, price_transport= {constants['PRICE_TRANSPORTATION']})" return score_function_string +def generate_score_function_string_2d(constants): + """Generating the score function string for the matching + + Args: + constants (dictionary): constants to use in the matching tool + + Returns: + string: the score function string for evaluation of the weight matrix + """ + metric = constants["Metric"] + transportation = constants["Include transportation"] + if metric == "GWP": + score_function_string = f"@lca.calculate_lca_2d(height = Height, width = Width, include_transportation={transportation}, distance = Distance, gwp_factor=Gwp_factor, transport_gwp = {constants['TRANSPORT_GWP']}, density = Density)" + elif metric == "Combined": + score_function_string = f"@lca.calculate_score_2d(height = Height, width = Width, include_transportation = {transportation}, distance = Distance, gwp_factor = Gwp_factor, transport_gwp = {constants['TRANSPORT_GWP']}, price = Price, priceGWP = {constants['VALUATION_GWP']}, density = Density, price_transport = {constants['PRICE_TRANSPORTATION']})" + elif metric == "Price": + score_function_string = f"@lca.calculate_price_2d(height = Height, width = Width, include_transportation = {transportation}, distance = Distance, price = Price, density = Density, price_transport= {constants['PRICE_TRANSPORTATION']})" + return score_function_string + def fill_closest_manufacturer(dataframe, constants): """Fill the dataframe with the colsets manufacturer depending on the material diff --git a/Matching/helper_methods_LCA.py b/Matching/helper_methods_LCA.py index 2c157a66..f4984cb4 100644 --- a/Matching/helper_methods_LCA.py +++ b/Matching/helper_methods_LCA.py @@ -3,7 +3,7 @@ import json # Opening JSON file -with open('Matching\Data\LCA_data.json') as json_file: +with open('app\matchingTool\src\Matching\Data\LCA_data.json') as json_file: data = json.load(json_file) def calculate_lca(length, area, gwp_factor, include_transportation=False, distance=100, transport_gwp=100, density=100): @@ -100,6 +100,101 @@ def calculate_price(length, area, include_transportation, distance, price, densi return score, transportation_score + +def calculate_lca_2d(height, width, gwp_factor, include_transportation=False, distance=100, transport_gwp=100, density=100): + """ Calculates the GWP of the elements + + Args: + length (float): length of element + area (float): area of element + include_transportation (boolean): if transportation should be included + distance (float): driving distance to the construction site + gwp_factor (float): GWP factor for the element + transport_gwp (float): GWP factor for transportation + density (float): density of the element + + Returns: + lca (float): the GWP of the element + transportation_LCA (float): the GWP of transporting the element + """ + area = height * width + lca = area * gwp_factor + transportation_LCA = lca.copy() + transportation_LCA[:] = 0 + if include_transportation: + transportation_LCA = calculate_transportation_LCA(area, density, distance, transport_gwp) + lca += transportation_LCA + return lca, transportation_LCA + + +def calculate_score_2d(height, width, include_transportation, distance, gwp_factor, transport_gwp, price, priceGWP, density, price_transport): + """ Method for evaluatating the scores corresponding to the "Combined" metric (both price and GWP) + + Args: + length (float): length of element + area (float): area of element + include_transportation (boolean): if transportation should be included + distance (float): driving distance to the construction site + gwp_factor (float): GWP factor for the element + transport_gwp (float): GWP factor for transportation + price (float): price of the element + priceGWP (float): price factor for GWP + density (float): density of the element + price_transport (float): price factor for transportation + + Returns: + score (float): the score of the element concidering both GWP and Price (combined) + transportation_score (float): the score of transporting the element + """ + area = height * width + score = area * gwp_factor + transportation_score = score.copy() + transportation_score[:] = 0 + + if not include_transportation: + score=score*priceGWP + + if include_transportation: + transportation_LCA = calculate_transportation_LCA(area, density, distance, transport_gwp) + transportation_cost= calcultate_price_transport(area,density,distance, price_transport) + logging.debug(f"Transportation LCA:", transportation_LCA) + score += transportation_LCA + score=score*priceGWP + score+=transportation_cost + transportation_score += transportation_LCA*priceGWP + transportation_cost + + price_element=area*price + score+=price_element + + return score, transportation_score + +def calculate_price_2d(heigth, width, include_transportation, distance, price, density, price_transport): + """ Method for evaluatating the price of an element + + Args: + length (float): length of element + area (float): area of element + include_transportation (boolean): if transportation should be included + distance (float): driving distance to the construction site + price (float): price of the element + density (float): density of the element + price_transport (float): price factor for transportation + + Returns: + score (float): the price of the element + transportation_score (float): the price of transporting the element + """ + area = heigth * width + score = area * price #In kr + transportation_score = score.copy() + transportation_score[:] = 0 + + if include_transportation: + transportation_score = calcultate_price_transport(area,density,distance, price_transport) + score += transportation_score + + return score, transportation_score + def calculate_driving_distance(A_lat, A_lon, B_lat, B_lon): """Calculates the driving distance between two coordinates and returns the result in meters - Coordinates as a String diff --git a/Matching/helper_methods_PDF.py b/Matching/helper_methods_PDF.py index f8c33fa0..ddc1e244 100644 --- a/Matching/helper_methods_PDF.py +++ b/Matching/helper_methods_PDF.py @@ -93,7 +93,7 @@ def extract_results_df_pdf(dict_list, constants): results_dict["Constants used"] = used_constants return results_dict -def create_random_data_supply_pdf_reports(supply_count, length_min, length_max, area_min, area_max, materials, supply_coords): +def create_random_data_supply_pdf_reports(supply_count, length_min, length_max, width_min, width_max, height_min, height_max, area_min, area_max, materials, supply_coords): """Creates random data for the case studies in the master thesis Args: @@ -122,6 +122,8 @@ def create_random_data_supply_pdf_reports(supply_count, length_min, length_max, np.random.RandomState(2023) supply = pd.DataFrame() supply['Length'] = np.round((length_max - length_min) * np.random.random_sample(size = supply_count) + length_min, 2) + supply['Width'] = np.round((width_max - width_min) * np.random.random_sample(size = supply_count) + width_min, 2) + supply['Height'] = np.round((height_max - height_min) * np.random.random_sample(size = supply_count) + height_min, 2) supply['Area'] = 0 supply['Moment of Inertia'] = 0 supply['Material'] = "" @@ -149,7 +151,7 @@ def create_random_data_supply_pdf_reports(supply_count, length_min, length_max, supply.loc[row,"Location"]=supply_coords.loc[lokasjon,"Location"] return supply -def create_random_data_demand_pdf_reports(demand_count, length_min, length_max, area_min, area_max, materials): +def create_random_data_demand_pdf_reports(demand_count, length_min, length_max, width_min, width_max, height_min, height_max, area_min, area_max, materials): """Creates random data for the case studies in the master thesis Args: @@ -175,6 +177,8 @@ def create_random_data_demand_pdf_reports(demand_count, length_min, length_max, np.random.RandomState(2023) demand = pd.DataFrame() demand['Length'] = np.round((length_max - length_min) * np.random.random_sample(size = demand_count) + length_min, 2) + demand['Width'] = np.round((width_max - width_min) * np.random.random_sample(size = demand_count) + width_min, 2) + demand['Height'] = np.round((height_max - height_min) * np.random.random_sample(size = demand_count) + height_min, 2) demand['Area'] = 0 demand['Moment of Inertia'] = 0 demand['Material'] = "" @@ -538,7 +542,11 @@ def add_necessary_columns_pdf(dataframe, constants): dataframe["Density"] = 0 dataframe["Site_lat"] = constants["Site latitude"] dataframe["Site_lon"] = constants["Site longitude"] + dataframe["Gwp_factor"] = 0 + dataframe["Price"] = 0 + + """ if metric == "GWP": dataframe["Gwp_factor"] = 0 elif metric == "Combined": @@ -546,6 +554,8 @@ def add_necessary_columns_pdf(dataframe, constants): dataframe["Price"] = 0 elif metric == "Price": dataframe["Price"] = 0 + """ + #If dataframe is demand, fill in the location and corresponding coordinates and to the closet manufacturer. if element_type=="D" and constants["Include transportation"]: @@ -553,7 +563,8 @@ def add_necessary_columns_pdf(dataframe, constants): #Adding necessary columns based on the chosen metric for row in range(len(dataframe)): - material = dataframe.iloc[row][dataframe.columns.get_loc("Material")].split()[0] #NOTE: Assumes that material-column has the material name as the first word, e.g. "Timber C14" or "Steel ASTM A992" + #material = dataframe.iloc[row][dataframe.columns.get_loc("Material")].split()[0] #NOTE: Assumes that material-column has the material name as the first word, e.g. "Timber C14" or "Steel ASTM A992" + material = dataframe.iloc[row][dataframe.columns.get_loc("Material")] dataframe.iloc[row, dataframe.columns.get_loc("Density")] = constants[f"{material.upper()}_DENSITY"] if element_type == "S": @@ -561,6 +572,16 @@ def add_necessary_columns_pdf(dataframe, constants): else: constant_name = f"{material.upper()}" + + dataframe.iloc[row, dataframe.columns.get_loc("Gwp_factor")] = constants[constant_name + "_GWP"] + if material.upper() == "STEEL": + price = constants[constant_name + "_PRICE"] * constants[f"{material.upper()}_DENSITY"] + else: + price = constants[constant_name + "_PRICE"] + dataframe.iloc[row, dataframe.columns.get_loc("Price")] = price + + """ + if metric == "GWP" or metric == "Combined": dataframe.iloc[row, dataframe.columns.get_loc("Gwp_factor")] = constants[constant_name + "_GWP"] if metric == "Price" or metric == "Combined": @@ -569,6 +590,7 @@ def add_necessary_columns_pdf(dataframe, constants): else: price = constants[constant_name + "_PRICE"] dataframe.iloc[row, dataframe.columns.get_loc("Price")] = price + """ return dataframe print_header = lambda matching_name: print("\n"+"="*(len(matching_name)+8) + "\n*** " + matching_name + " ***\n" + "="*(len(matching_name)+8) + "\n") \ No newline at end of file diff --git a/Matching/matching.py b/Matching/matching.py index 27c3b01e..08296fa9 100644 --- a/Matching/matching.py +++ b/Matching/matching.py @@ -33,7 +33,7 @@ class Matching(): """Class describing the matching problem, with its constituent parts.""" - def __init__(self, demand, supply, score_function_string, add_new=False, multi=False, constraints={}, solution_limit=60): + def __init__(self, demand, supply, score_function_string, score_function_string_2d, constants, add_new=False, multi=False, constraints={}, constraints2D={}, constraints3D={}, solution_limit=60): """_summary_ :param demand: _description_ @@ -48,20 +48,38 @@ def __init__(self, demand, supply, score_function_string, add_new=False, multi=F :type multi: bool, optional :param constraints: _description_, defaults to {} :type constraints: dict, optional + :param constraints2D: _description_, defaults to {} + :type constraints2D: dict, optional + :param constraints3D: _description_, defaults to {} + :type constraints3D: dict, optional :param solution_limit: _description_, defaults to 60 :type solution_limit: int, optional + :param constants: _description_, defaults to 60 + :type constants: int, optional + :param score_function_string_2d: _description_, defaults to 60 + :type score_function_string_2d: int, optional """ self.demand = demand.infer_objects() self.supply = supply.infer_objects() self.score_function_string = score_function_string.replace(" ", "") + self.score_function_string_2d = score_function_string_2d.replace(" ", "") + + #self.price_function_string = price_function_string.replace(" ", "") self.evaluate_transportation() - + pd.set_option('display.max_columns', 10) #Calculate the score and transportation score for the demand and supply elements - self.demand['Score'], self.demand["Transportation"] = self.demand.eval(self.score_function_string) - self.supply['Score'], self.supply["Transportation"] = self.supply.eval(self.score_function_string) + if tuple(self.demand['Element'].tolist()) in constants["element_linear"] or tuple(self.demand['Element'].tolist()) in constants["element_3d"]: + self.demand['Score'], self.demand['Transportation'] = self.demand.eval(self.score_function_string) + else: + self.demand['Score'], self.demand['Transportation'] = self.demand.eval(self.score_function_string_2d) + + if tuple(self.supply['Element'].tolist()) in constants["element_linear"] or tuple(self.supply['Element'].tolist()) in constants["element_3d"]: + self.supply['Score'], self.supply['Transportation'] = self.supply.eval(self.score_function_string) + else: + self.supply['Score'], self.supply['Transportation'] = self.supply.eval(self.score_function_string_2d) if add_new: # just copy designed to supply set, so that they act as new products demand_copy = self.demand.copy(deep = True) @@ -80,13 +98,17 @@ def __init__(self, demand, supply, score_function_string, add_new=False, multi=F self.pairs = pd.DataFrame(None, index=self.demand.index.values.tolist(), columns=['Supply_id']) #saves latest array of pairs self.incidence = pd.DataFrame(np.nan, index=self.demand.index.values.tolist(), columns=self.supply.index.values.tolist()) self.constraints = constraints + self.constraints2D = constraints2D + self.constraints3D = constraints3D self.solution_time = None self.solution_limit = solution_limit #Create incidence and weight for the method self.demand['Score'] = self.demand.eval(score_function_string)[0] self.supply['Score'] = self.supply.eval(score_function_string)[0] self.incidence = self.evaluate_incidence() + self.constants = constants self.weights, self.weights_transport = self.evaluate_weights() + #self.match_greedy(plural_assign=True) logging.info("Matching object created with %s demand, and %s supply elements", len(demand), len(supply)) def __copy__(self): @@ -157,44 +179,214 @@ def evaluate_transportation(self): else: self.supply["Distance"] = np.NaN self.demand["Distance"] = np.NaN - + + + def evaluate_incidence(self): - """Returns incidence matrix with true values where the element fit constraint criteria""" + """Returns incidence matrix with true values where the element fit constraint criteria""" # TODO optimize the evaluation. # TODO add 'Distance' 'Price' 'Material' 'Density' 'Imperfections' 'Is_column' 'Utilisation' 'Group' 'Quality' 'Max_height' ? #TODO Create standalone method for evaluating one column Rj of the incidence matrix. Need this for cutoffs in greedy algorithm as well. start = time.time() + #constraints = [] test change + bool_array = np.full((self.demand.shape[0], self.supply.shape[0]), True) # initiate empty array - for param, compare in self.constraints.items(): - cond_list = [] - for var in self.supply[param]: - demand_array = self.demand[param].to_list() - if isinstance(demand_array[0], str): #Assumes that target is to compare two text strings, "Timber" == "Timber" - bool_col = np.array(eval(f"['{var}' {compare} x for x in demand_array]")) + constraint_dict = self.constraints.items() + nrSupply = self.supply.shape[0] + nrDemand = self.demand.shape[0] + + for i in range(nrDemand): + for j in range(nrSupply): + #Check if element type is right + if (self.demand.iloc[i, 1] != self.supply.iloc[j, 1]): + print([i],[j]) + print(False) + bool_array[i][j] = False + #Check if material type is right + elif (self.demand.iloc[i, 2] != self.supply.iloc[j, 2]): + print([i],[j]) + bool_array[i][j] = False + print(False) + #Check if the constraints are right for the type of element else: - bool_col = ne.evaluate(f'{var} {compare} demand_array') # numpy array of boolean NOTE: Does not work when evaluating material given as a "String" - cond_list.append(bool_col) - cond_array = np.column_stack(cond_list) #create new 2D-array of conditionals - bool_array = ne.evaluate("cond_array & bool_array") # - #bool_array = np.logical_and(bool_array, cond_array) - # for simplicity I restrict the incidence of new elements to only be True for the "new" equivalent - inds = self.supply.index[self.supply.index.map(lambda s: 'N' in s)] # Get the indices for new elements - if len(inds) > 0: - diag_mat = np.full((len(inds), len(inds)), False) - np.fill_diagonal(diag_mat, True) # create a diagonal with True on diag, False else. - bool_array = np.hstack((bool_array[:, :-len(inds)], diag_mat)) - - end = time.time() - logging.info("Create incidence matrix from constraints: %s sec", round(end - start,3)) + #If the elements are linear + if (self.demand.iloc[i, 1] == "IfcBeam" or self.demand.iloc[i, 1] == "IfcColumn"): + for param, compare in self.constraints.items(): + supply_array = self.supply[param].to_list() + demand_array = self.demand[param].to_list() + if eval(f"supply_array[j] {compare} demand_array[i]"): + print(param) + print(f"supply_array[j] {compare} demand_array[i]") + print([i],[j]) + bool_array[i][j] = True + + else: + print(param) + print(f"supply_array[j] {compare} demand_array[i]") + print([i],[j]) + bool_array[i][j] = False + print(False) + break + #If the elements are 2D + elif (self.demand.iloc[i, 1] == "IfcWindow" or self.demand.iloc[i, 1] == "IfcDoor" or self.demand.iloc[i, 1] == "IfcWall"): + for param, compare in self.constraints2D.items(): + supply_array = self.supply[param].to_list() + demand_array = self.demand[param].to_list() + if eval(f"supply_array[j] {compare} demand_array[i]"): + print(param) + print(f"supply_array[j] {compare} demand_array[i]") + print([i],[j]) + bool_array[i][j] = True + else: + print(param) + print(f"supply_array[j] {compare} demand_array[i]") + print([i],[j]) + bool_array[i][j] = False + print(False) + break + #If the elements are 3D + elif (self.demand.iloc[i, 1] == "IfcSlab"): + for param, compare in self.constraints3D.items(): + supply_array = self.supply[param].to_list() + demand_array = self.demand[param].to_list() + + if eval(f"supply_array[j] {compare} demand_array[i]"): + print(param) + print(f"supply_array[j] {compare} demand_array[i]") + print([i],[j]) + bool_array[i][j] = True + else: + print(param) + print(f"supply_array[j] {compare} demand_array[i]") + print([i],[j]) + bool_array[i][j] = False + print(False) + break + + hm.export_dataframe_to_xlsx(pd.DataFrame(bool_array, columns= self.incidence.columns, index= self.incidence.index), r"" + "./app/matchingTool/src/TestCases/Data/CSV/bool_array1.xlsx") return pd.DataFrame(bool_array, columns= self.incidence.columns, index= self.incidence.index) + """ + + def evaluate_incidence(self): + Returns incidence matrix with true values where the element fit constraint criteria + # TODO optimize the evaluation. + # TODO add 'Distance' 'Price' 'Material' 'Density' 'Imperfections' 'Is_column' 'Utilisation' 'Group' 'Quality' 'Max_height' ? + #TODO Create standalone method for evaluating one column Rj of the incidence matrix. Need this for cutoffs in greedy algorithm as well. + start = time.time() + #constraints = [] test change + + bool_array = np.full((self.demand.shape[0], self.supply.shape[0]), True) # initiate empty array + constraint_dict = self.constraints.items() + iindex = 0 + jindex = 0 + nrSupply = self.supply.shape[0] + nrDemand = self.incidence.shape[0] + for i in range(len(self.supply)): + if iindex < nrSupply: + for j in range(len(self.demand)): + #Check if element type is right + if (self.supply.iloc[i, 1] != self.demand.iloc[j, 1]): + bool_array[j][i] = False + print([j],[i]) + #Check if material type is right + elif (self.supply.iloc[i, 2] != self.demand.iloc[j, 2]): + bool_array[j][i] = False + print([j],[i]) + #Check if the constraints are right for the type of element + else: + #If the elements are linear + if (self.supply.iloc[i, 1] == "IfcBeam" or self.supply.iloc[i, 1] == "IfcColumn"): + for param, compare in self.constraints.items(): + supply_array = self.supply[param].to_list() + demand_array = self.demand[param].to_list() + if eval(f"supply_array[i] {compare} demand_array[j]"): + print(param) + print(f"supply_array[i] {compare} demand_array[j]") + print([j],[i]) + bool_array[j][i] = True + + else: + bool_array[j][i] = False + print(param) + print(f"supply_array[i] {compare} demand_array[j]") + print([j],[i]) + break + #If the elements are 2D + elif (self.supply.iloc[i, 1] == "IfcWindow" or self.supply.iloc[i, 1] == "IfcDoor" or self.supply.iloc[i, 1] == "IfcWall"): + for param, compare in self.constraints2D.items(): + supply_array = self.supply[param].to_list() + demand_array = self.demand[param].to_list() + if eval(f"supply_array[i] {compare} demand_array[j]"): + print(param) + print(f"supply_array[i] {compare} demand_array[j]") + print([j],[i]) + bool_array[j][i] = True + else: + print(param) + print(f"supply_array[i] {compare} demand_array[j]") + print([j],[i]) + bool_array[j][i] = False + break + #If the elements are 3D + elif (self.supply.iloc[i, 1] == "IfcSlab"): + for param, compare in self.constraints3D.items(): + supply_array = self.supply[param].to_list() + demand_array = self.demand[param].to_list() + + if eval(f"supply_array[i] {compare} demand_array[j]"): + print(param) + print(f"supply_array[i] {compare} demand_array[j]") + print([j][i]) + bool_array[j][i] = True + else: + print(param) + print(f"supply_array[i] {compare} demand_array[j]") + print([j][i]) + bool_array[j][i] = False + break + + iindex += 1 + return pd.DataFrame(bool_array, columns= self.incidence.columns, index= self.incidence.index) + + """ + def evaluate_column(self, supply_val, parameter, compare, current_bool): """Evaluates a column in the incidence matrix according to the constraints Returns a np array that can substitute the input column.""" demand_array = self.demand[parameter].to_numpy(dtype = float) # array of demand parameters to evaluate. compare_array = ne.evaluate(f"{supply_val} {compare} demand_array") return ne.evaluate("current_bool & compare_array") + + """ + + def evaluate_weights(self): + Return matrix of weights for elements in the incidence matrix. The lower the weight the better. + start = time.time() + weights = np.full(self.incidence.shape, np.nan) + weights_transport = np.full(self.incidence.shape, np.nan) + el_locs0 = np.where(self.incidence) # tuple of rows and columns positions, as a list + el_locs = np.transpose(el_locs0) # array of row-column pairs where incidence matrix is true. + # create a new dataframe with values from supply, except for the Length, which is from demand set (cut supply) + eval_df = self.supply.iloc[el_locs0[1]].reset_index(drop=True) + + if tuple(self.demand['Element'].tolist()) in self.constants["element_linear"] or tuple(self.demand['Element'].tolist()) in self.constants["element_3d"]: + eval_df['Length'] = self.demand.iloc[el_locs0[0]]['Length'].reset_index(drop=True) + eval_scores = self.demand.eval(self.score_function_string) + else: + eval_df['Area'] = self.demand.iloc[el_locs0[0]]['Area'].reset_index(drop=True) + eval_scores = self.demand.eval(self.score_function_string_2d) + eval_score = eval_scores[0] + eval_score_transport = eval_scores[1] + weights[el_locs0[0], el_locs0[1]] = eval_score + weights_transport[el_locs0[0], el_locs0[1]] = eval_score_transport + end = time.time() + logging.info("Weight evaluation of incidence matrix: %s sec", round(end - start, 3)) + return pd.DataFrame(weights, index = self.incidence.index, columns = self.incidence.columns) ,pd.DataFrame(weights_transport, index = self.incidence.index, columns = self.incidence.columns) + + + """ def evaluate_weights(self): """Return matrix of weights for elements in the incidence matrix. The lower the weight the better.""" start = time.time() @@ -205,6 +397,7 @@ def evaluate_weights(self): # create a new dataframe with values from supply, except for the Length, which is from demand set (cut supply) eval_df = self.supply.iloc[el_locs0[1]].reset_index(drop=True) eval_df['Length'] = self.demand.iloc[el_locs0[0]]['Length'].reset_index(drop=True) + eval_scores = self.demand.eval(self.score_function_string) eval_scores = eval_df.eval(self.score_function_string) eval_score = eval_scores[0] eval_score_transport = eval_scores[1] @@ -212,7 +405,7 @@ def evaluate_weights(self): weights_transport[el_locs0[0], el_locs0[1]] = eval_score_transport end = time.time() logging.info("Weight evaluation of incidence matrix: %s sec", round(end - start, 3)) - return pd.DataFrame(weights, index = self.incidence.index, columns = self.incidence.columns), pd.DataFrame(weights_transport, index = self.incidence.index, columns = self.incidence.columns) + return pd.DataFrame(weights, index = self.incidence.index, columns = self.incidence.columns) ,pd.DataFrame(weights_transport, index = self.incidence.index, columns = self.incidence.columns) def add_pair(self, demand_id, supply_id): """Execute matrix matching""" @@ -779,7 +972,7 @@ def run_matching(demand, supply, score_function_string, constraints = None, add_ matches.append({'Name': 'MBM Plural Multiple','Match object': copy(matching), 'Time': matching.solution_time, 'PercentNew': matching.pairs.isna().sum()}) return matches - +""" if __name__ == "__main__": DEMAND_JSON = sys.argv[1] SUPPLY_JSON = sys.argv[2] @@ -791,8 +984,10 @@ def run_matching(demand, supply, score_function_string, constraints = None, add_ result = run_matching(demand, supply, score_function_string=score_function_string, constraints = constraint_dict, add_new = True, sci_milp=False, milp=False, greedy_single=True, greedy_plural = False, bipartite=False, genetic=True) simple_pairs = hm.extract_pairs_df(result) simple_results = hm.extract_results_df(result) + print("Simple pairs:") print(simple_pairs) print() print("Simple results") - print(simple_results) \ No newline at end of file + print(simple_results) + """ \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 8ba36d60..00000000 --- a/README.md +++ /dev/null @@ -1,64 +0,0 @@ -[![DOI](https://zenodo.org/badge/574263139.svg)](https://zenodo.org/badge/latestdoi/574263139) -# structuralCircle -Sustainable design from used structural elements. A project about building design from used elements in Grasshopper and Rhino. - -The repository contains data, tests and solutions related to the research project at Norwegian University of Science and Technology (NTNU). - -The **structuralCircle** project is about aiding the design process with reclaimed building components. In particular, the algorithm is matching available products to the design intent, aiming at environmental impact minimization. - -The solution is written in Python and for the ease of use wrapped into a Grasshopper nodes available for Rhino users. - -The implementation includes greedy algorithms, bipartite graphs, and mixed integer linear programming. - -Test data contains simulated sets of building elements. The aim of test cases is to compare score - reduction of embodied emissions, and speed of the calculation. - -The algorithms are also explained in this Colab notebook: -https://colab.research.google.com/drive/1BRBxFhya6xCnV-flAPq-Ro8zkxuSnnhC?usp=sharing - -# How to run -First, run the console and install the required packages from the list using: - -``` -pip install -r requirements.txt -``` - -Then, import the relevant packages and define the input data: - -``` -# import relevant packages -import pandas as pd -import sys -sys.path.append('./Matching') -import helper_methods as hm -from matching import run_matching -import LCA as lca - -# Create two datasets with two elements in each - demand D and supply S: -demand = pd.DataFrame(columns = ['Length', 'Area', 'Inertia_moment', 'Height', 'Gwp_factor']) -demand.loc['D1'] = {'Length': 4.00, 'Area': 0.06, 'Inertia_moment':0.00030, 'Height': 0.30, 'Gwp_factor':lca.TIMBER_GWP} -demand.loc['D2'] = {'Length': 5.00, 'Area': 0.04, 'Inertia_moment':0.00010, 'Height': 0.20, 'Gwp_factor':lca.TIMBER_GWP} -supply = pd.DataFrame(columns = ['Length', 'Area', 'Inertia_moment', 'Height', 'Gwp_factor']) -supply.loc['S1'] = {'Length': 5.50, 'Area': 0.045, 'Inertia_moment':0.00010, 'Height': 0.20, 'Gwp_factor':lca.TIMBER_REUSE_GWP} -supply.loc['S2'] = {'Length': 4.50, 'Area': 0.065, 'Inertia_moment':0.00035, 'Height': 0.35, 'Gwp_factor':lca.TIMBER_REUSE_GWP} - -# create constraint dictionary -constraint_dict = {'Area' : '>=', 'Inertia_moment' : '>=', 'Length' : '>='} - -# create optimization formula -score_function_string = "@lca.calculate_lca(length=Length, area=Area, gwp_factor=Gwp_factor, include_transportation=False)" -``` - -Finally, run the matching with desired methods and display the resultant pairs of elements: -``` -# run the matching -result_simple = run_matching(demand, supply, score_function_string=score_function_string, constraints = constraint_dict, add_new = True, sci_milp=False, milp=False, greedy_single=True, bipartite=True) - -# display results - matching table -print(hm.extract_pairs_df(result_simple)) -# display results - the score -print(hm.extract_results_df(result_simple)) -``` - -# Read more - -You can read our journal paper called 'Matching algorithms to assist in designing with reclaimed building elements' here: https://iopscience.iop.org/article/10.1088/2634-4505/acf341 diff --git a/TestCases/Data/CSV/DEMAND_DATAFRAME_SVERRE.xlsx b/TestCases/Data/CSV/DEMAND_DATAFRAME_SVERRE.xlsx deleted file mode 100644 index 6e3a4b7f..00000000 Binary files a/TestCases/Data/CSV/DEMAND_DATAFRAME_SVERRE.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/DEMAND_TEST_FILL_CLOSEST.xlsx b/TestCases/Data/CSV/DEMAND_TEST_FILL_CLOSEST.xlsx deleted file mode 100644 index aa74e91e..00000000 Binary files a/TestCases/Data/CSV/DEMAND_TEST_FILL_CLOSEST.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/Demand_homemade.xlsx b/TestCases/Data/CSV/Demand_homemade.xlsx new file mode 100644 index 00000000..c791755e Binary files /dev/null and b/TestCases/Data/CSV/Demand_homemade.xlsx differ diff --git a/TestCases/Data/CSV/Results/pairs.xlsx b/TestCases/Data/CSV/Results/pairs.xlsx new file mode 100644 index 00000000..7d317e02 Binary files /dev/null and b/TestCases/Data/CSV/Results/pairs.xlsx differ diff --git a/TestCases/Data/CSV/Results/test_demand_IFS_result1.xlsx b/TestCases/Data/CSV/Results/test_demand_IFS_result1.xlsx new file mode 100644 index 00000000..0889811e Binary files /dev/null and b/TestCases/Data/CSV/Results/test_demand_IFS_result1.xlsx differ diff --git a/TestCases/Data/CSV/Results/test_supply_IFC_result1.xlsx b/TestCases/Data/CSV/Results/test_supply_IFC_result1.xlsx new file mode 100644 index 00000000..39b8554d Binary files /dev/null and b/TestCases/Data/CSV/Results/test_supply_IFC_result1.xlsx differ diff --git a/TestCases/Data/CSV/SUPPLY_DATAFRAME_SVERRE.xlsx b/TestCases/Data/CSV/SUPPLY_DATAFRAME_SVERRE.xlsx deleted file mode 100644 index 1099bb5f..00000000 Binary files a/TestCases/Data/CSV/SUPPLY_DATAFRAME_SVERRE.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/Supply_homemade.xlsx b/TestCases/Data/CSV/Supply_homemade.xlsx new file mode 100644 index 00000000..6a6705e7 Binary files /dev/null and b/TestCases/Data/CSV/Supply_homemade.xlsx differ diff --git a/TestCases/Data/CSV/basic_study_demand.csv b/TestCases/Data/CSV/basic_study_demand.csv deleted file mode 100644 index 491d743f..00000000 --- a/TestCases/Data/CSV/basic_study_demand.csv +++ /dev/null @@ -1,11 +0,0 @@ -,Length,Area,Moment of Inertia,Material,Manufacturer,Latitude,Longitude -0,1.71,0.2925330207236583,0.0071312973511423565,Timber,0,0,0 -1,9.97,0.21529626993272144,0.003862706987245271,Timber,0,0,0 -2,2.17,0.00164,5.41e-06,Steel,0,0,0 -3,7.26,0.00201,8.69e-06,Steel,0,0,0 -4,2.1,0.21469647897990823,0.0038412148405308484,Timber,0,0,0 -5,1.01,0.25682546745733664,0.00549661006122329,Timber,0,0,0 -6,9.42,0.1610644146760936,0.0021618121395793857,Timber,0,0,0 -7,1.15,0.2528931772898338,0.005329579926645608,Timber,0,0,0 -8,3.04,0.15339866877720243,0.0019609292985514884,Timber,0,0,0 -9,5.25,0.00103,1.71e-06,Steel,0,0,0 diff --git a/TestCases/Data/CSV/basic_study_supply.csv b/TestCases/Data/CSV/basic_study_supply.csv deleted file mode 100644 index 0585ce3c..00000000 --- a/TestCases/Data/CSV/basic_study_supply.csv +++ /dev/null @@ -1,11 +0,0 @@ -,Length,Area,Moment of Inertia,Material,Location,Latitude,Longitude -0,9.28,0.00334,2.77e-05,Steel,Gjovik,60.8941,10.5001 -1,8.19,0.1893479330549463,0.0029877199793483683,Timber,Storlien,63.3160,12.1018 -2,9.33,0.2304234887844403,0.004424582015299424,Timber,Storlien,63.3160,12.1018 -3,8.3,0.29273287747622845,0.007141044796292715,Timber,Tiller,63.3604,10.4008 -4,1.39,0.2871966376449907,0.006873492389549007,Timber,Gjovik,60.8941,10.5001 -5,2.82,0.1693910127884734,0.0023911096011253966,Timber,Orkanger,63.3000,9.8468 -6,3.3,0.00334,2.77e-05,Steel,Gjovik,60.8941,10.5001 -7,7.83,0.16110170464648693,0.002162813270000326,Timber,Gjovik,60.8941,10.5001 -8,9.65,0.25253643604463827,0.005314554294177307,Timber,Tiller,63.3604,10.4008 -9,3.54,0.00239,1.32e-05,Steel,Orkanger,63.3000,9.8468 diff --git a/TestCases/Data/CSV/bool_array.xlsx b/TestCases/Data/CSV/bool_array.xlsx new file mode 100644 index 00000000..f7c8a66c Binary files /dev/null and b/TestCases/Data/CSV/bool_array.xlsx differ diff --git a/TestCases/Data/CSV/bool_array1.xlsx b/TestCases/Data/CSV/bool_array1.xlsx new file mode 100644 index 00000000..86174067 Binary files /dev/null and b/TestCases/Data/CSV/bool_array1.xlsx differ diff --git a/TestCases/Data/CSV/con_new_demand.xlsx b/TestCases/Data/CSV/con_new_demand.xlsx deleted file mode 100644 index 31aa085c..00000000 Binary files a/TestCases/Data/CSV/con_new_demand.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/con_new_supply.xlsx b/TestCases/Data/CSV/con_new_supply.xlsx deleted file mode 100644 index 0a411c28..00000000 Binary files a/TestCases/Data/CSV/con_new_supply.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/conference_demand.xlsx b/TestCases/Data/CSV/conference_demand.xlsx deleted file mode 100644 index 6b6e863a..00000000 Binary files a/TestCases/Data/CSV/conference_demand.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/conference_supply.xlsx b/TestCases/Data/CSV/conference_supply.xlsx deleted file mode 100644 index 8a96fdbc..00000000 Binary files a/TestCases/Data/CSV/conference_supply.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/gh_demand.csv b/TestCases/Data/CSV/gh_demand.csv deleted file mode 100644 index 06dc2e6a..00000000 --- a/TestCases/Data/CSV/gh_demand.csv +++ /dev/null @@ -1,11 +0,0 @@ -,Length,Area,Moment of Inertia,Material,Manufacturer,Latitude,Longitude -0,3.64,0.00103,1.71e-06,Steel,0,0,0 -1,4.85,0.00334,2.77e-05,Steel,0,0,0 -2,1.85,0.00334,2.77e-05,Steel,0,0,0 -3,2.48,0.2702056869206727,0.006084259437022716,Timber,0,0,0 -4,5.07,0.22091162218958293,0.004066828734869419,Timber,0,0,0 -5,8.34,0.26060398397918644,0.005659536372152004,Timber,0,0,0 -6,9.54,0.00103,1.71e-06,Steel,0,0,0 -7,6.72,0.27548075638237124,0.006324137261416948,Timber,0,0,0 -8,1.16,0.16669348813246831,0.0023155599154807793,Timber,0,0,0 -9,6.06,0.18396420392348284,0.002820235693766732,Timber,0,0,0 diff --git a/TestCases/Data/CSV/gh_supply.csv b/TestCases/Data/CSV/gh_supply.csv deleted file mode 100644 index cea79b1a..00000000 --- a/TestCases/Data/CSV/gh_supply.csv +++ /dev/null @@ -1,11 +0,0 @@ -,Length,Area,Moment of Inertia,Material,Location,Latitude,Longitude -0,1.61,0.00201,8.69e-06,Steel,Orkanger,63.3000,9.8468 -1,6.91,0.00239,1.32e-05,Steel,Tiller,63.3604,10.4008 -2,1.43,0.00103,1.71e-06,Steel,Storlien,63.3160,12.1018 -3,5.97,0.21944709548302138,0.004013085642994525,Timber,Orkanger,63.3000,9.8468 -4,3.34,0.00538,8.36e-05,Steel,Storlien,63.3160,12.1018 -5,7.06,0.00239,1.32e-05,Steel,Tiller,63.3604,10.4008 -6,3.6,0.1960950863738674,0.0032044402416645437,Timber,Gjovik,60.8941,10.5001 -7,2.17,0.00538,8.36e-05,Steel,Tiller,63.3604,10.4008 -8,7.31,0.22390606004317304,0.004177826977004751,Timber,Storlien,63.3160,12.1018 -9,1.42,0.00538,8.36e-05,Steel,Tiller,63.3604,10.4008 diff --git a/TestCases/Data/CSV/master_thesis_demand.xlsx b/TestCases/Data/CSV/master_thesis_demand.xlsx deleted file mode 100644 index 1fb7e0ea..00000000 Binary files a/TestCases/Data/CSV/master_thesis_demand.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/master_thesis_supply.xlsx b/TestCases/Data/CSV/master_thesis_supply.xlsx deleted file mode 100644 index 19651c07..00000000 Binary files a/TestCases/Data/CSV/master_thesis_supply.xlsx and /dev/null differ diff --git a/TestCases/Data/CSV/pairs1.xlsx b/TestCases/Data/CSV/pairs1.xlsx new file mode 100644 index 00000000..637e189a Binary files /dev/null and b/TestCases/Data/CSV/pairs1.xlsx differ diff --git a/TestCases/Data/CSV/test_demand.csv b/TestCases/Data/CSV/test_demand.csv new file mode 100644 index 00000000..c63e58fd --- /dev/null +++ b/TestCases/Data/CSV/test_demand.csv @@ -0,0 +1,5 @@ +,Length,Width,Height,Area,Moment of Inertia,Material,Manufacturer,Latitude,Longitude +0,0,2.0,2.0,0,0,Timber,0,0,0 +0,0,1.0,1.0,0,0,Timber,0,0,0 +0,0,2.5,2.0,0,0,Timber,0,0,0 +0,0,1.0,2.0,0,0,Timber,0,0,0 diff --git a/TestCases/Data/CSV/test_demand.xlsx b/TestCases/Data/CSV/test_demand.xlsx new file mode 100644 index 00000000..7216158f Binary files /dev/null and b/TestCases/Data/CSV/test_demand.xlsx differ diff --git a/TestCases/Data/CSV/test_demand_IFC.xlsx b/TestCases/Data/CSV/test_demand_IFC.xlsx new file mode 100644 index 00000000..216eff38 Binary files /dev/null and b/TestCases/Data/CSV/test_demand_IFC.xlsx differ diff --git a/TestCases/Data/CSV/test_demand_IFS_result.csv b/TestCases/Data/CSV/test_demand_IFS_result.csv new file mode 100644 index 00000000..db856091 --- /dev/null +++ b/TestCases/Data/CSV/test_demand_IFS_result.csv @@ -0,0 +1,11 @@ +,Guid,Element,Material&Quality,Material,Quality,Length,Height,Width,Area,Volume,Moment of Inertia,Profile,Density,Site_lat,Site_lon,Gwp_factor,Price,Distance,Score,Transportation,Price element,GWP element +D0,"#5151=IfcSlab('33as9O3zjEnAsHHJOULX_B',#20,'Floor:HD-265:1393736',$,'Floor:HD-265',#5110,#5150,'1393736',.FLOOR.)",IfcSlab,Concrete - B35,Concrete,35,35.06,0.27,11.66,3.1482,110.37589200000001,0.019125315000000004,0.0,491,59.94161606,10.72994518,400.0,435,,44150.3568,0.0,48013.513020000006,44150.3568 +D1,"#5202=IfcBeam('33as9O3zjEnAsHHJOULXyg',#20,'Beam IPE:IPE 270:1393897',$,'Beam IPE:IPE 270',#5185,#5201,'1393897')",IfcBeam,Steel - S355,Steel,355,34.67,0.27,0.13,0.035100000000000006,1.2169170000000002,0.00021323250000000003,IPE 270,100,59.94161606,10.72994518,9263.0,6700,,11272.302171000003,0.0,8153.343900000002,11272.302171000003 +D2,"#5267=IfcBeam('33as9O3zjEnAsHHJOULXxA',#20,'Beam IPE:IPE 270:1393929',$,'Beam IPE:IPE 270',#5254,#5266,'1393929')",IfcBeam,Steel - S355,Steel,355,34.67,0.27,0.13,0.035100000000000006,1.2169170000000002,0.00021323250000000003,IPE 270,100,59.94161606,10.72994518,9263.0,6700,,11272.302171000003,0.0,8153.343900000002,11272.302171000003 +D3,"#5294=IfcBeam('33as9O3zjEnAsHHJOULXxO',#20,'Beam IPE:IPE 270:1393947',$,'Beam IPE:IPE 270',#5281,#5293,'1393947')",IfcBeam,Steel - S355,Steel,355,11.27,0.27,0.13,0.035100000000000006,0.39557700000000007,0.00021323250000000003,IPE 270,100,59.94161606,10.72994518,9263.0,6700,,3664.2297510000008,0.0,2650.3659000000002,3664.2297510000008 +D4,"#7660=IfcSlab('2I9WHjl$58$uOG2hQYWWMS',#20,'Punktfundament:F4:1408628',$,'Punktfundament:F4',#7650,#7659,'1408628',.BASESLAB.)",IfcSlab,Concrete - B35,Concrete,35,2.0,2.0,2.0,4.0,8.0,1.3333333333333333,0.0,491,59.94161606,10.72994518,400.0,435,,3200.0,0.0,3480.0,3200.0 +D5,"#7691=IfcSlab('2I9WHjl$58$uOG2hQYWWMU',#20,'Punktfundament:F3:1408630',$,'Punktfundament:F3',#7681,#7690,'1408630',.BASESLAB.)",IfcSlab,Concrete - B35,Concrete,35,2.0,2.0,2.0,4.0,8.0,1.3333333333333333,0.0,491,59.94161606,10.72994518,400.0,435,,3200.0,0.0,3480.0,3200.0 +D6,"#8453=IfcSlab('2r6pcFq511UeZXcuDB_GrX',#20,'Floor:Lettak-element:1412380',$,'Floor:Lettak-element',#8439,#8452,'1412380',.FLOOR.)",IfcBeam,Timber - C24,Timber,24,35.3,0.4,0.4,0.16000000000000003,5.648000000000001,0.002133333333333334,0.0,200,59.94161606,10.72994518,15.0,100,,84.72000000000001,0.0,564.8000000000001,84.72000000000001 +D7,"#7660=IfcSlab('2I9WHjl$58$uOG2hQYWWMS',#20,'Punktfundament:F4:1408628',$,'Punktfundament:F4',#7650,#7659,'1408628',.BASESLAB.)",IfcDoor,Door,Door,1,1.0,1.5,1.0,1.5,1.5,0.28125,0.0,200,59.94161606,10.72994518,10.0,250,,15.0,0.0,375.0,15.0 +D8,"#7691=IfcSlab('2I9WHjl$58$uOG2hQYWWMU',#20,'Punktfundament:F3:1408630',$,'Punktfundament:F3',#7681,#7690,'1408630',.BASESLAB.)",IfcDoor,Door,Door,1,1.0,1.5,1.0,1.5,1.5,0.28125,0.0,200,59.94161606,10.72994518,10.0,250,,15.0,0.0,375.0,15.0 +D9,"#8453=IfcSlab('2r6pcFq511UeZXcuDB_GrX',#20,'Floor:Lettak-element:1412380',$,'Floor:Lettak-element',#8439,#8452,'1412380',.FLOOR.)",IfcWindow,Window,Window,1,1.0,1.0,1.0,1.0,1.0,0.08333333333333333,0.0,491,59.94161606,10.72994518,28.9,435,,28.9,0.0,435.0,28.9 diff --git a/TestCases/Data/CSV/test_demand_IFS_result1.xlsx b/TestCases/Data/CSV/test_demand_IFS_result1.xlsx new file mode 100644 index 00000000..5cc64bdf Binary files /dev/null and b/TestCases/Data/CSV/test_demand_IFS_result1.xlsx differ diff --git a/TestCases/Data/CSV/test_supply.csv b/TestCases/Data/CSV/test_supply.csv new file mode 100644 index 00000000..4994b221 --- /dev/null +++ b/TestCases/Data/CSV/test_supply.csv @@ -0,0 +1,5 @@ +,Length,Width,Height,Area,Moment of Inertia,Material,Manufacturer,Latitude,Longitude +0,0,1.0,1.0,0,0,Timber,10,10,10 +0,0,1.0,1.0,0,0,Timber,10,10,10 +0,0,2.5,2.0,0,0,Timber,10,10,10 +0,0,1.0,2.0,0,0,Timber,10,10,10 diff --git a/TestCases/Data/CSV/test_supply.xlsx b/TestCases/Data/CSV/test_supply.xlsx new file mode 100644 index 00000000..3c1730a8 Binary files /dev/null and b/TestCases/Data/CSV/test_supply.xlsx differ diff --git a/TestCases/Data/CSV/test_supply_IFC.xlsx b/TestCases/Data/CSV/test_supply_IFC.xlsx new file mode 100644 index 00000000..85711a35 Binary files /dev/null and b/TestCases/Data/CSV/test_supply_IFC.xlsx differ diff --git a/TestCases/Data/CSV/test_supply_IFC_result.csv b/TestCases/Data/CSV/test_supply_IFC_result.csv new file mode 100644 index 00000000..3bada9a0 --- /dev/null +++ b/TestCases/Data/CSV/test_supply_IFC_result.csv @@ -0,0 +1,11 @@ +,Guid,Element,Material&Quality,Material,Quality,Length,Height,Width,Area,Volume,Moment of Inertia,Profile,Density,Site_lat,Site_lon,Gwp_factor,Price,Distance,Score,Transportation,Price element,GWP element +S0,"#5151=IfcSlab('33as9O3zjEnAsHHJOULX_B',#20,'Floor:HD-265:1393736',$,'Floor:HD-265',#5110,#5150,'1393736',.FLOOR.)",IfcSlab,Concrete - B35,Concrete ,35,35.06,0.27,11.66,3.1482,110.37589200000001,0.019125315000000004,0.0,491,59.94161606,10.72994518,100.0,100,,11037.5892,0.0,11037.5892,11037.5892 +S1,"#5267=IfcBeam('33as9O3zjEnAsHHJOULXxA',#20,'Beam IPE:IPE 270:1393929',$,'Beam IPE:IPE 270',#5254,#5266,'1393929')",IfcBeam,Steel - S355,Steel,355,10.0,0.27,0.13,0.035100000000000006,0.3510000000000001,0.00021323250000000003,IPE 270,100,59.94161606,10.72994518,200.0,6700,,70.20000000000002,0.0,2351.7000000000007,70.20000000000002 +S2,"#5202=IfcBeam('33as9O3zjEnAsHHJOULXyg',#20,'Beam IPE:IPE 270:1393897',$,'Beam IPE:IPE 270',#5185,#5201,'1393897')",IfcBeam,Steel - S355,Steel,355,34.67,0.27,0.13,0.035100000000000006,1.2169170000000002,0.00021323250000000003,IPE 270,100,59.94161606,10.72994518,200.0,6700,,243.38340000000005,0.0,8153.343900000002,243.38340000000005 +S3,"#5294=IfcBeam('33as9O3zjEnAsHHJOULXxO',#20,'Beam IPE:IPE 270:1393947',$,'Beam IPE:IPE 270',#5281,#5293,'1393947')",IfcBeam,Steel - S355,Steel,355,11.27,0.27,0.13,0.035100000000000006,0.39557700000000007,0.00021323250000000003,IPE 270,100,59.94161606,10.72994518,200.0,6700,,79.11540000000001,0.0,2650.3659000000002,79.11540000000001 +S4,"#7660=IfcSlab('2I9WHjl$58$uOG2hQYWWMS',#20,'Punktfundament:F4:1408628',$,'Punktfundament:F4',#7650,#7659,'1408628',.BASESLAB.)",IfcSlab,Concrete - B35,Concrete,35,2.0,2.0,2.0,4.0,8.0,1.3333333333333333,0.0,491,59.94161606,10.72994518,100.0,100,,800.0,0.0,800.0,800.0 +S5,"#7691=IfcSlab('2I9WHjl$58$uOG2hQYWWMU',#20,'Punktfundament:F3:1408630',$,'Punktfundament:F3',#7681,#7690,'1408630',.BASESLAB.)",IfcSlab,Concrete - B35,Concrete,35,2.0,2.0,2.0,4.0,8.0,1.3333333333333333,0.0,491,59.94161606,10.72994518,100.0,100,,800.0,0.0,800.0,800.0 +S6,"#8453=IfcSlab('2r6pcFq511UeZXcuDB_GrX',#20,'Floor:Lettak-element:1412380',$,'Floor:Lettak-element',#8439,#8452,'1412380',.FLOOR.)",IfcBeam,Timber - C24,Timber,24,35.3,0.4,0.4,0.16000000000000003,5.648000000000001,0.002133333333333334,0.0,200,59.94161606,10.72994518,1.5,70,,8.472000000000001,0.0,395.36,8.472000000000001 +S7,"#7660=IfcSlab('2I9WHjl$58$uOG2hQYWWMS',#20,'Punktfundament:F4:1408628',$,'Punktfundament:F4',#7650,#7659,'1408628',.BASESLAB.)",IfcDoor,Door,Door,1,1.0,2.0,1.0,2.0,2.0,0.6666666666666666,0.0,200,59.94161606,10.72994518,3.0,80,,6.0,0.0,160.0,6.0 +S8,"#7691=IfcSlab('2I9WHjl$58$uOG2hQYWWMU',#20,'Punktfundament:F3:1408630',$,'Punktfundament:F3',#7681,#7690,'1408630',.BASESLAB.)",IfcDoor,Door,Door,1,1.0,1.5,1.0,1.5,1.5,0.28125,0.0,200,59.94161606,10.72994518,3.0,80,,4.5,0.0,120.0,4.5 +S9,"#8453=IfcSlab('2r6pcFq511UeZXcuDB_GrX',#20,'Floor:Lettak-element:1412380',$,'Floor:Lettak-element',#8439,#8452,'1412380',.FLOOR.)",IfcWindow,Window,Window,1,1.0,1.0,1.0,1.0,1.0,0.08333333333333333,0.0,491,59.94161606,10.72994518,2.25,100,,2.25,0.0,100.0,2.25 diff --git a/TestCases/Data/CSV/test_supply_IFC_result1.xlsx b/TestCases/Data/CSV/test_supply_IFC_result1.xlsx new file mode 100644 index 00000000..87f17552 Binary files /dev/null and b/TestCases/Data/CSV/test_supply_IFC_result1.xlsx differ diff --git a/TestCases/study_case_gh1.py b/TestCases/study_case_gh1.py new file mode 100644 index 00000000..7fb91a5d --- /dev/null +++ b/TestCases/study_case_gh1.py @@ -0,0 +1,101 @@ +import sys +sys.path.append('./Matching') +from matching import Matching +import pandas as pd +import numpy as np +import sys +import helper_methods_LCA as lca +import helper_methods as hm +import helper_methods_PDF as hmpdf +from matching import run_matching +# read input argument from console +#NOTE TO SVERRE: DONT KNOW IF THIS IS NEEDED? +""" +method_name = sys.argv[1] +demand_path = sys.argv[2] +supply_path = sys.argv[3] +result_path = sys.argv[4] +constraint_string = sys.argv[5] +""" +###################### + +#==========USER FILLS IN============# +#Constants +#TODO: FIND ALL DEFAULT VALUES FOR CONSTANTS, especially for price +constants = { + "TIMBER_GWP": 28.9, # based on NEPD-3442-2053-EN + "TIMBER_REUSE_GWP": 2.25, # 0.0778*28.9 = 2.25 based on Eberhardt + "TRANSPORT_GWP": 96.0, # TODO kg/m3/t based on ???? + "TIMBER_DENSITY": 491.0, # kg, based on NEPD-3442-2053-EN + "STEEL_GWP": 800, #Random value + "STEEL_REUSE_GWP": 4, #Random value + "VALUATION_GWP": 0.6, #In kr:Per kg CO2, based on OECD + "TIMBER_PRICE": 435, #Per m^3 https://www.landkredittbank.no/blogg/2021/prisen-pa-sagtommer-okte-20-prosent/ + "TIMBER_REUSE_PRICE" : 100, #Per m^3, Random value + "STEEL_PRICE": 500, #Per m^2, Random value + "STEEL_REUSE_PRICE": 200, #Per m^2, Random value + "PRICE_TRANSPORTATION": 3.78, #Price per km per tonn. Derived from 2011 numbers on scaled t0 2022 using SSB + "STEEL_DENSITY": 7850, + ######################## + "Project name": "Sognsveien 17", + "Metric": "GWP", + "Algorithms": ["bipartite", "greedy_plural", "bipartite_plural", "bipartite_plural_multiple"], + "Include transportation": False, + "Site latitude": "59.94161606", + "Site longitude": "10.72994518", + #"Demand file location": r"./TestCases/Data/CSV/test_demand.xlsx", + #"Supply file location": r"./TestCases/Data/CSV/test_supply.xlsx", + "Demand file location": r"./TestCases/Data/CSV/gh_demand.csv", + "Supply file location": r"./TestCases/Data/CSV/gh_supply.csv", + #"constraint_dict": {'Area' : '>=', 'Moment of Inertia' : '>=', 'Length' : '>=', 'Width' : '>=', 'Height' : '>=', 'Material': '=='} + "constraint_dict": {'Width' : '>=', 'Height' : '>='} +} +#========================# +#Generating dataset +#=================== +supply_coords = pd.DataFrame(columns = ["Location", "Latitude", "Longitude"]) + +tiller = ["Tiller", "63.3604", "10.4008"] +gjovik = ["Gjovik", "60.8941", "10.5001"] +orkanger = ["Orkanger", "63.3000", "9.8468"] +storlien = ["Storlien", "63.3160", "12.1018"] + +supply_coords.loc[len(supply_coords)] = tiller +supply_coords.loc[len(supply_coords)] = gjovik +supply_coords.loc[len(supply_coords)] = orkanger +supply_coords.loc[len(supply_coords)] = storlien + + + +materials = ["Timber", "Steel"] + +#GENERATE FILE +#============ +supply = hmpdf.create_random_data_supply_pdf_reports(supply_count = 10, length_min = 1.0, length_max = 10.0, width_min = 1.0, width_max = 10.0, height_min = 1.0, height_max = 10.0, area_min = 0.15, area_max = 0.30, materials = materials, supply_coords = supply_coords) +demand = hmpdf.create_random_data_demand_pdf_reports(demand_count = 10, length_min = 1.0, length_max = 10.0, width_min = 1.0, width_max = 10.0, height_min = 1.0, height_max = 10.0, area_min = 0.15, area_max = 0.30, materials = materials) +hm.export_dataframe_to_csv(supply, r"" + "./TestCases/Data/CSV/gh_supply.csv") +hm.export_dataframe_to_csv(demand, r"" + "./TestCases/Data/CSV/gh_demand.csv") + +#======================================== +score_function_string = hm.generate_score_function_string(constants) +supply = hm.import_dataframe_from_file(r"" + constants["Supply file location"], index_replacer = "S") +demand = hm.import_dataframe_from_file(r"" + constants["Demand file location"], index_replacer = "D") + +#hm.create_graph(supply, demand, "Length", number_of_intervals= 2, save_filename = r"C:\Users\sigur\Downloads\test.png") + +constraint_dict = constants["constraint_dict"] +#Add necessary columns to run the algorithm +supply = hmpdf.add_necessary_columns_pdf(supply, constants) +demand = hmpdf.add_necessary_columns_pdf(demand, constants) +run_string = hm.generate_run_string(constants) +result_simple = eval(run_string) + +simple_pairs = hm.extract_pairs_df(result_simple) +simple_results = hm.extract_results_df(result_simple, constants["Metric"]) + +print("Simple pairs:") +print(simple_pairs) + +print() +print("Simple results") +print(simple_results) \ No newline at end of file diff --git a/TestCases/study_case_gh2.py b/TestCases/study_case_gh2.py new file mode 100644 index 00000000..b24ecbeb --- /dev/null +++ b/TestCases/study_case_gh2.py @@ -0,0 +1,225 @@ +import sys +sys.path.append('./app/matchingTool/src/Matching') +from matching import Matching +import pandas as pd +import numpy as np +import sys +import helper_methods_LCA as lca +import helper_methods as hm +import helper_methods_PDF as hmpdf +from matching import run_matching +# read input argument from console +#NOTE TO SVERRE: DONT KNOW IF THIS IS NEEDED? +""" +method_name = sys.argv[1] +demand_path = sys.argv[2] +supply_path = sys.argv[3] +result_path = sys.argv[4] +constraint_string = sys.argv[5] +""" +###################### + +#==========USER FILLS IN============# +#Constants +#TODO: FIND ALL DEFAULT VALUES FOR CONSTANTS, especially for price +constants = { + + + "WINDOW_GWP": 28.9, + "WINDOW_REUSE_GWP": 2.25, + "WINDOW_DENSITY": 491.0, + "WINDOW_PRICE": 435, + "WINDOW_REUSE_PRICE" : 100, + + "DOOR_GWP": 10, + "DOOR_REUSE_GWP": 3, + "DOOR_DENSITY": 200, + "DOOR_PRICE": 250, + "DOOR_REUSE_PRICE" : 80, + + "TIMBER_GWP": 15, # based on NEPD-3442-2053-EN + "TIMBER_REUSE_GWP": 1.5, # 0.0778*28.9 = 2.25 based on Eberhardt + "TIMBER_DENSITY": 200, # kg, based on NEPD-3442-2053-EN + "TIMBER_PRICE": 100, #Per m^3 https://www.landkredittbank.no/blogg/2021/prisen-pa-sagtommer-okte-20-prosent/ + "TIMBER_REUSE_PRICE" : 70, #Per m^3, Random value + + "CONCRETE_GWP": 400, + "CONCRETE_DENSITY": 491.0, + "CONCRETE_PRICE": 435, + "CONCRETE_REUSE_PRICE" : 100, + "CONCRETE_REUSE_GWP": 100, + + "N/A_GWP": 400, + "N/A_DENSITY": 491.0, + "N/A_PRICE": 435, + "N/A_REUSE_PRICE" : 100, + "N/A_REUSE_GWP": 100, + + "STEEL_GWP": 9263, # [kg CO2 pr m^3] Taken from Trine and Elise + "STEEL_REUSE_GWP": 200, #[kg CO2 pr m^3] Taken from Trine and Elise + "STEEL_PRICE": 6, #[NOK pr m^3] Taken from Trine and Elise + "STEEL_REUSE_PRICE": 67, #[NOK pr m^3] Taken from Trine and Elise + "STEEL_DENSITY": 100, #[kg pr m^3] Taken from Trine and Elise + + "VALUATION_GWP": 0.7, #In kr:Per kg CO2, based on OECD + "PRICE_TRANSPORTATION": 4, #Price per km per tonn. Derived from 2011 numbers on scaled t0 2022 using SSB + "TRANSPORT_GWP": 81, # TODO kg/m3/t based on ???? + "Price" : 100, + + + + ######################## + "Project name": "Sognsveien 17", + "Metric": "GWP", + #"Algorithms": ["bipartite", "greedy_plural", "bipartite_plural", "bipartite_plural_multiple"], + "Algorithms": ["greedy_plural"], + "Include transportation": False, + "Site latitude": "59.94161606", + "Site longitude": "10.72994518", + "Demand file location": r"./app/matchingTool/src/TestCases/Data/CSV/Demand_homemade.xlsx", + "Supply file location": r"./app/matchingTool/src/TestCases/Data/CSV/Supply_homemade.xlsx", + #"Demand file location": r"./app/matchingTool/src/TestCases/Data/CSV/test_demand_IFC.csv", + #"Supply file location": r"./app/matchingTool/src/TestCases/Data/CSV/test_supply_IFC.csv", + + "tol_1D_area" : "0.9", + "tol_1D_moment_of_inertia" : "0.9", + "tol_1D_length" : "0.9", + "tol_1D_width" : "0.9", + "tol_1D_height" : "0.9", + "tol_1D_quality" : "0.9", + + "tol_2D_width" : "0.9", + "tol_2D_height" : "0.9", + "tol_2D_quality" : "0.9", + + "tol_3D_length" : "0.9", + "tol_3D_width" : "0.9", + "tol_3D_height" : "0.9", + "tol_3D_quality" : "0.9", + + "constraint_dict": {'Area' : '>=', 'Iy e-6' : '>=', 'Length' : '>=', 'Width' : '>=', 'Height' : '>=', 'Material': '==', 'Quality' : '>='}, + "constraint2D_dict" : {'Width' : '==', 'Height' : '==', 'Material' : '==', 'Quality' : '>='}, + "constraint3D_dict" : {'Length' : '>=','Width' : '==', 'Height' : '==', 'Material' : '==', 'Quality' : '>='}, + + "Name" : {"Timber", "Steel", "Window", "Door", "Slab", "Concrete - B35", "Steel - S355", "Steel - S235"}, + "element_linear" : {"IfcBeam", "IfcColumn"}, + "element_2d" : {"IfcWindow", "IfcDoor"}, + "element_3d" : {"IfcSlab"} +} +#========================# +#Generating dataset +#=================== +supply_coords = pd.DataFrame(columns = ["Location", "Latitude", "Longitude"]) + + +tiller = ["Tiller", "63.3604", "10.4008"] +gjovik = ["Gjovik", "60.8941", "10.5001"] +orkanger = ["Orkanger", "63.3000", "9.8468"] +storlien = ["Storlien", "63.3160", "12.1018"] + +supply_coords.loc[len(supply_coords)] = tiller +supply_coords.loc[len(supply_coords)] = gjovik +supply_coords.loc[len(supply_coords)] = orkanger +supply_coords.loc[len(supply_coords)] = storlien + + + + + + +#GENERATE FILE +#============ +"""supply = hmpdf.create_random_data_supply_pdf_reports(supply_count = 10, length_min = 1.0, length_max = 10.0, width_min = 1.0, width_max = 10.0, height_min = 1.0, height_max = 10.0, area_min = 0.15, area_max = 0.30, materials = materials, supply_coords = supply_coords) +demand = hmpdf.create_random_data_demand_pdf_reports(demand_count = 10, length_min = 1.0, length_max = 10.0, width_min = 1.0, width_max = 10.0, height_min = 1.0, height_max = 10.0, area_min = 0.15, area_max = 0.30, materials = materials) +hm.export_dataframe_to_csv(supply, r"" + "./TestCases/Data/CSV/test_supply.csv") +hm.export_dataframe_to_csv(demand, r"" + "./TestCases/Data/CSV/test_demand.csv") +""" +#======================================== +score_function_string = hm.generate_score_function_string(constants) +score_function_string_2d = hm.generate_score_function_string_2d(constants) + +supply = hm.import_dataframe_from_file(r"" + constants["Supply file location"], index_replacer = "S") +demand = hm.import_dataframe_from_file(r"" + constants["Demand file location"], index_replacer = "D") + +#hm.create_graph(supply, demand, "Length", number_of_intervals= 2, save_filename = r"C:\Users\sigur\Downloads\test.png") + +constraint_dict = constants["constraint_dict"] +constraint2D_dict = constants["constraint2D_dict"] +constraint3D_dict = constants["constraint3D_dict"] + + +#Add necessary columns to run the algorithm +supply = hmpdf.add_necessary_columns_pdf(supply, constants) +demand = hmpdf.add_necessary_columns_pdf(demand, constants) + + +m= Matching(demand, supply, score_function_string, score_function_string_2d, constants, constraints = constraint_dict, constraints2D = constraint2D_dict, constraints3D = constraint3D_dict, solution_limit=60) + +m.match_greedy(plural_assign=True) +simple_pairs = m.pairs +m.calculate_result() +simple_results = m.result +print("------------------------- Results -------------------------") +print("Weights matrix ") +print(m.weights) +print() +print("Algorithm used; " + ", ".join(constants["Algorithms"])) +print() +print("Simple pairs:") +print(simple_pairs) +print() +if (constants["Metric"] == "Price"): + print("Simple " + constants["Metric"] + " score;") +if (constants["Metric"] == "GWP"): + print("Simple " + constants["Metric"] + " score;") +if (constants["Metric"] == "Combined"): + print("Simple " + constants["Metric"] + " score;") +print(simple_results) + + + +#hm.export_dataframe_to_xlsx(pd.DataFrame(m.weights, r"" + "./app/matchingTool/src/TestCases/Data/CSV/Results/weights_before")) + +constants["Metric"] = "Price" +score_function_string = hm.generate_score_function_string(constants) +score_function_string = score_function_string.replace(" ", "") + + +if tuple(m.demand['Element'].tolist()) in constants["element_linear"] or tuple(m.demand['Element'].tolist()) in constants["element_3d"]: + m.demand['Price pr element'], m.demand['Transportation'] = m.demand.eval(m.score_function_string) +else: + m.demand['Price pr element'], m.demand['Transportation'] = m.demand.eval(m.score_function_string_2d) + +if tuple(m.supply['Element'].tolist()) in constants["element_linear"] or tuple(m.supply['Element'].tolist()) in constants["element_3d"]: + m.supply['Price pr element'], m.supply['Transportation'] = m.supply.eval(m.score_function_string) +else: + m.supply['Price pr element'], m.supply['Transportation'] = m.supply.eval(m.score_function_string_2d) + + +constants["Metric"] = "GWP" +score_function_string = hm.generate_score_function_string(constants) +score_function_string = score_function_string.replace(" ", "") + + +if tuple(m.demand['Element'].tolist()) in constants["element_linear"] or tuple(m.demand['Element'].tolist()) in constants["element_3d"]: + m.demand['GWP pr element'], m.demand['Transportation'] = m.demand.eval(m.score_function_string) +else: + m.demand['GWP pr element'], m.demand['Transportation'] = m.demand.eval(m.score_function_string_2d) + +if tuple(m.supply['Element'].tolist()) in constants["element_linear"] or tuple(m.supply['Element'].tolist()) in constants["element_3d"]: + m.supply['GWP pr element'], m.supply['Transportation'] = m.supply.eval(m.score_function_string) +else: + m.supply['GWP pr element'], m.supply['Transportation'] = m.supply.eval(m.score_function_string_2d) + + +#hm.export_dataframe_to_xlsx(m.weights, r"" + "./app/matchingTool/src/TestCases/Data/CSV/Results/weights") +hm.export_dataframe_to_xlsx(m.supply, r"" + "./app/matchingTool/src/TestCases/Data/CSV/Results/test_supply_IFC_result1.xlsx") +hm.export_dataframe_to_xlsx(m.demand, r"" + "./app/matchingTool/src/TestCases/Data/CSV/Results/test_demand_IFS_result1.xlsx") +hm.export_dataframe_to_xlsx(m.pairs, r"" + "./app/matchingTool/src/TestCases/Data/CSV/Results/pairs.xlsx") + + + + + +print(m.demand) +print(m.supply) \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 00000000..e69de29b