Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
Implements #10 Move the solver into a seperate assembly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Hughes committed Aug 6, 2015
1 parent e01c475 commit 72f1473
Show file tree
Hide file tree
Showing 42 changed files with 364 additions and 83 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 30 additions & 4 deletions src/Dyna Project.sln → Dyna Project.sln
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dyna.UI", "DynaApp\Dyna.UI.csproj", "{523D6D0B-595F-4C35-9F6C-C8BAAC322E2E}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dyna.UI", "src\DynaApp\Dyna.UI.csproj", "{523D6D0B-595F-4C35-9F6C-C8BAAC322E2E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dyna.UI.Tests.Unit", "..\tests\Dyna.UI.Tests.Unit\Dyna.UI.Tests.Unit.csproj", "{05262768-6951-40B3-B1E1-DB24C41ECB05}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dyna.UI.Tests.Unit", "tests\Dyna.UI.Tests.Unit\Dyna.UI.Tests.Unit.csproj", "{05262768-6951-40B3-B1E1-DB24C41ECB05}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{96D48A07-2470-4B66-8069-513ED49E58E0}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -14,9 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{96D48A
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dyna.UI.Tests.Integration", "..\tests\Dyna.UI.Tests.Integration\Dyna.UI.Tests.Integration.csproj", "{E1E117C3-891F-4727-B3B4-621EB417E3BF}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dyna.UI.Tests.Integration", "tests\Dyna.UI.Tests.Integration\Dyna.UI.Tests.Integration.csproj", "{E1E117C3-891F-4727-B3B4-621EB417E3BF}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Dyna.UI.Wix", "Dyna.UI.Wix\Dyna.UI.Wix.wixproj", "{A2337AC6-B32E-4D7E-A6D6-157415BEB0CC}"
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Dyna.UI.Wix", "src\Dyna.UI.Wix\Dyna.UI.Wix.wixproj", "{A2337AC6-B32E-4D7E-A6D6-157415BEB0CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dyna.Core", "src\Dyna.Core\Dyna.Core.csproj", "{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dyna.Core.Tests.Unit", "tests\Dyna.Core.Tests.Unit\Dyna.Core.Tests.Unit.csproj", "{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -74,6 +78,28 @@ Global
{A2337AC6-B32E-4D7E-A6D6-157415BEB0CC}.Release|Mixed Platforms.Build.0 = Release|x86
{A2337AC6-B32E-4D7E-A6D6-157415BEB0CC}.Release|x86.ActiveCfg = Release|x86
{A2337AC6-B32E-4D7E-A6D6-157415BEB0CC}.Release|x86.Build.0 = Release|x86
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Debug|x86.ActiveCfg = Debug|x86
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Debug|x86.Build.0 = Debug|x86
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Release|Any CPU.Build.0 = Release|Any CPU
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}.Release|x86.ActiveCfg = Release|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Debug|x86.ActiveCfg = Debug|x86
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Debug|x86.Build.0 = Debug|x86
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Release|Any CPU.Build.0 = Release|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B8A6ABDC-586B-434E-A9EE-2B922F8F6237}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
106 changes: 106 additions & 0 deletions src/Dyna.Core/Dyna.Core.csproj
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BDFDA6E8-2BB7-425E-AF10-47BCD2CC3DBC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Dyna.Core</RootNamespace>
<AssemblyName>Dyna.Core</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Google.OrTools">
<HintPath>..\..\Libs\or-tools.VisualStudio2013-32b\Google.OrTools.dll</HintPath>
</Reference>
<Reference Include="Sprache, Version=2.0.0.45, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Sprache.2.0.0.45\lib\portable-net4+netcore45+win8+wp8+sl5+MonoAndroid1+MonoTouch1\Sprache.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Entities\BinaryExpression.cs" />
<Compile Include="Entities\BoundVariable.cs" />
<Compile Include="Entities\Constraint.cs" />
<Compile Include="Entities\ConstraintGrammar.cs" />
<Compile Include="Entities\Domain.cs" />
<Compile Include="Entities\DomainGrammar.cs" />
<Compile Include="Entities\Expression.cs" />
<Compile Include="Entities\Literal.cs" />
<Compile Include="Entities\Model.cs" />
<Compile Include="Entities\ModelContext.cs" />
<Compile Include="Entities\OperatorType.cs" />
<Compile Include="Entities\RangeExpression.cs" />
<Compile Include="Entities\Solution.cs" />
<Compile Include="Entities\Variable.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Solver\ConstraintSolver.cs" />
<Compile Include="Solver\SolveResult.cs" />
<Compile Include="Solver\SolveStatus.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -1,6 +1,6 @@
using System;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// Expression tree of the constraint.
Expand Down
@@ -1,6 +1,6 @@
using System;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// A variable bound with a value.
Expand Down
@@ -1,6 +1,6 @@
using System;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// A constraint restricting a variable's possible bound values.
Expand Down
@@ -1,11 +1,11 @@
using Sprache;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// Grammar for parsing constraint expressions.
/// </summary>
class ConstraintGrammar
internal class ConstraintGrammar
{
/// <summary>
/// Parse an identifier.
Expand Down
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// A domain contains the possible values that a variable can be bound to.
Expand Down
Expand Up @@ -2,9 +2,9 @@
using System.Linq;
using Sprache;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
class DomainGrammar
internal class DomainGrammar
{
/// <summary>
/// Parse a band.
Expand Down
@@ -1,6 +1,6 @@
using System;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// An expression can either be a variable or literal.
Expand Down
@@ -1,6 +1,6 @@
using System;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
public class Literal
{
Expand Down
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// A model for specifying the problem.
Expand Down
@@ -1,6 +1,6 @@
using System;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// Fluent interface for building models.
Expand Down
@@ -1,4 +1,4 @@
namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// Operator type in a binary expression.
Expand Down
@@ -1,4 +1,4 @@
namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
public class RangeExpression
{
Expand Down
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
/// <summary>
/// A solution to a model.
Expand Down
@@ -1,6 +1,6 @@
using System;

namespace DynaApp.Entities
namespace Dyna.Core.Entities
{
public class Variable
{
Expand Down
36 changes: 36 additions & 0 deletions src/Dyna.Core/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Dyna.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Dyna.Core")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1bf2dc62-1c08-40bb-9458-0630a71df2c5")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using DynaApp.Entities;
using Dyna.Core.Entities;
using Google.OrTools.ConstraintSolver;
using Constraint = DynaApp.Entities.Constraint;
using Constraint = Dyna.Core.Entities.Constraint;

namespace DynaApp.Solver
namespace Dyna.Core.Solver
{
/// <summary>
/// Constraint solver.
/// </summary>
class ConstraintSolver
public class ConstraintSolver
{
private Google.OrTools.ConstraintSolver.Solver solver;
private readonly Dictionary<string, Tuple<Variable, IntVar>> variableMap = new Dictionary<string, Tuple<Variable, IntVar>>();
Expand Down
@@ -1,7 +1,7 @@
using System;
using DynaApp.Entities;
using Dyna.Core.Entities;

namespace DynaApp.Solver
namespace Dyna.Core.Solver
{
/// <summary>
/// The constraint model solution.
Expand Down
@@ -1,4 +1,4 @@
namespace DynaApp.Solver
namespace Dyna.Core.Solver
{
public enum SolveStatus
{
Expand Down
4 changes: 4 additions & 0 deletions src/Dyna.Core/packages.config
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Sprache" version="2.0.0.45" targetFramework="net45" />
</packages>
2 changes: 1 addition & 1 deletion src/Dyna.UI.Wix/Dyna.UI.Wix.wixproj
Expand Up @@ -27,7 +27,7 @@
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DynaApp\Dyna.UI.csproj">
<ProjectReference Include="..\..\src\DynaApp\Dyna.UI.csproj">
<Name>Dyna.UI</Name>
<Project>{523d6d0b-595f-4c35-9f6c-c8baac322e2e}</Project>
<Private>True</Private>
Expand Down

0 comments on commit 72f1473

Please sign in to comment.