MINERVA superseeded IF/Prolog.
Please see
http://www.ifcomputer.co.jp/MINERVA
for details.
We discontinued to sell IF/Prolog Dec 31. 2003.
Dedicated technical support for IF/Prolog ended Dec 31 2008.
This site is maintained as a community service only.
A farmer can choose to grow wheat or corn in his
fields, each crop produces a different yield
per hectare but also requires a different amount of
time for its care. There is a limit to the
maximum number of working days the farmer has
available for these crops. The following
IF/Prolog program calculates the maximum yield
achievable from his 100 hectares and 40
working days. The yield of wheat pro acre is 2.5,
while that of corn is 3.5. The time necessary
for cultivating wheat compared with that for corn
is 1:2.
:-import(const_linear).
farm(Area, WorkTime, AreaCorn, AreaWheat, Yield) :-
corn(OutputCorn, CostsCorn),
wheat(OutputWheat, CostsWheat),
all_positive([AreaCorn, AreaWheat]),
Area $>= AreaCorn + AreaWheat,
WorkTime $>= CostsCorn * AreaCorn +
CostsWheat * AreaWheat,
linear_maximize(AreaCorn * OutputCorn +
AreaWheat * OutputWheat,
Yield).
corn(0r5/2, 0r1/3).
wheat(0r7/2, 0r2/3).
[user] ?- farm(100,40,AreaCorn,AreaWheat,Yield).
AreaCorn = 80
AreaWheat = 20
Yield = 270
yes
|