In the latest update included:
- Fixed the scoring function to use natural logarithm instead of the 10 base.
- A fix to the previous fix about the rest times necessary for elves finishing at 19:00 punctual, including the edge case when elf finishes rest time at 19:00.
- Included a small example to demonstrate how to connect Matlab to Mosel
We provide you with tools to support rapid development of solution approaches to help Santa's helpers using Xpress-Mosel.
The package offers a minimalistic interface, and may be extended by request. It demonstrates the modularity and extension capabilities of Xpress-Mosel.
Make sure you have installed Xpress.
Please download the file below and unpack in a directory of your choice. Copy the input data file into the same directory.
Compile and run the greedy heuristic:
- On Windows only: doubleclick santa_greedy.mos and Xpress-IVE will open. Press to compile and run.
- On all systems, type in a console: mosel santa_greedy.mos.
The result will be written to xpress_sol.csv
Toys and elves are identified by their ID, represented by an integer.
setshiftstart(hour : integer)
Sets when the sanctioned hours on a working day start, expressed in hours of the day. Use this subroutine to set a value that is different from the built-in default.
setshiftend(hour : integer)
Sets when the sanctioned hours on a working day end, expressed in hours of the day. Use this subroutine to set a value that is different from the built-in default.
setjobwindow(days : integer)
Sets the maximum wait time for toys before their processing starts, expressed in days. Use this subroutine to set a value that is different from the built-in default.
Displays basic statistics about the toys data (including a trivial lower bound on the schedule finish time).
Working with minute based times
The santa package works with datetime values that are represented by an integer. It offers a set of conversion routines that can be used for display or when working with the toys database.
maketime(year : integer, month : integer, day : integer, hour : integer,
minute : integer) : integer
Creates a datetime in integer format from individual values.
maketime(dt:datetime) : integer
Converts a datetime object to integer format.
timeyear(tm : integer) : integer
Return the year of a datetime in integer format.
timemonth(tm : integer) : integer
Returns the month of a datetime in integer format.
timeday(tm : integer) : integer
Return the day of a datetime in integer format.
timehour(tm : integer) : integer
Return the hour of a datetime in integer format.
timeminute(tm : integer) : integer
Return the minute of a datetime in integer format.
timesanctioned(tm : integer, duration : integer) : integer
Calculates the number of sanctioned minutes in the time period tm..tm+duration.
timeunsanctioned(tm : integer, duration : integer ) : integer
Calculates the amount of unsanctioned minutes in the time period tm..tm+duration.
nextsanctionedtime(tm : integer) : integer
Returns a datetime in integer format, set to the next sanctioned minute.
nextunsanctionedtime(tm : integer) : integer
Returns a datetime in integer format, set to the next unsanctioned minute.
Working with the Toys database
loadtoysdata(filename : string)
Load the toy database from the CSV file filename, and populate the set TOYS with the set of toy IDs from the data file. For the format of the database file, please refer to the Xpress-Kaggle competition description.
toyarrivetime(toy : integer) : integer
Returns the arrival time of a toy.
istoydone(toyID : integer) : bool
Returns if a toy is already assigned to an elf.
toyduration(toyID : integer) : integer
Returns the duration of a toy (at an efficiency of 1.0)
gettoysunassignedat(tm : integer) : set of integer
Returns the set of toys available, and not assigned at a given time.
Working with elves
addelves(numbertoadd : integer)
Create the set of elves, their indices are stored in the set ELVES.
ifelfbusy(elfID : integer, tm : integer) : boolean
Returns if an elf is already busy at a given time. Note, that elf statuses are assumed to be contagious, i.e. if an elf is working on a toy that keeps him busy until a given time, this function well return true for all times prior to that, even if the time requested is before the elf has started working.
nextfreeelf : integer
Returns the next free elf, i.e. the index of an elf that is available to work at the earliest possible time.
elfbusyuntil(elfID : integer) : integer
Returns until what time an elf is busy, including his resting time.
elfefficiency(elfID : integer) : real
Returns the current efficiency coefficient of an elf.
getelvesfreeat(tm : integer, elfIDs : set of integer)
Returns the set of elf indices that are free at a given time.
assignelf2toy(elfID : integer, toyID : integer, tm : integer)
Carries out the full task of assigning an elf to a toy.
assignelf2toy(elfID : integer, toyID : integer, tm : integer, ifcheck: boolean)
Carries out the full task of assigning an elf to a toy, performing a feasibility validation when ifcheck is set to true.
traceelf(elfID : integer)
Sets the provided elf to be traced, i.e. all assignments to the elf will be logged in detail. Useful for debugging purposes.
Working with solutions
loadsolution(filename : string)
Load in a solution from disk. The assignment rules are validated on the fly.
writesolution(filename : string)
Write the current solution to file. This will write incomplete solutions as well.
Checks if a solution is compete, and returns an error if not.