I started sicstus prolog recently and have this homework to solve with CLP (constraint logic programing), please help me understand the problem, what I should be looking for and what I'm doing wrong. So,
A building company:
- To get raw material the BC has to rent a truck that takes 6 days to transport 25T of raw materials, and it costs 80$ a day.
- To build above the ground 15T of raw material is needed, it takes 10 days and costs 150$ per floor.
- To build underground 20T of raw material is needed, it takes 23 days (due to excavating), costs 150$ and at least one excavating machine is needed that adds 75$ per day and reduces excavating time by 3 days (two machines max at a time). (1->20days,2->17days)
- If a crane is rented all building time is reduced by 25% and has a cost of 120$ a day.
- The electric team can only advance when 75% of the building is built, it takes 5 days and costs 200$ per floor. And when the building is complete one more week is needed to finish all floors connections.
The BC pretends to build a Skyscrapers with 150 floors above ground and 15 underground, how must the building be organized so profit is maximized and and time required minimized?
Define the problem as a constraint satisfaction problem and solve it with CLP so it is possible to solve it with different parameters (more or less floors, or adjusting teams sobreposition times).
And what I have so far:
:- use_module(library(clpfd)).
start(Fdigs,Floors,Vars):-
length(Vars,5),
%S -> start, E -> end, D -> duration
%t -> transport, e -> excavating, f -> floor (build)
Vars=[St,Et,Se,Ee,Cost],
Se #>= Et,
Ee #= Se + 10,
Et #>=6,
Cost #>= Ee * 80, %transport cost since it starts at 0 Ee will be the days needed
domain(Vars,0,2000),
construct(0,Fdigs,Floors,Vars),
labeling([minimize(Cost)],Vars).
construct(Stock,0,Floors,Vars).
construct(Stock,Fdigs,Floors,[St,Et,Se,Ee,Cost]):-
Tasks=[
task(St,6,Et,0,1), %transport task
task(Se,10,Ee,5,2) %dig task, 5 because I'm digging all then building (20-15)
%10 because build is 10 so dig is 10
],
cumulative(Tasks,[limit(Stock)]),
Nfdigs is Fdigs - 1,
Nstock is Stock + 25,
construct(Nstock,Nfdigs,[Et,_Et,Ee,_Ee,Cost]).
And it doesn't work of course, because I cannot use cumulative with a task requiring 5 resources and a limit of 0 resources is the first of many issues I can't get around...