Skip to content

Instantly share code, notes, and snippets.

@cflewis
Created March 15, 2010 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cflewis/332607 to your computer and use it in GitHub Desktop.
Save cflewis/332607 to your computer and use it in GitHub Desktop.
% A script to show using lparse with optimize statements. Pipe into clasp for nicer output.
#hide cost(_,_).
#hide star(_,_).
#hide main_street(_).
% For some reason, lparse chokes on hotel(1..5). Enumerating them all works.
1 { hotel(1), hotel(2), hotel(3), hotel(4), hotel(5) } 1.
star(1,5). star(2,4). star(3,3). star(4,3). star(5,2).
cost(1,170). cost(2,140). cost(3,90). cost(4,75). cost(5,60).
main_street(4).
noisy :- hotel(X), main_street(X).
maximize [ hotel(X) : star(X,Y) = Y ].
minimize [ hotel(X) : cost(X,Y) : star(X,Z) = Y/Z ].
minimize { noisy }.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment