planning

Prolog planning using retract and assert

僤鯓⒐⒋嵵緔 提交于 2019-11-29 17:40:35
I wonder, is it possible to do planning in Prolog using the knowledge base modified by retract and assert during the runtime? My idea is as follows: assume that I need to replace a flat tire of a car. I can either put something on the ground or move something from the ground to some free place. So I came up with such a code: at(flat, axle). at(spare, trunk). free(Where) :- at(_, Where), !, fail. remove(What) :- at(What, _), retract(at(What, _)), assert(at(What, ground)). put_on(What, Where) :- at(What, _), free(Where), retract(at(What, _)), assert(at(What, Where)). (I am a rookie in Prolog so

How to return only work time from reservations in PostgreSql?

限于喜欢 提交于 2019-11-29 07:36:54
Select from great answer in How to find first free time in reservations table in PostgreSql create table reservation (during tsrange, EXCLUDE USING gist (during WITH &&) ); is used to find gaps in schedule starting at given date and hour (2012-11-17 8: in sample below) It finds saturday, sunday and public holidays also. Public holidays are defined in table create table pyha ( pyha date primary key) How to exclude weekends and public holidays also? Hard-coding free time as reserved to query like with gaps as ( select upper(during) as start, lead(lower(during),1,upper(during)) over (ORDER BY

How to return only work time from reservations in PostgreSql?

烂漫一生 提交于 2019-11-28 01:27:15
问题 Select from great answer in How to find first free time in reservations table in PostgreSql create table reservation (during tsrange, EXCLUDE USING gist (during WITH &&) ); is used to find gaps in schedule starting at given date and hour (2012-11-17 8: in sample below) It finds saturday, sunday and public holidays also. Public holidays are defined in table create table pyha ( pyha date primary key) How to exclude weekends and public holidays also? Hard-coding free time as reserved to query