From 1ad2be4c9a8dcc2ab2a6886f1ee1c1ff3a9b9ac4 Mon Sep 17 00:00:00 2001 From: kkdj20 Date: Fri, 14 Sep 2018 09:04:42 -0400 Subject: [PATCH 1/2] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a4f9ac0..20ab668 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# tarot \ No newline at end of file +# tarot +Kburda From 328a48df64605aa7b99ba276df782a8bf181ad9f Mon Sep 17 00:00:00 2001 From: kkdj20 Date: Fri, 26 Oct 2018 11:54:37 -0400 Subject: [PATCH 2/2] Model/data file --- staffing.dat | 37 +++++++++++++ staffing.mod | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 staffing.dat create mode 100644 staffing.mod diff --git a/staffing.dat b/staffing.dat new file mode 100644 index 0000000..7aed2ae --- /dev/null +++ b/staffing.dat @@ -0,0 +1,37 @@ +// -------------------------------------------------------------------------- +// Licensed Materials - Property of IBM +// +// 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 +// Copyright IBM Corporation 1998, 2013. All Rights Reserved. +// +// Note to U.S. Government Users Restricted Rights: +// Use, duplication or disclosure restricted by GSA ADP Schedule +// Contract with IBM Corp. +// -------------------------------------------------------------------------- + +totalPeriods=5; +totalStudents = 100; +NbPeriods=4; +maxStudents = 25; + +// N=2; // The number of days that a worker can work in a row + +Weekdays={Mon, Tue, Wed, Thu, Fri}; +Professors= {Eckroth, Plante, ElAarag, Koc, TBA}; +Courses= {DatabaseSystems, WebApp, BigData, SeniorP1, SeniorP2, IntrotoComputing, + IntrotoComp1, IntrotoComp1, IntrotoComp2, DiscreteStructures, SoftDev1, OperatingSystems, + ComputerNetworks, ComputerGraphics, SeniorR1, SeniorR2}; + + +Rooms ={Room1, Room2, Room3, Room4, Room5, Room6}; + + +//Shifts= { 8to12, 12to4, 4to8}; + +ProfCourses = { + , + , + , + , + +}; diff --git a/staffing.mod b/staffing.mod new file mode 100644 index 0000000..8346621 --- /dev/null +++ b/staffing.mod @@ -0,0 +1,145 @@ +// -------------------------------------------------------------------------- +// Licensed Materials - Property of IBM +// +// 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 +// Copyright IBM Corporation 1998, 2013. All Rights Reserved. +// +// Note to U.S. Government Users Restricted Rights: +// Use, duplication or disclosure restricted by GSA ADP Schedule +// Contract with IBM Corp. +// -------------------------------------------------------------------------- + +/*********************************************************************** +* OPL Model for Staffing Example +* +* This model is described in the documentation. +* See "IDE and OPL > Language and Interfaces Examples > OPL model library" +* +* This model is greater than the size allowed in trial mode. +* You therefore need a commercial edition of CPLEX Studio to run this example. +* If you are a student or teacher, you can also get a full version through +* the IBM Academic Initiative. +*************************************************************************/ + + + +//**************************** Data ************************************** +int totalPeriods = ...; // Total # of Periods in a day +int NbPeriods = ...; // Total # Periods a person should have class in a day +int totalStudents = ...; // Total # of students +int maxStudents = ...; // Max # of students per class +range Periods = 1..totalPeriods; +range Students = 1..totalStudents; + +{string} Professors = ...; // Set of Professors +{string} Weekdays = ...; // Set of work days +{string} Rooms = ...; // Set of Rooms +{string} Courses = ...; // Set of Courses + +// Data Structure +tuple PCourse { + key string p; + {string} s; +} + +{PCourse} ProfCourses = ...; // List of Professors for each course + +int Penalty = card(Weekdays)*NbPeriods+1; // Penalty for an unfilled slot + +//********************************* Variables ********************************** + +dvar boolean Assign[Weekdays][Periods][Rooms][Professors][Courses]; // Indicates a course assignment +dvar boolean Q[Students][Courses][Weekdays][Periods]; +dvar boolean I[Students][Weekdays][Periods]; +dvar boolean J[Courses][Weekdays][Periods]; +dvar int Unfilled[Courses][Weekdays][Periods][Rooms] in 0..25; // # of empty seats in given room on day/time +dvar int Pmin in 0..card(Weekdays)*NbPeriods; // Minimal # of Periods assigned +dvar int Pmax in 0..card(Weekdays)*NbPeriods; // Maximal # of Periods assigned +dvar boolean W[Students][Courses]; +dvar boolean Enroll [Students][Courses][Periods]; //student has course at period +dvar boolean Occupy [Courses][Rooms][Periods]; //Course in room at period +dvar boolean Teach [Professors][Courses]; //Professor teaching course at period +dvar boolean Avail[Weekdays][Periods][Rooms][Courses]; // Indicates the availability of a room +dvar boolean P[Periods]; + + +// the total # of slots unfilled in a week +dexpr int TotUnfilled = + sum(c in Courses,w in Weekdays,p in Periods, r in Rooms) Unfilled[c][w][p][r]; + +/************************************* Model *********************************/ + +//minimize TotUnfilled*Penalty + (Pmax-Pmin); +//minimize sum (p in Periods) P[p]; +minimize sum (c in Courses, p in Periods, r in Rooms) Occupy[c][r][p]; +//minimize 0; +// Note: Since the penalty is higher than the maximal +// possible difference in the # of Periods assigned to the Students, +// the schedule always fills the demand first, and then balances the class load. + +subject to { + + forall(c in Courses) + sum (w in Weekdays, p in Periods) J[c][w][p] == 1; + + forall(s in Students, c in Courses) + W[s][c] == sum (p in Periods) Enroll[s][c][p]; + + forall(w in Weekdays, p in Periods, r in Rooms, c in Courses) //only 1 professor per room/period + sum(j in Professors) + Assign[w][p][r][j][c] <= 1; + + forall(w in Weekdays, p in Periods, r in Rooms) //only 1 course per room/period + sum(c in Courses) + Avail[w][p][r][c] <= 1; + + forall(c in Courses, p in Periods) //one room per course per period + sum (r in Rooms) + Occupy[c][r][p] <= 1; + + forall(r in Rooms, p in Periods) //each course only given once per period + sum (c in Courses) + Occupy[c][r][p] <= 1; + + forall(p in Periods, s in Students) //one course per period + sum (c in Courses) + Enroll[s][c][p]<=1; + + forall(s in Students, c in Courses, p in Periods) + Enroll[s][c][p] <= sum (r in Rooms) Occupy[c][r][p]; // can only enroll in offered classes + + forall (p in Periods, c in Courses) + sum (s in Students) Enroll[s][c][p] <= sum (r in Rooms) Occupy[c][r][p]*maxStudents; //make sure students per class don't exceed maxstudents' + + forall (p in Periods, c in Courses, r in Rooms) + Occupy[c][r][p] <= P[p]; + + + forall(s in Students, c in Courses) + W[s][c] <= sum(w in Weekdays, p in Periods) Q[s][c][w][p]; + + + forall(s in Students, c in Courses, w in Weekdays, p in Periods) + Q[s][c][w][p]<=W[s][c]; + + forall(s in Students, w in Weekdays, p in Periods) + I[s][w][p] <= sum(c in Courses) Q[s][c][w][p]; + + forall(s in Students, c in Courses, w in Weekdays, p in Periods) + Q[s][c][w][p]<=I[s][w][p]; + + //forall(c in Courses, w in Weekdays, p in Periods) + + + forall(c in Courses) + sum (w in Weekdays, p in Periods, r in Rooms) + Avail[w][p][r][c] == 1; + + forall(c in Courses) + sum (j in Professors) + Teach[j][c]==1; + + + + +}