Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Planer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beekmannju85374
Planer
Commits
25d91e84
Commit
25d91e84
authored
7 months ago
by
beekmannju85374
Browse files
Options
Downloads
Patches
Plain Diff
fixed fairRest algo
parent
4f292ce0
No related branches found
No related tags found
1 merge request
!8
Master
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/Main.hs
+32
-23
32 additions, 23 deletions
app/Main.hs
dist-newstyle/cache/config
+0
-0
0 additions, 0 deletions
dist-newstyle/cache/config
presentations.pdf
+0
-0
0 additions, 0 deletions
presentations.pdf
presentations.tex
+3
-1
3 additions, 1 deletion
presentations.tex
with
35 additions
and
24 deletions
app/Main.hs
+
32
−
23
View file @
25d91e84
...
...
@@ -89,17 +89,17 @@ generateSchedules rooms startDay endDay professors = groups
days
=
[
d
|
d
<-
[
readDay
startDay
..
readDay
endDay
],
dayOfWeek
d
==
Thursday
,
d
`
notElem
`
uniHolidays
(
readDay
startDay
)
(
readDay
endDay
)]
-- generate all possible presentations
presentations
=
[
Presentation
room
day
proj
prof
|
day
<-
days
,
room
<-
rooms
,
prof
<-
professors
,
(
null
(
availableDays
prof
)
&&
day
`
notElem
`
unavailableDays
prof
)
||
(
null
(
unavailableDays
prof
)
&&
day
`
elem
`
availableDays
prof
),
proj
<-
projects
prof
]
room
<-
rooms
,
prof
<-
professors
,
(
null
(
availableDays
prof
)
&&
day
`
notElem
`
unavailableDays
prof
)
||
(
null
(
unavailableDays
prof
)
&&
day
`
elem
`
availableDays
prof
),
proj
<-
projects
prof
]
-- generate all combinations from each presentation in presentations with every other presentation, filter out unsuitable or impossible presentations
-- the possible dates must be >= the number of professors and their projects in order to combine them
-- the possible dates
x room
must be >= the number of professors and their projects in order to combine them
groups
|
length
days
*
length
rooms
<
projectsLen
=
error
"not enough possible dates or rooms for scheduling"
|
otherwise
=
map
(
splitIntoGroups
(
fairRest
projectsLen
)
.
sortByRoom
)
$
combinationsFast
projectsLen
(
sort
presentations
)
|
otherwise
=
map
(
splitIntoGroups
(
fairRest
projectsLen
)
.
sortByRoom
)
$
combinationsFast
projectsLen
(
sort
presentations
)
-- try complexity with sort and without
-- after combining the presentations, split each list into the fairest groups
-- a presentationgroup should have 3 to 5 projects each
...
...
@@ -108,18 +108,27 @@ generateSchedules rooms startDay endDay professors = groups
-- if 5 is the fairest with rest 1 change to resultDif because you cannot have groupings of 6
-- 3a + 4b + 5c = n
-- if 3,4 or 5 are equal, does findEven change if the other equal number is chosen?
-- guard order is important!
fairRest
::
Int
->
Int
fairRest
n
=
if
first
result
==
5
&&
second
result
==
1
then
first
resultDif
else
first
result
|
first
result
==
5
&&
second
result
==
1
=
first
resultDif
-- last group cannot be 6 since its not allowed
|
first
resultDif
==
3
&&
third
result
==
1
=
first
result
-- last group cannot be 2 since its not allowed
|
second
result
<=
1
=
first
result
|
second
result
>
1
=
first
resultDif
|
otherwise
=
error
"critical math error in fairRest"
-- is not possible
where
result
=
minimumBy
(
compare
`
on
`
second
)
modResults
resultDif
=
minimumBy
(
compare
`
on
`
third
)
modResults
modResult
x
=
(
x
,
n
`
mod
`
x
,
x
-
(
n
`
mod
`
x
))
modResults
=
map
modResult
[
5
,
4
,
3
]
modResults
=
map
modResult
[
5
,
4
]
first
(
x
,
_
,
_
)
=
x
second
(
_
,
x
,
_
)
=
x
third
(
_
,
_
,
x
)
=
x
-- if first result == 5 && second result == 1 then first resultDif else first result
-- ( n, x, n%x, x - (n%x) )
fairRestDebug
::
Int
->
[(
Int
,
Int
,
Int
,
Int
)]
fairRestDebug
n
=
result
...
...
@@ -171,14 +180,14 @@ findEven presentations rooms
-- filters according to the rules above findEven
checkEven
::
[[
Presentation
]]
->
[
Room
]
->
Bool
checkEven
presentations
rooms
|
even
(
length
presentations
)
=
all
(
\
group
->
length
(
nub
(
map
room
group
))
==
1
)
presentations
|
even
projectsLen
=
let
countRooms
=
map
(
countRoom
(
concat
presentations
))
rooms
in
all
(
==
head
countRooms
)
(
tail
countRooms
)
|
odd
projectsLen
=
all
(
\
r
->
abs
(
countRoom
(
concat
presentations
)
r
-
(
projectsLen
`
div
`
length
rooms
))
<=
1
)
rooms
|
otherwise
=
error
"unaccounted for amount of rooms and or presenations, fix in function checkEven, maybe needs stricter guards"
where
projectsLen
=
length
$
concat
presentations
|
even
(
length
presentations
)
=
all
(
\
group
->
length
(
nub
(
map
room
group
))
==
1
)
presentations
|
even
projectsLen
=
let
countRooms
=
map
(
countRoom
(
concat
presentations
))
rooms
in
all
(
==
head
countRooms
)
(
tail
countRooms
)
|
odd
projectsLen
=
all
(
\
r
->
abs
(
countRoom
(
concat
presentations
)
r
-
(
projectsLen
`
div
`
length
rooms
))
<=
1
)
rooms
|
otherwise
=
error
"unaccounted for amount of rooms and or presenations, fix in function checkEven, maybe needs stricter guards"
where
projectsLen
=
length
$
concat
presentations
countRoom
::
[
Presentation
]
->
Room
->
Int
countRoom
presentations
r
=
length
$
filter
(
\
p
->
room
p
==
r
)
presentations
...
...
@@ -187,9 +196,9 @@ countRoom presentations r = length $ filter (\p -> room p == r) presentations
-- leave schedule unchanged for old professors, if it is not possible the plan must be recalculated
addProfessor
::
Professor
->
[
Room
]
->
String
->
String
->
[[
Presentation
]]
->
[[[
Presentation
]]]
addProfessor
prof
rooms
startDay
endDay
oldPresentations
=
if
null
newGroups
then
error
"Cannot add a new professor with the existing presentation list. Need to recalculate all presentations."
else
map
(
splitIntoGroups
(
fairRest
projectsLen
)
.
sortByRoom
)
newGroups
if
null
newGroups
then
error
"Cannot add a new professor with the existing presentation list. Need to recalculate all presentations."
else
map
(
splitIntoGroups
(
fairRest
projectsLen
)
.
sortByRoom
)
newGroups
where
oldPresentationsFlat
=
concat
oldPresentations
--removes grouping
projectsLen
=
length
oldPresentationsFlat
+
length
(
projects
prof
)
...
...
@@ -209,9 +218,9 @@ addProfessor prof rooms startDay endDay oldPresentations =
addProfUnavailability
::
Professor
->
[
String
]
->
[
Room
]
->
String
->
String
->
[[
Presentation
]]
->
[[[
Presentation
]]]
addProfUnavailability
prof
unavailables
rooms
startDay
endDay
oldPresentations
=
if
null
newGroups
then
error
"Cannot add new unavailability for professor with the existing presentation list. Need to recalculate all presentations."
else
newGroups
if
null
newGroups
then
error
"Cannot add new unavailability for professor with the existing presentation list. Need to recalculate all presentations."
else
newGroups
where
oldPresentationsFlat
=
concat
oldPresentations
updatedProf
=
prof
{
unavailableDays
=
readDays
unavailables
++
unavailableDays
prof
}
...
...
This diff is collapsed.
Click to expand it.
dist-newstyle/cache/config
+
0
−
0
View file @
25d91e84
No preview for this file type
This diff is collapsed.
Click to expand it.
presentations.pdf
+
0
−
0
View file @
25d91e84
No preview for this file type
This diff is collapsed.
Click to expand it.
presentations.tex
+
3
−
1
View file @
25d91e84
...
...
@@ -13,6 +13,7 @@
\begin{document}
\noindent
\textbf
{
Vortragsgruppe S1
}
\\
Beginn: 14:00
\\
\\
\begin{tabular}
{
@
{}
llll
}
Datum
&
Projektgruppe
&
Dozent/in
&
Raum
\\
04.04.24
&
Project 2
&
Professor 2
&
H
\\
...
...
@@ -22,11 +23,12 @@ Beginn: 14:00\\
\\\\
\noindent
\textbf
{
Vortragsgruppe S2
}
\\
Beginn: 14:00
\\
\\
\begin{tabular}
{
@
{}
llll
}
Datum
&
Projektgruppe
&
Dozent/in
&
Raum
\\
25.04.24
&
Project 5
&
Professor 5
&
H
\\
04.04.24
&
Project 4
&
Professor 4
&
P
\\
11.04.24
&
Project 3
&
Professor 3
&
P
\\
25.04.24
&
Project 5
&
Professor 5
&
P
\\
\end{tabular}
\\\\
\end{document}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment