-
-
Save luismbo/314ded3273666ea38cbc12958bab6418 to your computer and use it in GitHub Desktop.
MPL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-model wedding () | |
(possible-tables | |
guests | |
table-guests | |
happiness | |
max-tables) | |
;; variables | |
(dvar 'x :binary | |
(for i :in (param 'possible-tables))) | |
;; objective | |
(minimize (sum (* (param 'happiness i) (var 'x i)) | |
(for i :in (param 'possible-tables)))) | |
;; constraints | |
(s.t. 'maximum-number-of-tables | |
(<= (sum (var 'x i) | |
(for i :in (param 'possible-tables))) | |
(param 'max-tables))) | |
(s.t. 'seat-each-guest-once | |
(= (sum (var 'x i) | |
(for i :in (param 'possible-tables)) | |
(where (member g (param 'table-guests i)))) | |
1) | |
(for g :in (param 'guests)))) | |
; => WEDDING | |
(make-instance 'wedding | |
:possible-tables '(a b c d e) | |
:guests '(alice bob carl) | |
:table-guests '(a (alice bob) b (alice carl) c (bob carl) d (bob) e (carl)) | |
:happiness '(a 10 b 20 c 30 d 1 e 2) | |
:max-tables 2) | |
; => #<WEDDING [MIN] 1 variable, 2 constraints @ #x1163ccea2> | |
(solve *) | |
; ... | |
; => #<MPL::SOLUTION 12.0 (optimal) @ #x112bb11d2> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment