Commits

Christian Dalager committed 4601a3f

Adding scheduler!

  • Participants
  • Parent commits 2c7c8b2

Comments (0)

Files changed (20)

CommunityDayPoll/App_Readme/MathNet.Numerics.authors.txt

+Math.NET Numerics Authors
+=========================
+
+* [Marcus Cuda](http://marcuscuda.com/): @cuda
+* [Jurgen Van Gael](http://mlg.eng.cam.ac.uk/jurgen/): @jvangael
+* [Christoph Rüegg](http://christoph.ruegg.name/): @cdrnet
+* [Andriy Bratiychuk](http://ua.linkedin.com/pub/andriy-bratiychuk/4/6b/920)
+
+Contributors
+------------
+* [Alexander Karatarakis](http://karatarakis.com/alex/)
+
+Other dnAnalytics Contributors
+------------------------------
+
+* Patrick van der Valde
+
+Other Math.NET Iridium Contributors
+-----------------------------------
+
+* [Joannès Vermorel](http://www.vermorel.com/)
+* Matthew Kitchin
+* Rana Ian
+* Andrew Kurochka
+* Thaddaeus Parker
+
+ALGLIB Contributors
+-------------------
+
+* [Sergey Bochkanov](http://www.alglib.net/)
+
+Boost Contributors
+------------------
+
+* John Maddock
+
+Cephes Math Library Contributors
+--------------------------------
+
+* Stephen L. Moshier

CommunityDayPoll/App_Readme/MathNet.Numerics.copyright.txt

+Math.NET Numerics License (MIT/X11)
+===================================
+
+Copyright (c) 2002-2011 Math.NET
+
+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.
+
+Other Copyrights
+================
+
+Portions of code are inspired by or derived from code
+covered by the following copyrights:
+
+ALGLIB
+------
+
+Any code from ALGLIB is from version 2.0.1 which is distributed 
+under the license below.
+
+Copyright (c) 2007, Sergey Bochkanov (ALGLIB project).
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+- Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer listed
+  in this license in the documentation and/or other materials
+  provided with the distribution.
+
+- Neither the name of the copyright holders nor the names of its
+  contributors may be used to endorse or promote products derived from
+  this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+BOOST
+-----
+
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+---
+
+ZLIB.NET  
+Copyright (c) 2006-2007, ComponentAce
+http://www.componentace.com
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without 
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this 
+list of conditions and the following disclaimer. 
+
+Redistributions in binary form must reproduce the above copyright notice, 
+this list of conditions and the following disclaimer in the documentation 
+and/or other materials provided with the distribution. 
+
+Neither the name of ComponentAce nor the names of its contributors 
+may be used to endorse or promote products derived from this software without 
+specific prior written permission. 
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 
+HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+OF SUCH DAMAGE.

CommunityDayPoll/App_Readme/MathNet.Numerics.readme.txt

+Math.NET Numerics
+=================
+
+Math.NET Numerics is an opensource **numerical library for .Net, Silverlight and Mono**.
+
+Math.NET Numerics is the numerical foundation of the Math.NET project,
+aiming to provide methods and algorithms for numerical computations in science,
+engineering and every day use. Covered topics include special functions,
+linear algebra, probability models, random numbers, interpolation,
+integral transforms (FFT) and more.
+
+Math.NET Numerics is the result of merging [dnAnalytics](http://dnanalytics.codeplex.com/)
+with [Math.NET Iridium](http://www.mathdotnet.com/Iridium.aspx) and is intended to
+replace both. It targets Microsoft .Net 4.0, Silverlight 4 and Mono,
+and in addition to purely managed implementations will also support
+native hardware optimization (MKL, ATLAS).
+
+Math.NET Numerics is covered under the terms of the [MIT/X11](http://mathnetnumerics.codeplex.com/license)
+license. You may therefore link to it and use it in both opensource and proprietary
+software projects. See also the [COPYRIGHT](COPYRIGHT.markdown) file in the root folder.
+
+Quick Links
+-----------
+
+* [**Project Website**](http://numerics.mathdotnet.com)
+* [News Blog](http://numerics.mathdotnet.com/blog/)
+* [Source Code](http://github.com/mathnet/mathnet-numerics)
+* [Downloads](http://mathnetnumerics.codeplex.com/Release/ProjectReleases.aspx)
+* [Discussions](http://mathnetnumerics.codeplex.com/discussions?ProjectName=mathnetnumerics)
+* [Work Items and Bug Tracker](http://mathnetnumerics.codeplex.com/workitem/list/advanced)
+* [Ideas & Feedback](http://feedback.mathdotnet.com)
+* Twitter: [@MathNetNumerics](http://twitter.com/MathNetNumerics)
+
+Installation Instructions
+-------------------------
+
+Download the *MathNet.Numerics.dll* assembly, add a reference to it to your project and you're done. To make this even simpler we publish binary releases to the [**NuGet Gallery**](http://nuget.org/) as package *MathNet.Numerics* (or *MathNet.Numerics.FSharp* for F# integration). Altenatively we also publish binary releases including documentation on [CodePlex](http://mathnetnumerics.codeplex.com/releases).
+
+Team & Contributors
+-------------------
+
+**Primary Authors**:
+[Marcus Cuda](http://marcuscuda.com/),
+[Jurgen Van Gael](http://mlg.eng.cam.ac.uk/jurgen/),
+[Christoph Rüegg](http://christoph.ruegg.name/),
+[Andriy Bratiychuk](http://ua.linkedin.com/pub/andriy-bratiychuk/4/6b/920)  
+**Contributors**:
+Alexander Karatarakis, Patrick van der Velde, Joannès Vermorel,
+Matthew Kitchin, Rana Ian, Andrew Kurochka,
+Thaddaeus Parker, Sergey Bochkanov (ALGLIB), John Maddock (Boost),
+Stephen L. Moshier (Cephes Math Library)
+
+See also the [AUTHORS](AUTHORS.markdown) file for a full list of all contributors.

CommunityDayPoll/CommunityDayPoll.csproj

     <Reference Include="EntityFramework">
       <HintPath>..\packages\EntityFramework.4.1.10331.0\lib\net40\EntityFramework.dll</HintPath>
     </Reference>
+    <Reference Include="MathNet.Numerics">
+      <HintPath>..\packages\MathNet.Numerics.2.1.2\lib\Net40\MathNet.Numerics.dll</HintPath>
+    </Reference>
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
       <Private>True</Private>
   <ItemGroup>
     <Compile Include="Controllers\HomeController.cs" />
     <Compile Include="Controllers\ResultsController.cs" />
+    <Compile Include="Controllers\ScheduleController.cs" />
     <Compile Include="Global.asax.cs">
       <DependentUpon>Global.asax</DependentUpon>
     </Compile>
+    <Compile Include="Models\Conference.cs" />
+    <Compile Include="Models\ConferenceScore.cs" />
+    <Compile Include="Models\Generator.cs" />
     <Compile Include="Models\PollResult.cs" />
+    <Compile Include="Models\PriorityScore.cs" />
+    <Compile Include="Models\RandomSwapGenerator.cs" />
+    <Compile Include="Models\ScheduleModel.cs" />
+    <Compile Include="Models\SimulatedAnnealing.cs" />
     <Compile Include="Models\Talk.cs" />
+    <Compile Include="Models\TalkInfo.cs" />
+    <Compile Include="Models\TalkOrderGenerator.cs" />
     <Compile Include="Models\TalkRepository.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <ItemGroup>
+    <Content Include="App_Readme\MathNet.Numerics.authors.txt" />
+    <Content Include="App_Readme\MathNet.Numerics.copyright.txt" />
+    <Content Include="App_Readme\MathNet.Numerics.readme.txt" />
     <Content Include="Content\images\cdlogo.jpg" />
     <Content Include="Content\images\preview.gif" />
     <Content Include="Content\themes\base\images\ui-bg_flat_0_aaaaaa_40x100.png" />
     <Content Include="Content\themes\base\jquery.ui.slider.css" />
     <Content Include="Content\themes\base\jquery.ui.tabs.css" />
     <Content Include="Content\themes\base\jquery.ui.theme.css" />
+    <Content Include="Data\Data.txt" />
     <Content Include="Global.asax" />
     <Content Include="Content\Site.css" />
     <Content Include="Scripts\communitydaypoll.js" />
   <ItemGroup>
     <Content Include="Views\Home\Index.cshtml" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="Views\Schedule\Index.cshtml" />
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

CommunityDayPoll/Content/Site.css

   .textcontent{ width: 310px;}
 }
 
+
+.block {
+    border-top: 1px solid #a0a0a0;
+    padding: 10px 0;
+    clear: both;
+}
+
+.clear { clear: both;}
+
+.talk {
+    width: 150px;
+    float: left;
+    margin-right: 10px;
+    height: 150px;
+    border: 1px solid black;
+}
+
+.talk h3 {
+    margin: 0;
+    padding: 5px;
+    text-align: right;
+    color: #4444cc;
+    font-size: 10px;
+}
+
+.talk .stats {
+    padding: 5px;
+    text-align: right;
+}
+
+.talk .stats .label {
+    float: left;
+    display: block;
+    font-size: 11px;
+    padding-top: 3px;
+}
+
+.talk .stat {
+    font-size: 14px;
+    
+}
+
+.schedule {
+    float: left;   
+}
+
+.priorities 
+{
+    float: right;
+    font-size: 11px;    
+    width: 300px;
+}
+
+.priorities .used {
+    
+    font-size: 12px;
+    text-decoration: underline;
+    color: #00a000;
+    
+}
+.priorities .blocked {
+    color: red;
+}
+
+.priority-block {
+    padding: 2px 0 2px 10px;
+}
+.priority-block .info {
+    margin-left: -10px;
+    font-size: 9px;    
+    padding: 2px 5px;
+}
+
+.priority-block .score {
+    float: right;
+} 
+
+h3, h4 {
+    text-transform: lowercase;
+    font-weight: normal;
+    font-size: 24px;
+    color: #223366;
+}
+
+h4 { font-size: 18px;margin: 0;}
+
+td { text-align: right}
+td.label { text-align: right;padding-left: 5px;}
+
+.block-info, .number-info {
+    padding: 5px 0;
+}
+
+.form-row {
+    padding-top: 5px;
+    width: 330px;
+    padding-left: 10px;
+}
+
+.slider 
+{
+    margin-top: 5px;
+    margin-left: 20px;
+    width: 300px;
+}
+
+.check-row {
+    text-align: right;
+}
+
+.form-row label {
+    display: block;
+}
+
+.check-row label {
+    display: inline;
+}
+
+.number-box {
+    text-align: right;
+    width: 70px;
+}
+
+.settings form {
+    position: relative;
+}
+.settings .numbers {
+    position: absolute;
+    left: 360px;
+    top: 0px;
+}
+
+.submit-row {
+    padding: 20px 0;
+    text-align: right;
+}

CommunityDayPoll/Controllers/ScheduleController.cs

+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Net;
+using System.Web.Mvc;
+using CommunityDayPoll.Models;
+using DapperExtensions;
+using Happyference.Models;
+using Newtonsoft.Json;
+
+namespace CommunityDayPoll.Controllers
+{
+    public class ScheduleController : Controller
+    {
+        private readonly string _connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
+
+        private int[][] GetData()
+        {
+            IEnumerable<PollResult> pollResults;
+            using (SqlConnection cn = new SqlConnection(_connectionString))
+            {
+                cn.Open();
+                pollResults = cn.GetList<PollResult>().ToList();
+                cn.Close();
+            }
+
+            return pollResults.Select(x => JsonConvert.DeserializeObject<int[]>(x.Priorities)).ToArray();
+
+        }
+
+        //
+        // GET: /Schedule/
+
+        public ActionResult Index(ScheduleModel model)
+        {
+            var data = GetData();
+            data = data.Where(d => d != null).ToArray();
+
+            foreach (var p in data) //Align talk ID's (first should have id "0", not "1")
+            {
+                for (var i = 0; i < p.Length; i++) --p[i];
+            }
+
+            if (Request.HttpMethod == "POST")
+            {
+                model.Talks = 20;
+            }
+            else
+            {
+                model = new ScheduleModel
+                    {
+                        MeanWeight = 1,
+                        Participants = 200,
+                        RoomCapacitiesInput = new[] { 100, 50, 50, 20 },
+                        Talks = 20
+                    };
+            }
+
+            model.RoomCapacities = model.RoomCapacitiesInput.Where(rc => rc > 0).ToArray();
+
+            var c = new Conference(data, model.Talks, model.RoomCapacities, model.Participants)
+                {
+                    MeanWeight = model.UseMedianInsteadOfMean ? 0 : model.MeanWeight,
+                    MedianWeight = model.UseMedianInsteadOfMean ? model.MeanWeight : 0,
+                    SuckerWeight = model.SuckerWeight,
+                    StDevWeight = model.StdDevweight,
+                    SuckerPercentile = .10
+                };
+
+
+            HashSet<int> fixedTalks;
+            var empty = c.CreateEmptySchedule(null, out fixedTalks);
+
+            if (model.FixedSchedule != null && model.FixedSchedule.Count > 0)
+            {
+                foreach (var kv in model.FixedSchedule)
+                {
+                    if (kv.Value[0] < empty.Length && kv.Value[1] < empty[kv.Value[0]].Length)
+                    {
+                        empty[kv.Value[0]][kv.Value[1]] = kv.Key;
+                    }
+                }
+                empty = c.CreateEmptySchedule(empty, out fixedTalks);
+            }
+
+            //Initial schedule doesn't matter when using SA. But this guarantees a semi-shitty lower bound
+            var schedule = c.GreedySchedule(empty);
+            //var schedule = c.NaiveSchedule(empty);                      
+
+            var r = new Random(1337);
+            var generator = new RandomSwapGenerator(schedule, c, fixedTalks, r);
+            //This is slow, and doesn't improve results: var generator = new TalkOrderGenerator(c, random: r);
+            var sa = new SimulatedAnnealing(c, r);
+            schedule = sa.Start(generator);
+
+            model.Schedule = schedule;
+            model.Score = c.DetailedScore(schedule);
+            model.TalkModels = TalkRepository.GetAll();
+
+            
+
+
+
+
+            return View(model);
+        }
+    }
+}

CommunityDayPoll/Data/Data.txt

+[
+  [
+    3,
+    12,
+    10,
+    2,
+    8,
+    1,
+    5,
+    14,
+    20,
+    11
+  ],
+  [
+    15,
+    17,
+    1,
+    12,
+    8,
+    7,
+    10,
+    18,
+    9
+  ],
+  [
+    17,
+    11,
+    7,
+    3,
+    16,
+    8,
+    19
+  ],
+  [
+    8,
+    19,
+    2,
+    15,
+    11,
+    13,
+    4,
+    9
+  ],
+  [
+    14,
+    9,
+    1,
+    20,
+    18
+  ],
+  [
+    15,
+    17,
+    6,
+    3,
+    11,
+    19,
+    18,
+    14,
+    16,
+    1
+  ],
+  [
+    3,
+    15,
+    6,
+    17,
+    13,
+    4,
+    18,
+    19
+  ],
+  [
+    20,
+    15,
+    16,
+    5,
+    7,
+    13
+  ],
+  [
+    6,
+    20,
+    1,
+    7,
+    12,
+    11,
+    17,
+    16,
+    14
+  ],
+  [
+    7,
+    17,
+    18,
+    2,
+    6,
+    3,
+    9,
+    16
+  ],
+  [
+    12,
+    20,
+    6,
+    2,
+    13,
+    9,
+    15,
+    11
+  ],
+  [
+    1,
+    4,
+    6,
+    7,
+    18,
+    14,
+    15,
+    17
+  ],
+  [
+    6,
+    8,
+    14,
+    15,
+    19,
+    20,
+    1,
+    3,
+    13,
+    5
+  ],
+  [
+    1,
+    13,
+    18,
+    17,
+    15,
+    16
+  ],
+  [
+    9,
+    4,
+    15,
+    13,
+    11,
+    19,
+    3,
+    12,
+    18
+  ],
+  [
+    16,
+    18,
+    19,
+    8,
+    3,
+    12,
+    15,
+    13
+  ],
+  [
+    5,
+    2,
+    16,
+    8,
+    11,
+    12,
+    13,
+    20
+  ],
+  [
+    6,
+    3,
+    19,
+    2,
+    12,
+    7,
+    14,
+    16,
+    17,
+    18,
+    1,
+    10,
+    8,
+    13,
+    15,
+    11,
+    4,
+    9,
+    5,
+    20
+  ],
+  [
+    15,
+    19,
+    7,
+    11,
+    1,
+    14,
+    9,
+    3
+  ],
+  [
+    2,
+    15,
+    10,
+    16,
+    7,
+    17,
+    11,
+    13,
+    9,
+    1
+  ],
+  [
+    5,
+    8,
+    16,
+    3,
+    4,
+    12,
+    7,
+    6,
+    10,
+    20
+  ],
+  [
+    9,
+    15,
+    13,
+    12,
+    17,
+    20,
+    16
+  ],
+  [
+    6,
+    7,
+    10,
+    12,
+    16,
+    18,
+    8,
+    14,
+    2
+  ],
+  [
+    3,
+    11,
+    9,
+    12,
+    13
+  ],
+  [
+    20,
+    12,
+    5,
+    3,
+    16,
+    6,
+    15,
+    13
+  ],
+  [
+    6,
+    15,
+    11,
+    14,
+    13,
+    2,
+    12
+  ],
+  [
+    15,
+    12,
+    18,
+    9,
+    6,
+    17,
+    5,
+    1,
+    16,
+    20,
+    13,
+    8,
+    14,
+    19,
+    3,
+    4,
+    7,
+    10,
+    2,
+    11
+  ],
+  [
+    2,
+    9,
+    3,
+    6,
+    7,
+    1
+  ],
+  [
+    12,
+    20,
+    3,
+    2,
+    9,
+    15,
+    14,
+    13
+  ],
+  [
+    8,
+    12,
+    16,
+    2,
+    13,
+    18,
+    17,
+    15
+  ],
+  [
+    15,
+    3,
+    20,
+    7,
+    1,
+    2,
+    12,
+    13,
+    17,
+    18,
+    19,
+    14,
+    10,
+    8,
+    6
+  ],
+  [
+    12,
+    5,
+    17,
+    16,
+    6
+  ],
+  [
+    1,
+    10,
+    2,
+    6,
+    8,
+    12,
+    15,
+    3
+  ],
+  [
+    7,
+    8,
+    12,
+    15,
+    20,
+    11,
+    2,
+    3,
+    4
+  ],
+  [
+    3,
+    13,
+    20,
+    19,
+    8,
+    15,
+    2,
+    11,
+    12,
+    17,
+    16
+  ],
+  [
+    1,
+    4,
+    13,
+    18,
+    16,
+    2,
+    5,
+    3
+  ],
+  [
+    19,
+    2,
+    17,
+    18,
+    7
+  ],
+  [
+    3,
+    19,
+    12,
+    16,
+    20
+  ],
+  [
+    15,
+    6,
+    7,
+    5,
+    2,
+    1,
+    14,
+    16,
+    4
+  ],
+  [
+    15,
+    6,
+    7,
+    5,
+    1
+  ],
+  [
+    1,
+    2,
+    10,
+    16,
+    7,
+    11,
+    13,
+    18,
+    20,
+    9
+  ],
+  [
+    3,
+    8,
+    12,
+    18,
+    19
+  ],
+  [
+    1,
+    7,
+    6,
+    15,
+    3,
+    13,
+    12
+  ],
+  [
+    18,
+    7,
+    13,
+    17,
+    8,
+    12,
+    3,
+    11
+  ],
+  [
+    13,
+    17,
+    11,
+    16,
+    14,
+    15,
+    4,
+    12
+  ],
+  [
+    3,
+    13,
+    14,
+    19,
+    17,
+    18
+  ],
+  [
+    15,
+    8,
+    13,
+    5,
+    11,
+    20,
+    4,
+    16,
+    9,
+    3
+  ],
+  [
+    18,
+    15,
+    2,
+    16,
+    19,
+    7
+  ],
+  [
+    16,
+    1,
+    2,
+    11,
+    3
+  ],
+  [
+    7,
+    3,
+    16,
+    20,
+    12,
+    19,
+    8,
+    6,
+    14
+  ],
+  [
+    2,
+    1,
+    14,
+    6,
+    17
+  ],
+  [
+    9,
+    3,
+    19,
+    13,
+    15
+  ],
+  [
+    5,
+    3,
+    6,
+    1,
+    17,
+    9,
+    19,
+    11,
+    16,
+    20
+  ],
+  [
+    8,
+    12,
+    13,
+    15,
+    16,
+    19,
+    18,
+    9
+  ],
+  [
+    6,
+    14,
+    20,
+    5,
+    1,
+    16,
+    7,
+    12,
+    10
+  ],
+  [
+    10,
+    3,
+    7,
+    12,
+    13,
+    6,
+    2,
+    1
+  ],
+  [
+    20,
+    2,
+    9,
+    3,
+    5,
+    16,
+    1,
+    12
+  ],
+  [
+    4,
+    9,
+    13,
+    20,
+    2,
+    8,
+    3,
+    19
+  ],
+  [
+    1,
+    14,
+    2,
+    16,
+    6,
+    18
+  ],
+  [
+    5,
+    20,
+    17,
+    2,
+    15,
+    1,
+    16,
+    9,
+    3
+  ],
+  [
+    15,
+    16,
+    14,
+    6,
+    8,
+    10,
+    1,
+    7,
+    4,
+    2
+  ],
+  [
+    19,
+    17,
+    18,
+    7,
+    15
+  ],
+  [
+    8,
+    3,
+    19,
+    9,
+    11,
+    13,
+    15,
+    2
+  ],
+  [
+    20,
+    2,
+    8,
+    12,
+    5,
+    6,
+    16
+  ],
+  [
+    5,
+    20,
+    12,
+    8,
+    7,
+    15
+  ],
+  [
+    2,
+    6,
+    3,
+    10,
+    19,
+    7,
+    1,
+    17,
+    9
+  ],
+  [
+    18,
+    14,
+    13,
+    19,
+    7
+  ],
+  [
+    13,
+    4,
+    3,
+    9,
+    12,
+    15
+  ],
+  [
+    3,
+    6,
+    2,
+    10,
+    17
+  ],
+  [
+    3,
+    8,
+    12,
+    17,
+    11
+  ],
+  [
+    15,
+    6,
+    11,
+    14,
+    17,
+    13,
+    10,
+    18,
+    19
+  ],
+  [
+    2,
+    19,
+    1,
+    3,
+    9
+  ],
+  [
+    17,
+    3,
+    11,
+    18,
+    19
+  ],
+  [
+    1,
+    14,
+    15,
+    18,
+    5,
+    13,
+    17,
+    11
+  ],
+  [
+    18,
+    14,
+    10,
+    15,
+    17,
+    8
+  ],
+  [
+    6,
+    12,
+    10,
+    13,
+    7,
+    5,
+    8,
+    17,
+    18,
+    16,
+    14,
+    4,
+    1,
+    20,
+    15,
+    3,
+    11,
+    19,
+    2,
+    9
+  ],
+  [
+    6,
+    12,
+    5,
+    3,
+    2,
+    19,
+    16,
+    9
+  ],
+  [
+    3,
+    8,
+    11,
+    15,
+    14,
+    6,
+    2,
+    16,
+    20,
+    12
+  ],
+  [
+    5,
+    20,
+    6,
+    2,
+    16,
+    14,
+    7,
+    17,
+    3,
+    18,
+    12
+  ],
+  [
+    19,
+    17,
+    13,
+    2,
+    15,
+    8,
+    9,
+    1,
+    7
+  ],
+  [
+    6,
+    11,
+    17,
+    7,
+    3,
+    15,
+    10,
+    19,
+    16,
+    13,
+    14,
+    8,
+    2
+  ],
+  [
+    1,
+    6,
+    14,
+    18,
+    3,
+    9,
+    10
+  ],
+  [
+    14,
+    1,
+    20,
+    15,
+    5,
+    2,
+    13
+  ],
+  [
+    1,
+    13,
+    17,
+    19,
+    18,
+    4,
+    7
+  ],
+  [
+    2,
+    15,
+    1,
+    8,
+    17,
+    10,
+    7,
+    12
+  ],
+  [
+    20,
+    5,
+    7,
+    1,
+    9
+  ],
+  [
+    14,
+    16,
+    1,
+    12,
+    5,
+    8,
+    6,
+    20
+  ],
+  [
+    9,
+    12,
+    19,
+    2,
+    13
+  ],
+  [
+    3,
+    16,
+    18,
+    7,
+    8,
+    11,
+    12
+  ],
+  [
+    17,
+    16,
+    6,
+    5,
+    12,
+    11,
+    10,
+    7,
+    8,
+    20,
+    1,
+    2
+  ],
+  [
+    13,
+    2,
+    3,
+    4,
+    9,
+    19
+  ],
+  [
+    12,
+    3,
+    8,
+    11,
+    18
+  ],
+  [
+    6,
+    19,
+    14,
+    10,
+    15
+  ],
+  [
+    2,
+    8,
+    12,
+    18,
+    20,
+    5,
+    4,
+    15,
+    13,
+    16
+  ],
+  [
+    20,
+    5,
+    3,
+    10,
+    19,
+    8,
+    11,
+    12,
+    15,
+    13,
+    7,
+    18
+  ],
+  [
+    15,
+    9,
+    14,
+    3,
+    17,
+    13,
+    4,
+    19
+  ],
+  [
+    6,
+    19,
+    20,
+    7,
+    8,
+    16,
+    15
+  ],
+  [
+    14,
+    8,
+    16,
+    11,
+    3,
+    18,
+    6
+  ],
+  [
+    8,
+    19,
+    17,
+    1,
+    7,
+    18,
+    11,
+    5
+  ],
+  [
+    12,
+    10,
+    3,
+    19,
+    1,
+    18,
+    7,
+    8,
+    2
+  ],
+  [
+    7,
+    18,
+    2,
+    16,
+    17,
+    9,
+    12,
+    15
+  ],
+  [
+    3,
+    8,
+    19,
+    6,
+    5,
+    20,
+    1,
+    12
+  ],
+  [
+    18,
+    7,
+    15,
+    8,
+    13,
+    1,
+    14,
+    2
+  ],
+  [
+    16,
+    17,
+    13,
+    12,
+    11,
+    15,
+    8,
+    7,
+    9
+  ],
+  [
+    2,
+    9,
+    10,
+    6,
+    20,
+    7,
+    5,
+    12
+  ],
+  [
+    13,
+    12,
+    7,
+    15,
+    10,
+    6,
+    8,
+    2,
+    5,
+    4,
+    20,
+    18,
+    11,
+    3,
+    16,
+    19,
+    9,
+    17,
+    1,
+    14
+  ],
+  [
+    12,
+    16,
+    17,
+    15,
+    6,
+    8,
+    20
+  ],
+  null,
+  null,
+  [
+    15,
+    18,
+    14,
+    13,
+    2,
+    9,
+    1,
+    16
+  ],
+  [
+    7,
+    12,
+    10,
+    6,
+    1
+  ],
+  [
+    11,
+    7,
+    10,
+    3,
+    18,
+    17
+  ],
+  [
+    2,
+    3,
+    12,
+    17,
+    8,
+    6,
+    16,
+    14,
+    10,
+    1,
+    7,
+    5
+  ],
+  [
+    20,
+    5,
+    7,
+    2,
+    6,
+    12,
+    15,
+    11
+  ],
+  [
+    3,
+    2,
+    7,
+    1,
+    20,
+    11,
+    10,
+    9
+  ],
+  [
+    5,
+    8,
+    9,
+    12,
+    11,
+    16,
+    20
+  ],
+  [
+    3,
+    1,
+    6,
+    17,
+    18,
+    13,
+    15
+  ],
+  [
+    5,
+    12,
+    13,
+    18,
+    20,
+    8
+  ],
+  [
+    2,
+    9,
+    3,
+    12,
+    11,
+    19,
+    15,
+    17
+  ],
+  [
+    20,
+    3,
+    12,
+    2,
+    15,
+    19,
+    5,
+    8,
+    1
+  ],
+  [
+    20,
+    2,
+    12,
+    6,
+    3,
+    5,
+    8,
+    9
+  ],
+  [
+    17,
+    2,
+    14,
+    16,
+    13,
+    3,
+    1,
+    12
+  ],
+  [
+    17,
+    7,
+    12,
+    6,
+    8,
+    13,
+    19,
+    11,
+    3
+  ],
+  [
+    2,
+    11,
+    17,
+    13,
+    12,
+    10,
+    18,
+    1
+  ],
+  [
+    2,
+    20,
+    13,
+    6,
+    15,
+    8
+  ],
+  [
+    3,
+    2,
+    1,
+    18,
+    12,
+    7,
+    10
+  ],
+  [
+    15,
+    19,
+    1,
+    13,
+    3,
+    4,
+    2,
+    6
+  ],
+  [
+    12,
+    8,
+    9,
+    3,
+    18,
+    17,
+    19,
+    4,
+    2
+  ],
+  [
+    8,
+    10,
+    5,
+    12,
+    16,
+    2,
+    7,
+    13
+  ],
+  [
+    1,
+    7,
+    10,
+    17,
+    15,
+    18
+  ],
+  [
+    11,
+    2,
+    18,
+    4,
+    13,
+    12,
+    3,
+    15,
+    19
+  ],
+  [
+    20,
+    12,
+    3,
+    8,
+    13,
+    2,
+    1,
+    15,
+    5,
+    14,
+    4
+  ],
+  [
+    16,
+    13,
+    6,
+    1,
+    14,
+    2,
+    4,
+    15,
+    12,
+    11,
+    10,
+    9,
+    8
+  ],
+  [
+    11,
+    5,
+    20,
+    8,
+    2
+  ],
+  [
+    1,
+    14,
+    16,
+    10,
+    3,
+    15,
+    17,
+    13
+  ],
+  [
+    1,
+    2,
+    3,
+    17,
+    16,
+    13,
+    10,
+    11
+  ],
+  [
+    5,
+    8,
+    13,
+    16,
+    10,
+    12,
+    9,
+    19
+  ],
+  [
+    5,
+    20,
+    1,
+    7,
+    11,
+    8,
+    13,
+    3,
+    19
+  ],
+  [
+    4,
+    16,
+    12,
+    18,
+    2,
+    11,
+    6,
+    9,
+    7
+  ],
+  [
+    13,
+    17,
+    15,
+    4,
+    18,
+    19
+  ],
+  [
+    6,
+    3,
+    18,
+    1,
+    5,
+    2,
+    8,
+    14,
+    20
+  ],
+  [
+    8,
+    18,
+    19,
+    10,
+    17,
+    16,
+    6,
+    2,
+    13,
+    20,
+    4,
+    1,
+    3,
+    11,
+    7
+  ],
+  [
+    20,
+    17,
+    2,
+    19,
+    6,
+    12,
+    5,
+    14
+  ],
+  [
+    14,
+    16,
+    18,
+    7,
+    2,
+    12,
+    6,
+    3,
+    15
+  ],
+  [
+    15,
+    16,
+    6,
+    1,
+    2
+  ]
+]

CommunityDayPoll/Models/Conference.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using CommunityDayPoll.Models;
+using MathNet.Numerics.Statistics;
+
+namespace Happyference.Models
+{
+    public class Conference
+    {
+        public int TotalParticipants { get; set; }
+        public double ParticipantsPerPriority { get; set; }
+
+
+        public int Talks { get; set; }
+
+        public int[][] Priorities { get; set; }
+        public double[][] PrioritiyScores { get; set; }
+
+        public int[] Counts { get; set; }
+
+        public int[] ProjectedCounts { get; set; }
+
+        public int[] RoomCapacities { get; set; }
+
+        
+        public double MeanWeight { get; set; }
+        public double MedianWeight { get; set; }
+        public double StDevWeight { get; set; }
+        public double SuckerWeight { get; set; }
+
+        public double SuckerPercentile { get; set; }
+
+        public Conference(int[][] priorities, int talks, int[] roomCapacities, int totalParticipants)
+        {
+            MeanWeight = 1;
+
+            SuckerPercentile = .1;
+
+            Priorities = priorities;
+            Talks = talks;
+            RoomCapacities = roomCapacities;
+            TotalParticipants = Math.Max(priorities.Length, totalParticipants);
+
+            PrioritiyScores = new double[priorities.Length][];
+            Counts = new int[Talks];
+
+            for (int i = 0; i < priorities.Length; i++)
+            {
+                var po = priorities[i];
+                var weight = 100d;
+                PrioritiyScores[i] = new double[Talks];
+                for (int j = 0; j < po.Length; j++)
+                {
+                    var p = po[j];
+                    ++Counts[p];
+                    PrioritiyScores[i][p] = weight;
+                    weight /= 2;
+                }
+            }
+
+            ParticipantsPerPriority = TotalParticipants / (double)Priorities.Length;
+            ProjectedCounts = Counts.Select(c => (int)Math.Ceiling(c * ParticipantsPerPriority)).ToArray();
+        }
+
+        /// <summary>
+        /// The total number of time blocks required
+        /// </summary>
+        public int NumberOfBlocks
+        {
+            get { return (int)Math.Ceiling(Talks / (double)RoomCapacities.Length); }
+        }
+
+        public int[] GetTalkOrderByProjectedCounts()
+        {
+            return Enumerable.Range(0, Talks)
+                .Select(i => new KeyValuePair<int, double>(i, ProjectedCounts[i]))
+                .OrderByDescending(kv => kv.Value).Select(kv => kv.Key).ToArray();
+        }
+
+
+        public int[][] CreateEmptySchedule(int[][] fixedSchedule, out HashSet<int> fixedTalks)
+        {
+            fixedTalks = new HashSet<int>();
+
+            var schedule = fixedSchedule;