:- use_module(library(clpfd)).
:- use_module('/afs/inria.fr/rocq/home/contraintes/jmartin/rules2cp/interpreter/prolog/r2cp.pl').
:- init_interpreter.

rcp_rule(first, rcp_rec([start=free_var('_',0,1),duration=0])).
rcp_rule(a1, rcp_rec([start=free_var('_',0,1),duration=4])).
rcp_rule(a2, rcp_rec([start=free_var('_',0,1),duration=2])).
rcp_rule(a3, rcp_rec([start=free_var('_',0,1),duration=2])).
rcp_rule(a4, rcp_rec([start=free_var('_',0,1),duration=2])).
rcp_rule(a5, rcp_rec([start=free_var('_',0,1),duration=2])).
rcp_rule(a6, rcp_rec([start=free_var('_',0,1),duration=5])).
rcp_rule(p1, rcp_rec([start=free_var('_',0,1),duration=20])).
rcp_rule(p2, rcp_rec([start=free_var('_',0,1),duration=13])).
rcp_rule(ue, rcp_rec([start=free_var('_',0,1),duration=10])).
rcp_rule(s1, rcp_rec([start=free_var('_',0,1),duration=8])).
rcp_rule(s2, rcp_rec([start=free_var('_',0,1),duration=4])).
rcp_rule(s3, rcp_rec([start=free_var('_',0,1),duration=4])).
rcp_rule(s4, rcp_rec([start=free_var('_',0,1),duration=4])).
rcp_rule(s5, rcp_rec([start=free_var('_',0,1),duration=4])).
rcp_rule(s6, rcp_rec([start=free_var('_',0,1),duration=10])).
rcp_rule(b1, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(b2, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(b3, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(b4, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(b5, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(b6, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(ab1, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(ab2, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(ab3, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(ab4, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(ab5, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(ab6, rcp_rec([start=free_var('_',0,1),duration=1])).
rcp_rule(m1, rcp_rec([start=free_var('_',0,1),duration=16])).
rcp_rule(m2, rcp_rec([start=free_var('_',0,1),duration=8])).
rcp_rule(m3, rcp_rec([start=free_var('_',0,1),duration=8])).
rcp_rule(m4, rcp_rec([start=free_var('_',0,1),duration=8])).
rcp_rule(m5, rcp_rec([start=free_var('_',0,1),duration=8])).
rcp_rule(m6, rcp_rec([start=free_var('_',0,1),duration=20])).
rcp_rule(l1, rcp_rec([start=free_var('_',0,1),duration=2])).
rcp_rule(t1, rcp_rec([start=free_var('_',0,1),duration=12])).
rcp_rule(t2, rcp_rec([start=free_var('_',0,1),duration=12])).
rcp_rule(t3, rcp_rec([start=free_var('_',0,1),duration=12])).
rcp_rule(t4, rcp_rec([start=free_var('_',0,1),duration=12])).
rcp_rule(t5, rcp_rec([start=free_var('_',0,1),duration=12])).
rcp_rule(ua, rcp_rec([start=free_var('_',0,1),duration=10])).
rcp_rule(v1, rcp_rec([start=free_var('_',0,1),duration=15])).
rcp_rule(v2, rcp_rec([start=free_var('_',0,1),duration=10])).
rcp_rule(k1, rcp_rec([start=free_var('_',0,1),duration=0])).
rcp_rule(k2, rcp_rec([start=free_var('_',0,1),duration=0])).
rcp_rule(last, rcp_rec([start=free_var('_',0,1),duration=0])).
rcp_rule(cost, rcp_att(start,[last])).
rcp_rule(tasks, [first,a1,a2,a3,a4,a5,a6,p1,p2,ue,s1,s2,s3,s4,s5,s6,b1,b2,b3,b4,b5,b6,ab1,ab2,ab3,ab4,ab5,ab6,m1,m2,m3,m4,m5,m6,l1,t1,t2,t3,t4,t5,ua,v1,v2,k1,k2,last]).
rcp_rule(precedences_list, [[first,a1],[first,a2],[first,a3],[first,a4],[first,a5],[first,a6],[first,ue],[a1,s1],[a2,s2],[a5,s5],[a6,s6],[a3,p1],[a4,p2],[p1,s3],[p2,s4],[p1,k1],[p2,k1],[s1,b1],[s2,b2],[s3,b3],[s4,b4],[s5,b5],[s6,b6],[b1,ab1],[b2,ab2],[b3,ab3],[b4,ab4],[b5,ab5],[b6,ab6],[ab1,m1],[ab2,m2],[ab3,m3],[ab4,m4],[ab5,m5],[ab6,m6],[m1,t1],[m2,t1],[m2,t2],[m3,t2],[m3,t3],[m4,t3],[m4,t4],[m5,t4],[m5,t5],[m6,t5],[m1,k2],[m2,k2],[m3,k2],[m4,k2],[m5,k2],[m6,k2],[l1,t1],[l1,t2],[l1,t3],[l1,t4],[l1,t5],[t1,v1],[t5,v2],[t2,last],[t3,last],[t4,last],[v1,last],[v2,last],[ua,last],[k1,last],[k2,last]]).
rcp_rule(resource_crane, [l1,t1,t2,t3,t4,t5]).
rcp_rule(resource_bricklaying, [m1,m2,m3,m4,m5,m6]).
rcp_rule(resource_schal, [s1,s2,s3,s4,s5,s6]).
rcp_rule(resource_excavator, [a1,a2,a3,a4,a5,a6]).
rcp_rule(resource_ram, [p1,p2]).
rcp_rule(resource_pump, [b1,b2,b3,b4,b5,b6]).
rcp_rule(resource_caterpillar, [v1,v2]).
rcp_rule(resources_list, [resource_crane,resource_bricklaying,resource_schal,resource_excavator,resource_ram,resource_pump,resource_caterpillar]).
rcp_rule(max_nf_list, [[first,l1,30],[a1,s1,3],[a2,s2,3],[a5,s5,3],[a6,s6,3],[p1,s3,3],[p2,s4,3]]).
rcp_rule(min_sf_list, [[ua,m1,2],[ua,m2,2],[ua,m3,2],[ua,m4,2],[ua,m5,2],[ua,m6,2]]).
rcp_rule(max_ef_list, [[s1,b1,4],[s2,b2,4],[s3,b3,4],[s4,b4,4],[s5,b5,4],[s6,b6,4]]).
rcp_rule(min_nf_list, [[first,l1,30]]).
rcp_rule(min_af_list, [[ue,s1,6],[ue,s2,6],[ue,s3,6],[ue,s4,6],[ue,s5,6],[ue,s6,6]]).
rcp_rule(end(var('Task',0)), rcp_att(start,[var('Task',0)])+rcp_att(duration,[var('Task',0)])).
rcp_rule(prec(var('T1',0),var('T2',0)), end(var('T1',0))=<rcp_att(start,[var('T2',0)])).
rcp_rule(disj(var('T1',0),var('T2',0)), prec(var('T1',0),var('T2',0))or prec(var('T2',0),var('T1',0))).
rcp_rule(precedences, foldl(var('TaskPair',58),precedences_list,and,1,prec(nth(1,var('TaskPair',58)),nth(2,var('TaskPair',58))))).
rcp_rule(disjunctives, foldl(var('Tasks',60),resources_list,and,1,disjo(var('Tasks',60)))).
rcp_rule(disjo(var('Tasks',0)), foldl(var('T1',64),var('Tasks',0),and,1,foldl(var('T2',66),var('Tasks',0),and,1,rcp_att(uid,[var('T1',64)])<rcp_att(uid,[var('T2',66)])implies disj(var('T1',64),var('T2',66))))).
rcp_rule(max_nf(var('T1',0),var('T2',0),var('N',0)), rcp_att(start,[var('T2',0)])=<end(var('T1',0))+var('N',0)).
rcp_rule(min_nf(var('T1',0),var('T2',0),var('N',0)), rcp_att(start,[var('T2',0)])>=rcp_att(start,[var('T1',0)])+2*rcp_att(duration,[var('T1',0)])+var('N',0)).
rcp_rule(max_ef(var('T1',0),var('T2',0),var('N',0)), end(var('T2',0))=<end(var('T1',0))+var('N',0)).
rcp_rule(min_af(var('T1',0),var('T2',0),var('N',0)), rcp_att(start,[var('T2',0)])>=rcp_att(start,[var('T1',0)])+var('N',0)).
rcp_rule(min_sf(var('T1',0),var('T2',0),var('N',0)), end(var('T2',0))=<rcp_att(start,[var('T1',0)])+var('N',0)).
rcp_rule(distances, foldl(var('T',72),max_nf_list,and,1,max_nf(nth(1,var('T',72)),nth(2,var('T',72)),nth(3,var('T',72))))and foldl(var('T',73),min_sf_list,and,1,min_sf(nth(1,var('T',73)),nth(2,var('T',73)),nth(3,var('T',73))))and foldl(var('T',74),max_ef_list,and,1,max_ef(nth(1,var('T',74)),nth(2,var('T',74)),nth(3,var('T',74))))and foldl(var('T',75),min_nf_list,and,1,min_nf(nth(1,var('T',75)),nth(2,var('T',75)),nth(3,var('T',75))))and foldl(var('T',76),min_af_list,and,1,min_af(nth(1,var('T',76)),nth(2,var('T',76)),nth(3,var('T',76))))).
rcp_rule(tasks_domain, domain(variables(foldr(var('T',78),tasks,cons,[],rcp_att(start,[var('T',78)]))),0,200)).
rcp_rule(minimize_completion_time, conjunct_ordering([greatest(rcp_att(duration,[var('A',0)])+rcp_att(duration,[var('B',0)])if^is disj(var('A',0),var('B',0)))])and disjunct_ordering([greatest(rcp_att(duration,[var('A',0)])if^is prec(var('A',0),var('B',0)))])and minimize(search(disjunctives),cost)).
rcp_rule(solve_query, tasks_domain and precedences and distances and minimize_completion_time).


first(_A_) :- 
	rcp_var(from(first,0,1), First),
	rcp_rec([start=First,duration=0], _A_).

first_search(_A_) :- 
	rcp_var(from(first,0,1), First),
	rcp_rec([start=First,duration=0], _A_).

a1(_A_) :- 
	rcp_var(from(a1,0,1), A1),
	rcp_rec([start=A1,duration=4], _A_).

a1_search(_A_) :- 
	rcp_var(from(a1,0,1), A1),
	rcp_rec([start=A1,duration=4], _A_).

a2(_A_) :- 
	rcp_var(from(a2,0,1), A2),
	rcp_rec([start=A2,duration=2], _A_).

a2_search(_A_) :- 
	rcp_var(from(a2,0,1), A2),
	rcp_rec([start=A2,duration=2], _A_).

a3(_A_) :- 
	rcp_var(from(a3,0,1), A3),
	rcp_rec([start=A3,duration=2], _A_).

a3_search(_A_) :- 
	rcp_var(from(a3,0,1), A3),
	rcp_rec([start=A3,duration=2], _A_).

a4(_A_) :- 
	rcp_var(from(a4,0,1), A4),
	rcp_rec([start=A4,duration=2], _A_).

a4_search(_A_) :- 
	rcp_var(from(a4,0,1), A4),
	rcp_rec([start=A4,duration=2], _A_).

a5(_A_) :- 
	rcp_var(from(a5,0,1), A5),
	rcp_rec([start=A5,duration=2], _A_).

a5_search(_A_) :- 
	rcp_var(from(a5,0,1), A5),
	rcp_rec([start=A5,duration=2], _A_).

a6(_A_) :- 
	rcp_var(from(a6,0,1), A6),
	rcp_rec([start=A6,duration=5], _A_).

a6_search(_A_) :- 
	rcp_var(from(a6,0,1), A6),
	rcp_rec([start=A6,duration=5], _A_).

p1(_A_) :- 
	rcp_var(from(p1,0,1), P1),
	rcp_rec([start=P1,duration=20], _A_).

p1_search(_A_) :- 
	rcp_var(from(p1,0,1), P1),
	rcp_rec([start=P1,duration=20], _A_).

p2(_A_) :- 
	rcp_var(from(p2,0,1), P2),
	rcp_rec([start=P2,duration=13], _A_).

p2_search(_A_) :- 
	rcp_var(from(p2,0,1), P2),
	rcp_rec([start=P2,duration=13], _A_).

ue(_A_) :- 
	rcp_var(from(ue,0,1), Ue),
	rcp_rec([start=Ue,duration=10], _A_).

ue_search(_A_) :- 
	rcp_var(from(ue,0,1), Ue),
	rcp_rec([start=Ue,duration=10], _A_).

s1(_A_) :- 
	rcp_var(from(s1,0,1), S1),
	rcp_rec([start=S1,duration=8], _A_).

s1_search(_A_) :- 
	rcp_var(from(s1,0,1), S1),
	rcp_rec([start=S1,duration=8], _A_).

s2(_A_) :- 
	rcp_var(from(s2,0,1), S2),
	rcp_rec([start=S2,duration=4], _A_).

s2_search(_A_) :- 
	rcp_var(from(s2,0,1), S2),
	rcp_rec([start=S2,duration=4], _A_).

s3(_A_) :- 
	rcp_var(from(s3,0,1), S3),
	rcp_rec([start=S3,duration=4], _A_).

s3_search(_A_) :- 
	rcp_var(from(s3,0,1), S3),
	rcp_rec([start=S3,duration=4], _A_).

s4(_A_) :- 
	rcp_var(from(s4,0,1), S4),
	rcp_rec([start=S4,duration=4], _A_).

s4_search(_A_) :- 
	rcp_var(from(s4,0,1), S4),
	rcp_rec([start=S4,duration=4], _A_).

s5(_A_) :- 
	rcp_var(from(s5,0,1), S5),
	rcp_rec([start=S5,duration=4], _A_).

s5_search(_A_) :- 
	rcp_var(from(s5,0,1), S5),
	rcp_rec([start=S5,duration=4], _A_).

s6(_A_) :- 
	rcp_var(from(s6,0,1), S6),
	rcp_rec([start=S6,duration=10], _A_).

s6_search(_A_) :- 
	rcp_var(from(s6,0,1), S6),
	rcp_rec([start=S6,duration=10], _A_).

b1(_A_) :- 
	rcp_var(from(b1,0,1), B1),
	rcp_rec([start=B1,duration=1], _A_).

b1_search(_A_) :- 
	rcp_var(from(b1,0,1), B1),
	rcp_rec([start=B1,duration=1], _A_).

b2(_A_) :- 
	rcp_var(from(b2,0,1), B2),
	rcp_rec([start=B2,duration=1], _A_).

b2_search(_A_) :- 
	rcp_var(from(b2,0,1), B2),
	rcp_rec([start=B2,duration=1], _A_).

b3(_A_) :- 
	rcp_var(from(b3,0,1), B3),
	rcp_rec([start=B3,duration=1], _A_).

b3_search(_A_) :- 
	rcp_var(from(b3,0,1), B3),
	rcp_rec([start=B3,duration=1], _A_).

b4(_A_) :- 
	rcp_var(from(b4,0,1), B4),
	rcp_rec([start=B4,duration=1], _A_).

b4_search(_A_) :- 
	rcp_var(from(b4,0,1), B4),
	rcp_rec([start=B4,duration=1], _A_).

b5(_A_) :- 
	rcp_var(from(b5,0,1), B5),
	rcp_rec([start=B5,duration=1], _A_).

b5_search(_A_) :- 
	rcp_var(from(b5,0,1), B5),
	rcp_rec([start=B5,duration=1], _A_).

b6(_A_) :- 
	rcp_var(from(b6,0,1), B6),
	rcp_rec([start=B6,duration=1], _A_).

b6_search(_A_) :- 
	rcp_var(from(b6,0,1), B6),
	rcp_rec([start=B6,duration=1], _A_).

ab1(_A_) :- 
	rcp_var(from(ab1,0,1), Ab1),
	rcp_rec([start=Ab1,duration=1], _A_).

ab1_search(_A_) :- 
	rcp_var(from(ab1,0,1), Ab1),
	rcp_rec([start=Ab1,duration=1], _A_).

ab2(_A_) :- 
	rcp_var(from(ab2,0,1), Ab2),
	rcp_rec([start=Ab2,duration=1], _A_).

ab2_search(_A_) :- 
	rcp_var(from(ab2,0,1), Ab2),
	rcp_rec([start=Ab2,duration=1], _A_).

ab3(_A_) :- 
	rcp_var(from(ab3,0,1), Ab3),
	rcp_rec([start=Ab3,duration=1], _A_).

ab3_search(_A_) :- 
	rcp_var(from(ab3,0,1), Ab3),
	rcp_rec([start=Ab3,duration=1], _A_).

ab4(_A_) :- 
	rcp_var(from(ab4,0,1), Ab4),
	rcp_rec([start=Ab4,duration=1], _A_).

ab4_search(_A_) :- 
	rcp_var(from(ab4,0,1), Ab4),
	rcp_rec([start=Ab4,duration=1], _A_).

ab5(_A_) :- 
	rcp_var(from(ab5,0,1), Ab5),
	rcp_rec([start=Ab5,duration=1], _A_).

ab5_search(_A_) :- 
	rcp_var(from(ab5,0,1), Ab5),
	rcp_rec([start=Ab5,duration=1], _A_).

ab6(_A_) :- 
	rcp_var(from(ab6,0,1), Ab6),
	rcp_rec([start=Ab6,duration=1], _A_).

ab6_search(_A_) :- 
	rcp_var(from(ab6,0,1), Ab6),
	rcp_rec([start=Ab6,duration=1], _A_).

m1(_A_) :- 
	rcp_var(from(m1,0,1), M1),
	rcp_rec([start=M1,duration=16], _A_).

m1_search(_A_) :- 
	rcp_var(from(m1,0,1), M1),
	rcp_rec([start=M1,duration=16], _A_).

m2(_A_) :- 
	rcp_var(from(m2,0,1), M2),
	rcp_rec([start=M2,duration=8], _A_).

m2_search(_A_) :- 
	rcp_var(from(m2,0,1), M2),
	rcp_rec([start=M2,duration=8], _A_).

m3(_A_) :- 
	rcp_var(from(m3,0,1), M3),
	rcp_rec([start=M3,duration=8], _A_).

m3_search(_A_) :- 
	rcp_var(from(m3,0,1), M3),
	rcp_rec([start=M3,duration=8], _A_).

m4(_A_) :- 
	rcp_var(from(m4,0,1), M4),
	rcp_rec([start=M4,duration=8], _A_).

m4_search(_A_) :- 
	rcp_var(from(m4,0,1), M4),
	rcp_rec([start=M4,duration=8], _A_).

m5(_A_) :- 
	rcp_var(from(m5,0,1), M5),
	rcp_rec([start=M5,duration=8], _A_).

m5_search(_A_) :- 
	rcp_var(from(m5,0,1), M5),
	rcp_rec([start=M5,duration=8], _A_).

m6(_A_) :- 
	rcp_var(from(m6,0,1), M6),
	rcp_rec([start=M6,duration=20], _A_).

m6_search(_A_) :- 
	rcp_var(from(m6,0,1), M6),
	rcp_rec([start=M6,duration=20], _A_).

l1(_A_) :- 
	rcp_var(from(l1,0,1), L1),
	rcp_rec([start=L1,duration=2], _A_).

l1_search(_A_) :- 
	rcp_var(from(l1,0,1), L1),
	rcp_rec([start=L1,duration=2], _A_).

t1(_A_) :- 
	rcp_var(from(t1,0,1), T1),
	rcp_rec([start=T1,duration=12], _A_).

t1_search(_A_) :- 
	rcp_var(from(t1,0,1), T1),
	rcp_rec([start=T1,duration=12], _A_).

t2(_A_) :- 
	rcp_var(from(t2,0,1), T2),
	rcp_rec([start=T2,duration=12], _A_).

t2_search(_A_) :- 
	rcp_var(from(t2,0,1), T2),
	rcp_rec([start=T2,duration=12], _A_).

t3(_A_) :- 
	rcp_var(from(t3,0,1), T3),
	rcp_rec([start=T3,duration=12], _A_).

t3_search(_A_) :- 
	rcp_var(from(t3,0,1), T3),
	rcp_rec([start=T3,duration=12], _A_).

t4(_A_) :- 
	rcp_var(from(t4,0,1), T4),
	rcp_rec([start=T4,duration=12], _A_).

t4_search(_A_) :- 
	rcp_var(from(t4,0,1), T4),
	rcp_rec([start=T4,duration=12], _A_).

t5(_A_) :- 
	rcp_var(from(t5,0,1), T5),
	rcp_rec([start=T5,duration=12], _A_).

t5_search(_A_) :- 
	rcp_var(from(t5,0,1), T5),
	rcp_rec([start=T5,duration=12], _A_).

ua(_A_) :- 
	rcp_var(from(ua,0,1), Ua),
	rcp_rec([start=Ua,duration=10], _A_).

ua_search(_A_) :- 
	rcp_var(from(ua,0,1), Ua),
	rcp_rec([start=Ua,duration=10], _A_).

v1(_A_) :- 
	rcp_var(from(v1,0,1), V1),
	rcp_rec([start=V1,duration=15], _A_).

v1_search(_A_) :- 
	rcp_var(from(v1,0,1), V1),
	rcp_rec([start=V1,duration=15], _A_).

v2(_A_) :- 
	rcp_var(from(v2,0,1), V2),
	rcp_rec([start=V2,duration=10], _A_).

v2_search(_A_) :- 
	rcp_var(from(v2,0,1), V2),
	rcp_rec([start=V2,duration=10], _A_).

k1(_A_) :- 
	rcp_var(from(k1,0,1), K1),
	rcp_rec([start=K1,duration=0], _A_).

k1_search(_A_) :- 
	rcp_var(from(k1,0,1), K1),
	rcp_rec([start=K1,duration=0], _A_).

k2(_A_) :- 
	rcp_var(from(k2,0,1), K2),
	rcp_rec([start=K2,duration=0], _A_).

k2_search(_A_) :- 
	rcp_var(from(k2,0,1), K2),
	rcp_rec([start=K2,duration=0], _A_).

last(_A_) :- 
	rcp_var(from(last,0,1), Last),
	rcp_rec([start=Last,duration=0], _A_).

last_search(_A_) :- 
	rcp_var(from(last,0,1), Last),
	rcp_rec([start=Last,duration=0], _A_).

cost(_B_) :- 
	last(_A_),
	rcp_att(start, _A_, _B_).

cost_search(_B_) :- 
	last_search(_A_),
	rcp_att(start, _A_, _B_).

tasks(_V1_) :- 
	first(_A_),
	a1(_B_),
	a2(_C_),
	a3(_D_),
	a4(_E_),
	a5(_F_),
	a6(_G_),
	p1(_H_),
	p2(_I_),
	ue(_J_),
	s1(_K_),
	s2(_L_),
	s3(_M_),
	s4(_N_),
	s5(_O_),
	s6(_P_),
	b1(_Q_),
	b2(_R_),
	b3(_S_),
	b4(_T_),
	b5(_U_),
	b6(_V_),
	ab1(_W_),
	ab2(_X_),
	ab3(_Y_),
	ab4(_Z_),
	ab5(_B1_),
	ab6(_C1_),
	m1(_D1_),
	m2(_E1_),
	m3(_F1_),
	m4(_G1_),
	m5(_H1_),
	m6(_I1_),
	l1(_J1_),
	t1(_K1_),
	t2(_L1_),
	t3(_M1_),
	t4(_N1_),
	t5(_O1_),
	ua(_P1_),
	v1(_Q1_),
	v2(_R1_),
	k1(_S1_),
	k2(_T1_),
	last(_U1_),
	_V1_=[_A_,_B_,_C_,_D_,_E_,_F_,_G_,_H_,_I_,_J_,_K_,_L_,_M_,_N_,_O_,_P_,_Q_,_R_,_S_,_T_,_U_,_V_,_W_,_X_,_Y_,_Z_,_B1_,_C1_,_D1_,_E1_,_F1_,_G1_,_H1_,_I1_,_J1_,_K1_,_L1_,_M1_,_N1_,_O1_,_P1_,_Q1_,_R1_,_S1_,_T1_,_U1_].

tasks_search(_V1_) :- 
	first_search(_A_),
	a1_search(_B_),
	a2_search(_C_),
	a3_search(_D_),
	a4_search(_E_),
	a5_search(_F_),
	a6_search(_G_),
	p1_search(_H_),
	p2_search(_I_),
	ue_search(_J_),
	s1_search(_K_),
	s2_search(_L_),
	s3_search(_M_),
	s4_search(_N_),
	s5_search(_O_),
	s6_search(_P_),
	b1_search(_Q_),
	b2_search(_R_),
	b3_search(_S_),
	b4_search(_T_),
	b5_search(_U_),
	b6_search(_V_),
	ab1_search(_W_),
	ab2_search(_X_),
	ab3_search(_Y_),
	ab4_search(_Z_),
	ab5_search(_B1_),
	ab6_search(_C1_),
	m1_search(_D1_),
	m2_search(_E1_),
	m3_search(_F1_),
	m4_search(_G1_),
	m5_search(_H1_),
	m6_search(_I1_),
	l1_search(_J1_),
	t1_search(_K1_),
	t2_search(_L1_),
	t3_search(_M1_),
	t4_search(_N1_),
	t5_search(_O1_),
	ua_search(_P1_),
	v1_search(_Q1_),
	v2_search(_R1_),
	k1_search(_S1_),
	k2_search(_T1_),
	last_search(_U1_),
	_V1_=[_A_,_B_,_C_,_D_,_E_,_F_,_G_,_H_,_I_,_J_,_K_,_L_,_M_,_N_,_O_,_P_,_Q_,_R_,_S_,_T_,_U_,_V_,_W_,_X_,_Y_,_Z_,_B1_,_C1_,_D1_,_E1_,_F1_,_G1_,_H1_,_I1_,_J1_,_K1_,_L1_,_M1_,_N1_,_O1_,_P1_,_Q1_,_R1_,_S1_,_T1_,_U1_].

precedences_list(_D5_) :- 
	first(_A_),
	a1(_B_),
	first(_C_),
	a2(_D_),
	first(_E_),
	a3(_F_),
	first(_G_),
	a4(_H_),
	first(_I_),
	a5(_J_),
	first(_K_),
	a6(_L_),
	first(_M_),
	ue(_N_),
	a1(_O_),
	s1(_P_),
	a2(_Q_),
	s2(_R_),
	a5(_S_),
	s5(_T_),
	a6(_U_),
	s6(_V_),
	a3(_W_),
	p1(_X_),
	a4(_Y_),
	p2(_Z_),
	p1(_B1_),
	s3(_C1_),
	p2(_D1_),
	s4(_E1_),
	p1(_F1_),
	k1(_G1_),
	p2(_H1_),
	k1(_I1_),
	s1(_J1_),
	b1(_K1_),
	s2(_L1_),
	b2(_M1_),
	s3(_N1_),
	b3(_O1_),
	s4(_P1_),
	b4(_Q1_),
	s5(_R1_),
	b5(_S1_),
	s6(_T1_),
	b6(_U1_),
	b1(_V1_),
	ab1(_W1_),
	b2(_X1_),
	ab2(_Y1_),
	b3(_Z1_),
	ab3(_A2_),
	b4(_B2_),
	ab4(_C2_),
	b5(_D2_),
	ab5(_E2_),
	b6(_F2_),
	ab6(_G2_),
	ab1(_H2_),
	m1(_I2_),
	ab2(_J2_),
	m2(_K2_),
	ab3(_L2_),
	m3(_M2_),
	ab4(_N2_),
	m4(_O2_),
	ab5(_P2_),
	m5(_Q2_),
	ab6(_R2_),
	m6(_S2_),
	m1(_T2_),
	t1(_U2_),
	m2(_V2_),
	t1(_W2_),
	m2(_X2_),
	t2(_Y2_),
	m3(_Z2_),
	t2(_A3_),
	m3(_B3_),
	t3(_C3_),
	m4(_D3_),
	t3(_E3_),
	m4(_F3_),
	t4(_G3_),
	m5(_H3_),
	t4(_I3_),
	m5(_J3_),
	t5(_K3_),
	m6(_L3_),
	t5(_M3_),
	m1(_N3_),
	k2(_O3_),
	m2(_P3_),
	k2(_Q3_),
	m3(_R3_),
	k2(_S3_),
	m4(_T3_),
	k2(_U3_),
	m5(_V3_),
	k2(_W3_),
	m6(_X3_),
	k2(_Y3_),
	l1(_Z3_),
	t1(_A4_),
	l1(_B4_),
	t2(_C4_),
	l1(_D4_),
	t3(_E4_),
	l1(_F4_),
	t4(_G4_),
	l1(_H4_),
	t5(_I4_),
	t1(_J4_),
	v1(_K4_),
	t5(_L4_),
	v2(_M4_),
	t2(_N4_),
	last(_O4_),
	t3(_P4_),
	last(_Q4_),
	t4(_R4_),
	last(_S4_),
	v1(_T4_),
	last(_U4_),
	v2(_V4_),
	last(_W4_),
	ua(_X4_),
	last(_Y4_),
	k1(_Z4_),
	last(_A5_),
	k2(_B5_),
	last(_C5_),
	_D5_=[[_A_,_B_],[_C_,_D_],[_E_,_F_],[_G_,_H_],[_I_,_J_],[_K_,_L_],[_M_,_N_],[_O_,_P_],[_Q_,_R_],[_S_,_T_],[_U_,_V_],[_W_,_X_],[_Y_,_Z_],[_B1_,_C1_],[_D1_,_E1_],[_F1_,_G1_],[_H1_,_I1_],[_J1_,_K1_],[_L1_,_M1_],[_N1_,_O1_],[_P1_,_Q1_],[_R1_,_S1_],[_T1_,_U1_],[_V1_,_W1_],[_X1_,_Y1_],[_Z1_,_A2_],[_B2_,_C2_],[_D2_,_E2_],[_F2_,_G2_],[_H2_,_I2_],[_J2_,_K2_],[_L2_,_M2_],[_N2_,_O2_],[_P2_,_Q2_],[_R2_,_S2_],[_T2_,_U2_],[_V2_,_W2_],[_X2_,_Y2_],[_Z2_,_A3_],[_B3_,_C3_],[_D3_,_E3_],[_F3_,_G3_],[_H3_,_I3_],[_J3_,_K3_],[_L3_,_M3_],[_N3_,_O3_],[_P3_,_Q3_],[_R3_,_S3_],[_T3_,_U3_],[_V3_,_W3_],[_X3_,_Y3_],[_Z3_,_A4_],[_B4_,_C4_],[_D4_,_E4_],[_F4_,_G4_],[_H4_,_I4_],[_J4_,_K4_],[_L4_,_M4_],[_N4_,_O4_],[_P4_,_Q4_],[_R4_,_S4_],[_T4_,_U4_],[_V4_,_W4_],[_X4_,_Y4_],[_Z4_,_A5_],[_B5_,_C5_]].

precedences_list_search(_D5_) :- 
	first_search(_A_),
	a1_search(_B_),
	first_search(_C_),
	a2_search(_D_),
	first_search(_E_),
	a3_search(_F_),
	first_search(_G_),
	a4_search(_H_),
	first_search(_I_),
	a5_search(_J_),
	first_search(_K_),
	a6_search(_L_),
	first_search(_M_),
	ue_search(_N_),
	a1_search(_O_),
	s1_search(_P_),
	a2_search(_Q_),
	s2_search(_R_),
	a5_search(_S_),
	s5_search(_T_),
	a6_search(_U_),
	s6_search(_V_),
	a3_search(_W_),
	p1_search(_X_),
	a4_search(_Y_),
	p2_search(_Z_),
	p1_search(_B1_),
	s3_search(_C1_),
	p2_search(_D1_),
	s4_search(_E1_),
	p1_search(_F1_),
	k1_search(_G1_),
	p2_search(_H1_),
	k1_search(_I1_),
	s1_search(_J1_),
	b1_search(_K1_),
	s2_search(_L1_),
	b2_search(_M1_),
	s3_search(_N1_),
	b3_search(_O1_),
	s4_search(_P1_),
	b4_search(_Q1_),
	s5_search(_R1_),
	b5_search(_S1_),
	s6_search(_T1_),
	b6_search(_U1_),
	b1_search(_V1_),
	ab1_search(_W1_),
	b2_search(_X1_),
	ab2_search(_Y1_),
	b3_search(_Z1_),
	ab3_search(_A2_),
	b4_search(_B2_),
	ab4_search(_C2_),
	b5_search(_D2_),
	ab5_search(_E2_),
	b6_search(_F2_),
	ab6_search(_G2_),
	ab1_search(_H2_),
	m1_search(_I2_),
	ab2_search(_J2_),
	m2_search(_K2_),
	ab3_search(_L2_),
	m3_search(_M2_),
	ab4_search(_N2_),
	m4_search(_O2_),
	ab5_search(_P2_),
	m5_search(_Q2_),
	ab6_search(_R2_),
	m6_search(_S2_),
	m1_search(_T2_),
	t1_search(_U2_),
	m2_search(_V2_),
	t1_search(_W2_),
	m2_search(_X2_),
	t2_search(_Y2_),
	m3_search(_Z2_),
	t2_search(_A3_),
	m3_search(_B3_),
	t3_search(_C3_),
	m4_search(_D3_),
	t3_search(_E3_),
	m4_search(_F3_),
	t4_search(_G3_),
	m5_search(_H3_),
	t4_search(_I3_),
	m5_search(_J3_),
	t5_search(_K3_),
	m6_search(_L3_),
	t5_search(_M3_),
	m1_search(_N3_),
	k2_search(_O3_),
	m2_search(_P3_),
	k2_search(_Q3_),
	m3_search(_R3_),
	k2_search(_S3_),
	m4_search(_T3_),
	k2_search(_U3_),
	m5_search(_V3_),
	k2_search(_W3_),
	m6_search(_X3_),
	k2_search(_Y3_),
	l1_search(_Z3_),
	t1_search(_A4_),
	l1_search(_B4_),
	t2_search(_C4_),
	l1_search(_D4_),
	t3_search(_E4_),
	l1_search(_F4_),
	t4_search(_G4_),
	l1_search(_H4_),
	t5_search(_I4_),
	t1_search(_J4_),
	v1_search(_K4_),
	t5_search(_L4_),
	v2_search(_M4_),
	t2_search(_N4_),
	last_search(_O4_),
	t3_search(_P4_),
	last_search(_Q4_),
	t4_search(_R4_),
	last_search(_S4_),
	v1_search(_T4_),
	last_search(_U4_),
	v2_search(_V4_),
	last_search(_W4_),
	ua_search(_X4_),
	last_search(_Y4_),
	k1_search(_Z4_),
	last_search(_A5_),
	k2_search(_B5_),
	last_search(_C5_),
	_D5_=[[_A_,_B_],[_C_,_D_],[_E_,_F_],[_G_,_H_],[_I_,_J_],[_K_,_L_],[_M_,_N_],[_O_,_P_],[_Q_,_R_],[_S_,_T_],[_U_,_V_],[_W_,_X_],[_Y_,_Z_],[_B1_,_C1_],[_D1_,_E1_],[_F1_,_G1_],[_H1_,_I1_],[_J1_,_K1_],[_L1_,_M1_],[_N1_,_O1_],[_P1_,_Q1_],[_R1_,_S1_],[_T1_,_U1_],[_V1_,_W1_],[_X1_,_Y1_],[_Z1_,_A2_],[_B2_,_C2_],[_D2_,_E2_],[_F2_,_G2_],[_H2_,_I2_],[_J2_,_K2_],[_L2_,_M2_],[_N2_,_O2_],[_P2_,_Q2_],[_R2_,_S2_],[_T2_,_U2_],[_V2_,_W2_],[_X2_,_Y2_],[_Z2_,_A3_],[_B3_,_C3_],[_D3_,_E3_],[_F3_,_G3_],[_H3_,_I3_],[_J3_,_K3_],[_L3_,_M3_],[_N3_,_O3_],[_P3_,_Q3_],[_R3_,_S3_],[_T3_,_U3_],[_V3_,_W3_],[_X3_,_Y3_],[_Z3_,_A4_],[_B4_,_C4_],[_D4_,_E4_],[_F4_,_G4_],[_H4_,_I4_],[_J4_,_K4_],[_L4_,_M4_],[_N4_,_O4_],[_P4_,_Q4_],[_R4_,_S4_],[_T4_,_U4_],[_V4_,_W4_],[_X4_,_Y4_],[_Z4_,_A5_],[_B5_,_C5_]].

resource_crane(_G_) :- 
	l1(_A_),
	t1(_B_),
	t2(_C_),
	t3(_D_),
	t4(_E_),
	t5(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_crane_search(_G_) :- 
	l1_search(_A_),
	t1_search(_B_),
	t2_search(_C_),
	t3_search(_D_),
	t4_search(_E_),
	t5_search(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_bricklaying(_G_) :- 
	m1(_A_),
	m2(_B_),
	m3(_C_),
	m4(_D_),
	m5(_E_),
	m6(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_bricklaying_search(_G_) :- 
	m1_search(_A_),
	m2_search(_B_),
	m3_search(_C_),
	m4_search(_D_),
	m5_search(_E_),
	m6_search(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_schal(_G_) :- 
	s1(_A_),
	s2(_B_),
	s3(_C_),
	s4(_D_),
	s5(_E_),
	s6(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_schal_search(_G_) :- 
	s1_search(_A_),
	s2_search(_B_),
	s3_search(_C_),
	s4_search(_D_),
	s5_search(_E_),
	s6_search(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_excavator(_G_) :- 
	a1(_A_),
	a2(_B_),
	a3(_C_),
	a4(_D_),
	a5(_E_),
	a6(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_excavator_search(_G_) :- 
	a1_search(_A_),
	a2_search(_B_),
	a3_search(_C_),
	a4_search(_D_),
	a5_search(_E_),
	a6_search(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_ram(_C_) :- 
	p1(_A_),
	p2(_B_),
	_C_=[_A_,_B_].

resource_ram_search(_C_) :- 
	p1_search(_A_),
	p2_search(_B_),
	_C_=[_A_,_B_].

resource_pump(_G_) :- 
	b1(_A_),
	b2(_B_),
	b3(_C_),
	b4(_D_),
	b5(_E_),
	b6(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_pump_search(_G_) :- 
	b1_search(_A_),
	b2_search(_B_),
	b3_search(_C_),
	b4_search(_D_),
	b5_search(_E_),
	b6_search(_F_),
	_G_=[_A_,_B_,_C_,_D_,_E_,_F_].

resource_caterpillar(_C_) :- 
	v1(_A_),
	v2(_B_),
	_C_=[_A_,_B_].

resource_caterpillar_search(_C_) :- 
	v1_search(_A_),
	v2_search(_B_),
	_C_=[_A_,_B_].

resources_list(_H_) :- 
	resource_crane(_A_),
	resource_bricklaying(_B_),
	resource_schal(_C_),
	resource_excavator(_D_),
	resource_ram(_E_),
	resource_pump(_F_),
	resource_caterpillar(_G_),
	_H_=[_A_,_B_,_C_,_D_,_E_,_F_,_G_].

resources_list_search(_H_) :- 
	resource_crane_search(_A_),
	resource_bricklaying_search(_B_),
	resource_schal_search(_C_),
	resource_excavator_search(_D_),
	resource_ram_search(_E_),
	resource_pump_search(_F_),
	resource_caterpillar_search(_G_),
	_H_=[_A_,_B_,_C_,_D_,_E_,_F_,_G_].

max_nf_list(_O_) :- 
	first(_A_),
	l1(_B_),
	a1(_C_),
	s1(_D_),
	a2(_E_),
	s2(_F_),
	a5(_G_),
	s5(_H_),
	a6(_I_),
	s6(_J_),
	p1(_K_),
	s3(_L_),
	p2(_M_),
	s4(_N_),
	_O_=[[_A_,_B_,30],[_C_,_D_,3],[_E_,_F_,3],[_G_,_H_,3],[_I_,_J_,3],[_K_,_L_,3],[_M_,_N_,3]].

max_nf_list_search(_O_) :- 
	first_search(_A_),
	l1_search(_B_),
	a1_search(_C_),
	s1_search(_D_),
	a2_search(_E_),
	s2_search(_F_),
	a5_search(_G_),
	s5_search(_H_),
	a6_search(_I_),
	s6_search(_J_),
	p1_search(_K_),
	s3_search(_L_),
	p2_search(_M_),
	s4_search(_N_),
	_O_=[[_A_,_B_,30],[_C_,_D_,3],[_E_,_F_,3],[_G_,_H_,3],[_I_,_J_,3],[_K_,_L_,3],[_M_,_N_,3]].

min_sf_list(_M_) :- 
	ua(_A_),
	m1(_B_),
	ua(_C_),
	m2(_D_),
	ua(_E_),
	m3(_F_),
	ua(_G_),
	m4(_H_),
	ua(_I_),
	m5(_J_),
	ua(_K_),
	m6(_L_),
	_M_=[[_A_,_B_,2],[_C_,_D_,2],[_E_,_F_,2],[_G_,_H_,2],[_I_,_J_,2],[_K_,_L_,2]].

min_sf_list_search(_M_) :- 
	ua_search(_A_),
	m1_search(_B_),
	ua_search(_C_),
	m2_search(_D_),
	ua_search(_E_),
	m3_search(_F_),
	ua_search(_G_),
	m4_search(_H_),
	ua_search(_I_),
	m5_search(_J_),
	ua_search(_K_),
	m6_search(_L_),
	_M_=[[_A_,_B_,2],[_C_,_D_,2],[_E_,_F_,2],[_G_,_H_,2],[_I_,_J_,2],[_K_,_L_,2]].

max_ef_list(_M_) :- 
	s1(_A_),
	b1(_B_),
	s2(_C_),
	b2(_D_),
	s3(_E_),
	b3(_F_),
	s4(_G_),
	b4(_H_),
	s5(_I_),
	b5(_J_),
	s6(_K_),
	b6(_L_),
	_M_=[[_A_,_B_,4],[_C_,_D_,4],[_E_,_F_,4],[_G_,_H_,4],[_I_,_J_,4],[_K_,_L_,4]].

max_ef_list_search(_M_) :- 
	s1_search(_A_),
	b1_search(_B_),
	s2_search(_C_),
	b2_search(_D_),
	s3_search(_E_),
	b3_search(_F_),
	s4_search(_G_),
	b4_search(_H_),
	s5_search(_I_),
	b5_search(_J_),
	s6_search(_K_),
	b6_search(_L_),
	_M_=[[_A_,_B_,4],[_C_,_D_,4],[_E_,_F_,4],[_G_,_H_,4],[_I_,_J_,4],[_K_,_L_,4]].

min_nf_list(_C_) :- 
	first(_A_),
	l1(_B_),
	_C_=[[_A_,_B_,30]].

min_nf_list_search(_C_) :- 
	first_search(_A_),
	l1_search(_B_),
	_C_=[[_A_,_B_,30]].

min_af_list(_M_) :- 
	ue(_A_),
	s1(_B_),
	ue(_C_),
	s2(_D_),
	ue(_E_),
	s3(_F_),
	ue(_G_),
	s4(_H_),
	ue(_I_),
	s5(_J_),
	ue(_K_),
	s6(_L_),
	_M_=[[_A_,_B_,6],[_C_,_D_,6],[_E_,_F_,6],[_G_,_H_,6],[_I_,_J_,6],[_K_,_L_,6]].

min_af_list_search(_M_) :- 
	ue_search(_A_),
	s1_search(_B_),
	ue_search(_C_),
	s2_search(_D_),
	ue_search(_E_),
	s3_search(_F_),
	ue_search(_G_),
	s4_search(_H_),
	ue_search(_I_),
	s5_search(_J_),
	ue_search(_K_),
	s6_search(_L_),
	_M_=[[_A_,_B_,6],[_C_,_D_,6],[_E_,_F_,6],[_G_,_H_,6],[_I_,_J_,6],[_K_,_L_,6]].

end(Task, _C_) :- 
	rcp_att(start, Task, _A_),
	rcp_att(duration, Task, _B_),
	fd_aeq(_A_+_B_, _C_).

end_search(Task, _C_) :- 
	rcp_att(start, Task, _A_),
	rcp_att(duration, Task, _B_),
	fd_aeq(_A_+_B_, _C_).

prec(T1, T2, _C_) :- 
	end(T1, _A_),
	rcp_att(start, T2, _B_),
	fd_leq(_A_, _B_, _C_).

prec_search(T1, T2, _C_) :- 
	end_search(T1, _A_),
	rcp_att(start, T2, _B_),
	fd_leq(_A_, _B_),
	fd_aeq(_C_, 1).

disj(T1, T2, _C_) :- 
	fd_or(_A_, _B_, _C_),
	prec(T1, T2, _A_),
	prec(T2, T1, _B_).

disj_search(T1, T2, _C_) :- 
	(
	prec_search(T1, T2, _A_),
	rcp_assert(_A_)
	;
	prec_search(T2, T1, _B_),
	rcp_assert(_B_)
	),
	fd_aeq(_C_, 1).

precedences_foldl_1([], I_and, _, I_and) :- 
	!.
precedences_foldl_1([TaskPair_57|Tail], I_and, [], _D_) :- 
	nth1(1, TaskPair_57, _A_),
	nth1(2, TaskPair_57, _B_),
	prec(_A_, _B_, _C_),
	fd_and(I_and, _C_, _E_),
	precedences_foldl_1(Tail, _E_, [], _D_).

precedences_foldl_1_search([], I_and, _, I_and) :- 
	!.
precedences_foldl_1_search([TaskPair_57|Tail], I_and, [], _D_) :- 
	nth1(1, TaskPair_57, _A_),
	nth1(2, TaskPair_57, _B_),
	prec_search(_A_, _B_, _C_),
	rcp_assert(I_and),
	rcp_assert(_C_),
	precedences_foldl_1_search(Tail, _E_, [], _D_).

precedences(_B_) :- 
	precedences_list(_A_),
	precedences_foldl_1(_A_, 1, [], _B_).

precedences_search(_B_) :- 
	precedences_list_search(_A_),
	precedences_foldl_1_search(_A_, 1, [], _B_).

disjunctives_foldl_1([], I_and, _, I_and) :- 
	!.
disjunctives_foldl_1([Tasks_59|Tail], I_and, [], _B_) :- 
	disjo(Tasks_59, _A_),
	fd_and(I_and, _A_, _C_),
	disjunctives_foldl_1(Tail, _C_, [], _B_).

disjunctives_foldl_1_search([], I_and, _, I_and) :- 
	!.
disjunctives_foldl_1_search([Tasks_59|Tail], I_and, [], _B_) :- 
	disjo_search(Tasks_59, _A_),
	rcp_assert(I_and),
	rcp_assert(_A_),
	disjunctives_foldl_1_search(Tail, _C_, [], _B_).

disjunctives(_B_) :- 
	resources_list(_A_),
	disjunctives_foldl_1(_A_, 1, [], _B_).

disjunctives_search(_B_) :- 
	resources_list_search(_A_),
	disjunctives_foldl_1_search(_A_, 1, [], _B_).

disjo_foldl_2([], I_and, _, I_and) :- 
	!.
disjo_foldl_2([T2_63|Tail], I_and, [T1_61,Tasks], _F_) :- 
	fd_implies(_C_, _D_, _E_),
	rcp_att(uid, T1_61, _A_),
	rcp_att(uid, T2_63, _B_),
	fd_lt(_A_, _B_, _C_),
	disj(T1_61, T2_63, _D_),
	fd_and(I_and, _E_, _G_),
	disjo_foldl_2(Tail, _G_, [T1_61,Tasks], _F_).

disjo_foldl_2_search([], I_and, _, I_and) :- 
	!.
disjo_foldl_2_search([T2_63|Tail], I_and, [T1_61,Tasks], _G_) :- 
	rcp_att(uid, T1_61, _A_),
	rcp_att(uid, T2_63, _B_),
	rcp_att(uid, T1_61, _C_),
	rcp_att(uid, T2_63, _D_),
	(
	fd_lt(_A_, _B_),
	disj_search(T1_61, T2_63, _E_),
	fd_equiv(_E_, _F_, 1)
	;
	fd_geq(_C_, _D_),
	fd_aeq(_F_, 1)
	),
	rcp_assert(I_and),
	rcp_assert(_F_),
	disjo_foldl_2_search(Tail, _H_, [T1_61,Tasks], _G_).

disjo_foldl_1([], I_and, _, I_and) :- 
	!.
disjo_foldl_1([T1_61|Tail], I_and, [Tasks], _B_) :- 
	disjo_foldl_2(Tasks, 1, [T1_61,Tasks], _A_),
	fd_and(I_and, _A_, _C_),
	disjo_foldl_1(Tail, _C_, [Tasks], _B_).

disjo_foldl_1_search([], I_and, _, I_and) :- 
	!.
disjo_foldl_1_search([T1_61|Tail], I_and, [Tasks], _B_) :- 
	disjo_foldl_2_search(Tasks, 1, [T1_61,Tasks], _A_),
	rcp_assert(I_and),
	rcp_assert(_A_),
	disjo_foldl_1_search(Tail, _C_, [Tasks], _B_).

disjo(Tasks, _A_) :- 
	disjo_foldl_1(Tasks, 1, [Tasks], _A_).

disjo_search(Tasks, _A_) :- 
	disjo_foldl_1_search(Tasks, 1, [Tasks], _A_).

max_nf(T1, T2, N, _D_) :- 
	rcp_att(start, T2, _A_),
	end(T1, _B_),
	fd_aeq(_B_+N, _C_),
	fd_leq(_A_, _C_, _D_).

max_nf_search(T1, T2, N, _D_) :- 
	rcp_att(start, T2, _A_),
	end_search(T1, _B_),
	fd_aeq(_B_+N, _C_),
	fd_leq(_A_, _C_),
	fd_aeq(_D_, 1).

min_nf(T1, T2, N, _G_) :- 
	rcp_att(start, T2, _A_),
	rcp_att(start, T1, _B_),
	rcp_att(duration, T1, _C_),
	fd_aeq(2*_C_, _D_),
	fd_aeq(_B_+_D_, _E_),
	fd_aeq(_E_+N, _F_),
	fd_geq(_A_, _F_, _G_).

min_nf_search(T1, T2, N, _G_) :- 
	rcp_att(start, T2, _A_),
	rcp_att(start, T1, _B_),
	rcp_att(duration, T1, _C_),
	fd_aeq(2*_C_, _D_),
	fd_aeq(_B_+_D_, _E_),
	fd_aeq(_E_+N, _F_),
	fd_geq(_A_, _F_),
	fd_aeq(_G_, 1).

max_ef(T1, T2, N, _D_) :- 
	end(T2, _A_),
	end(T1, _B_),
	fd_aeq(_B_+N, _C_),
	fd_leq(_A_, _C_, _D_).

max_ef_search(T1, T2, N, _D_) :- 
	end_search(T2, _A_),
	end_search(T1, _B_),
	fd_aeq(_B_+N, _C_),
	fd_leq(_A_, _C_),
	fd_aeq(_D_, 1).

min_af(T1, T2, N, _D_) :- 
	rcp_att(start, T2, _A_),
	rcp_att(start, T1, _B_),
	fd_aeq(_B_+N, _C_),
	fd_geq(_A_, _C_, _D_).

min_af_search(T1, T2, N, _D_) :- 
	rcp_att(start, T2, _A_),
	rcp_att(start, T1, _B_),
	fd_aeq(_B_+N, _C_),
	fd_geq(_A_, _C_),
	fd_aeq(_D_, 1).

min_sf(T1, T2, N, _D_) :- 
	end(T2, _A_),
	rcp_att(start, T1, _B_),
	fd_aeq(_B_+N, _C_),
	fd_leq(_A_, _C_, _D_).

min_sf_search(T1, T2, N, _D_) :- 
	end_search(T2, _A_),
	rcp_att(start, T1, _B_),
	fd_aeq(_B_+N, _C_),
	fd_leq(_A_, _C_),
	fd_aeq(_D_, 1).

distances_foldl_1([], I_and, _, I_and) :- 
	!.
distances_foldl_1([T_67|Tail], I_and, [], _E_) :- 
	nth1(1, T_67, _A_),
	nth1(2, T_67, _B_),
	nth1(3, T_67, _C_),
	max_nf(_A_, _B_, _C_, _D_),
	fd_and(I_and, _D_, _F_),
	distances_foldl_1(Tail, _F_, [], _E_).

distances_foldl_1_search([], I_and, _, I_and) :- 
	!.
distances_foldl_1_search([T_67|Tail], I_and, [], _E_) :- 
	nth1(1, T_67, _A_),
	nth1(2, T_67, _B_),
	nth1(3, T_67, _C_),
	max_nf_search(_A_, _B_, _C_, _D_),
	rcp_assert(I_and),
	rcp_assert(_D_),
	distances_foldl_1_search(Tail, _F_, [], _E_).

distances_foldl_2([], I_and, _, I_and) :- 
	!.
distances_foldl_2([T_68|Tail], I_and, [], _E_) :- 
	nth1(1, T_68, _A_),
	nth1(2, T_68, _B_),
	nth1(3, T_68, _C_),
	min_sf(_A_, _B_, _C_, _D_),
	fd_and(I_and, _D_, _F_),
	distances_foldl_2(Tail, _F_, [], _E_).

distances_foldl_2_search([], I_and, _, I_and) :- 
	!.
distances_foldl_2_search([T_68|Tail], I_and, [], _E_) :- 
	nth1(1, T_68, _A_),
	nth1(2, T_68, _B_),
	nth1(3, T_68, _C_),
	min_sf_search(_A_, _B_, _C_, _D_),
	rcp_assert(I_and),
	rcp_assert(_D_),
	distances_foldl_2_search(Tail, _F_, [], _E_).

distances_foldl_3([], I_and, _, I_and) :- 
	!.
distances_foldl_3([T_69|Tail], I_and, [], _E_) :- 
	nth1(1, T_69, _A_),
	nth1(2, T_69, _B_),
	nth1(3, T_69, _C_),
	max_ef(_A_, _B_, _C_, _D_),
	fd_and(I_and, _D_, _F_),
	distances_foldl_3(Tail, _F_, [], _E_).

distances_foldl_3_search([], I_and, _, I_and) :- 
	!.
distances_foldl_3_search([T_69|Tail], I_and, [], _E_) :- 
	nth1(1, T_69, _A_),
	nth1(2, T_69, _B_),
	nth1(3, T_69, _C_),
	max_ef_search(_A_, _B_, _C_, _D_),
	rcp_assert(I_and),
	rcp_assert(_D_),
	distances_foldl_3_search(Tail, _F_, [], _E_).

distances_foldl_4([], I_and, _, I_and) :- 
	!.
distances_foldl_4([T_70|Tail], I_and, [], _E_) :- 
	nth1(1, T_70, _A_),
	nth1(2, T_70, _B_),
	nth1(3, T_70, _C_),
	min_nf(_A_, _B_, _C_, _D_),
	fd_and(I_and, _D_, _F_),
	distances_foldl_4(Tail, _F_, [], _E_).

distances_foldl_4_search([], I_and, _, I_and) :- 
	!.
distances_foldl_4_search([T_70|Tail], I_and, [], _E_) :- 
	nth1(1, T_70, _A_),
	nth1(2, T_70, _B_),
	nth1(3, T_70, _C_),
	min_nf_search(_A_, _B_, _C_, _D_),
	rcp_assert(I_and),
	rcp_assert(_D_),
	distances_foldl_4_search(Tail, _F_, [], _E_).

distances_foldl_5([], I_and, _, I_and) :- 
	!.
distances_foldl_5([T_71|Tail], I_and, [], _E_) :- 
	nth1(1, T_71, _A_),
	nth1(2, T_71, _B_),
	nth1(3, T_71, _C_),
	min_af(_A_, _B_, _C_, _D_),
	fd_and(I_and, _D_, _F_),
	distances_foldl_5(Tail, _F_, [], _E_).

distances_foldl_5_search([], I_and, _, I_and) :- 
	!.
distances_foldl_5_search([T_71|Tail], I_and, [], _E_) :- 
	nth1(1, T_71, _A_),
	nth1(2, T_71, _B_),
	nth1(3, T_71, _C_),
	min_af_search(_A_, _B_, _C_, _D_),
	rcp_assert(I_and),
	rcp_assert(_D_),
	distances_foldl_5_search(Tail, _F_, [], _E_).

distances(_N_) :- 
	fd_and(_K_, _M_, _N_),
	fd_and(_H_, _J_, _K_),
	fd_and(_E_, _G_, _H_),
	fd_and(_B_, _D_, _E_),
	max_nf_list(_A_),
	distances_foldl_1(_A_, 1, [], _B_),
	min_sf_list(_C_),
	distances_foldl_2(_C_, 1, [], _D_),
	max_ef_list(_F_),
	distances_foldl_3(_F_, 1, [], _G_),
	min_nf_list(_I_),
	distances_foldl_4(_I_, 1, [], _J_),
	min_af_list(_L_),
	distances_foldl_5(_L_, 1, [], _M_).

distances_search(_K_) :- 
	max_nf_list_search(_A_),
	distances_foldl_1_search(_A_, 1, [], _B_),
	rcp_assert(_B_),
	min_sf_list_search(_C_),
	distances_foldl_2_search(_C_, 1, [], _D_),
	rcp_assert(_D_),
	max_ef_list_search(_E_),
	distances_foldl_3_search(_E_, 1, [], _F_),
	rcp_assert(_F_),
	min_nf_list_search(_G_),
	distances_foldl_4_search(_G_, 1, [], _H_),
	rcp_assert(_H_),
	min_af_list_search(_I_),
	distances_foldl_5_search(_I_, 1, [], _J_),
	rcp_assert(_J_),
	fd_aeq(_K_, 1).

tasks_domain_foldr_1([], _, []) :- 
	!.
tasks_domain_foldr_1([T_77|Tail], [], [_A_|_B_]) :- 
	tasks_domain_foldr_1(Tail, [], _B_),
	rcp_att(start, T_77, _A_).

tasks_domain_foldr_1_search([], _, []) :- 
	!.
tasks_domain_foldr_1_search([T_77|Tail], [], [_A_|_B_]) :- 
	tasks_domain_foldr_1_search(Tail, [], _B_),
	rcp_att(start, T_77, _A_).

tasks_domain(_D_) :- 
	tasks(_A_),
	tasks_domain_foldr_1(_A_, [], _B_),
	variables(_B_, _C_),
	domain(_C_, 0, 200),
	fd_aeq(_D_, 1).

tasks_domain_search(_D_) :- 
	tasks_search(_A_),
	tasks_domain_foldr_1_search(_A_, [], _B_),
	variables(_B_, _C_),
	domain(_C_, 0, 200),
	fd_aeq(_D_, 1).

minimize_completion_time(_C_) :- 
	cost(_B_),
	minimize(((rcp_assert(_A_),disjunctives_search(_A_)),rcp_labeling([_B_])), _B_),
	true,
	fd_aeq(_C_, 1).

minimize_completion_time_search(_C_) :- 
	cost(_B_),
	minimize(((rcp_assert(_A_),disjunctives_search(_A_)),rcp_labeling([_B_])), _B_),
	true,
	fd_aeq(_C_, 1).

solve([Ab1,Ab2,Ab3,Ab4,Ab5,Ab6,K1,K2,Ua,First,Ue,P2,P1,M6,V2,V1,M1,M2,M3,M5,M4,T1,T2,T3,T4,L1,T5,S6,S1,S2,S3,S5,S4,A6,A1,A2,A3,A5,A4,B1,B2,B3,B4,B6,B5,Last]) :- 
	statistics(runtime, [_Runtime_0_|_]),
	fd_statistics(backtracks, _),
	
	rcp_var(from(ab1,0,1), Ab1),
	rcp_var(from(ab2,0,1), Ab2),
	rcp_var(from(ab3,0,1), Ab3),
	rcp_var(from(ab4,0,1), Ab4),
	rcp_var(from(ab5,0,1), Ab5),
	rcp_var(from(ab6,0,1), Ab6),
	rcp_var(from(k1,0,1), K1),
	rcp_var(from(k2,0,1), K2),
	rcp_var(from(last,0,1), Last),
	rcp_var(from(ua,0,1), Ua),
	rcp_var(from(first,0,1), First),
	rcp_var(from(ue,0,1), Ue),
	rcp_var(from(p2,0,1), P2),
	rcp_var(from(p1,0,1), P1),
	rcp_var(from(m6,0,1), M6),
	rcp_var(from(v2,0,1), V2),
	rcp_var(from(v1,0,1), V1),
	rcp_var(from(m1,0,1), M1),
	rcp_var(from(m2,0,1), M2),
	rcp_var(from(m3,0,1), M3),
	rcp_var(from(m5,0,1), M5),
	rcp_var(from(m4,0,1), M4),
	rcp_var(from(t1,0,1), T1),
	rcp_var(from(t2,0,1), T2),
	rcp_var(from(t3,0,1), T3),
	rcp_var(from(t4,0,1), T4),
	rcp_var(from(l1,0,1), L1),
	rcp_var(from(t5,0,1), T5),
	rcp_var(from(s6,0,1), S6),
	rcp_var(from(s1,0,1), S1),
	rcp_var(from(s2,0,1), S2),
	rcp_var(from(s3,0,1), S3),
	rcp_var(from(s5,0,1), S5),
	rcp_var(from(s4,0,1), S4),
	rcp_var(from(a6,0,1), A6),
	rcp_var(from(a1,0,1), A1),
	rcp_var(from(a2,0,1), A2),
	rcp_var(from(a3,0,1), A3),
	rcp_var(from(a5,0,1), A5),
	rcp_var(from(a4,0,1), A4),
	rcp_var(from(b1,0,1), B1),
	rcp_var(from(b2,0,1), B2),
	rcp_var(from(b3,0,1), B3),
	rcp_var(from(b4,0,1), B4),
	rcp_var(from(b6,0,1), B6),
	rcp_var(from(b5,0,1), B5),
	domain([First,A1,A2,A3,A4,A5,A6,P1,P2,Ue,S1,S2,S3,S4,S5,S6,B1,B2,B3,B4,B5,B6,Ab1,Ab2,Ab3,Ab4,Ab5,Ab6,M1,M2,M3,M4,M5,M6,L1,T1,T2,T3,T4,T5,Ua,V1,V2,K1,K2,Last], 0, 200),
	First#=<A1,
	First#=<A2,
	First#=<A3,
	First#=<A4,
	First#=<A5,
	First#=<A6,
	First#=<Ue,
	A1+4#=<S1,
	A2+2#=<S2,
	A5+2#=<S5,
	A6+5#=<S6,
	A3+2#=<P1,
	A4+2#=<P2,
	P1+20#=<S3,
	P2+13#=<S4,
	P1+20#=<K1,
	P2+13#=<K1,
	S1+8#=<B1,
	S2+4#=<B2,
	S3+4#=<B3,
	S4+4#=<B4,
	S5+4#=<B5,
	S6+10#=<B6,
	B1+1#=<Ab1,
	B2+1#=<Ab2,
	B3+1#=<Ab3,
	B4+1#=<Ab4,
	B5+1#=<Ab5,
	B6+1#=<Ab6,
	Ab1+1#=<M1,
	Ab2+1#=<M2,
	Ab3+1#=<M3,
	Ab4+1#=<M4,
	Ab5+1#=<M5,
	Ab6+1#=<M6,
	M1+16#=<T1,
	M2+8#=<T1,
	M2+8#=<T2,
	M3+8#=<T2,
	M3+8#=<T3,
	M4+8#=<T3,
	M4+8#=<T4,
	M5+8#=<T4,
	M5+8#=<T5,
	M6+20#=<T5,
	M1+16#=<K2,
	M2+8#=<K2,
	M3+8#=<K2,
	M4+8#=<K2,
	M5+8#=<K2,
	M6+20#=<K2,
	L1+2#=<T1,
	L1+2#=<T2,
	L1+2#=<T3,
	L1+2#=<T4,
	L1+2#=<T5,
	T1+12#=<V1,
	T5+12#=<V2,
	T2+12#=<Last,
	T3+12#=<Last,
	T4+12#=<Last,
	V1+15#=<Last,
	V2+10#=<Last,
	Ua+10#=<Last,
	K1#=<Last,
	K2#=<Last,
	L1#=<First+30,
	S1#=<A1+4+3,
	S2#=<A2+2+3,
	S5#=<A5+2+3,
	S6#=<A6+5+3,
	S3#=<P1+20+3,
	S4#=<P2+13+3,
	M1+16#=<Ua+2,
	M2+8#=<Ua+2,
	M3+8#=<Ua+2,
	M4+8#=<Ua+2,
	M5+8#=<Ua+2,
	M6+20#=<Ua+2,
	B1+1#=<S1+8+4,
	B2+1#=<S2+4+4,
	B3+1#=<S3+4+4,
	B4+1#=<S4+4+4,
	B5+1#=<S5+4+4,
	B6+1#=<S6+10+4,
	L1#>=First+30,
	S1#>=Ue+6,
	S2#>=Ue+6,
	S3#>=Ue+6,
	S4#>=Ue+6,
	S5#>=Ue+6,
	S6#>=Ue+6,
	minimize((((M6+20#=<M1;M1+16#=<M6),(P1+20#=<P2;P2+13#=<P1),(M6+20#=<M2;M2+8#=<M6),(M6+20#=<M3;M3+8#=<M6),(M6+20#=<M4;M4+8#=<M6),(M6+20#=<M5;M5+8#=<M6),(V1+15#=<V2;V2+10#=<V1),(T1+12#=<T2;T2+12#=<T1),(T1+12#=<T3;T3+12#=<T1),(T1+12#=<T4;T4+12#=<T1),(T1+12#=<T5;T5+12#=<T1),(T2+12#=<T3;T3+12#=<T2),(T2+12#=<T4;T4+12#=<T2),(T2+12#=<T5;T5+12#=<T2),(T3+12#=<T4;T4+12#=<T3),(T3+12#=<T5;T5+12#=<T3),(T4+12#=<T5;T5+12#=<T4),(M1+16#=<M2;M2+8#=<M1),(M1+16#=<M3;M3+8#=<M1),(M1+16#=<M4;M4+8#=<M1),(M1+16#=<M5;M5+8#=<M1),(S6+10#=<S1;S1+8#=<S6),(M2+8#=<M3;M3+8#=<M2),(M2+8#=<M4;M4+8#=<M2),(M2+8#=<M5;M5+8#=<M2),(M3+8#=<M4;M4+8#=<M3),(M3+8#=<M5;M5+8#=<M3),(M4+8#=<M5;M5+8#=<M4),(T1+12#=<L1;L1+2#=<T1),(T2+12#=<L1;L1+2#=<T2),(T3+12#=<L1;L1+2#=<T3),(T4+12#=<L1;L1+2#=<T4),(T5+12#=<L1;L1+2#=<T5),(S6+10#=<S2;S2+4#=<S6),(S6+10#=<S3;S3+4#=<S6),(S6+10#=<S4;S4+4#=<S6),(S6+10#=<S5;S5+4#=<S6),(S1+8#=<S2;S2+4#=<S1),(S1+8#=<S3;S3+4#=<S1),(S1+8#=<S4;S4+4#=<S1),(S1+8#=<S5;S5+4#=<S1),(A6+5#=<A1;A1+4#=<A6),(S2+4#=<S3;S3+4#=<S2),(S2+4#=<S4;S4+4#=<S2),(S2+4#=<S5;S5+4#=<S2),(S3+4#=<S4;S4+4#=<S3),(S3+4#=<S5;S5+4#=<S3),(S4+4#=<S5;S5+4#=<S4),(A6+5#=<A2;A2+2#=<A6),(A6+5#=<A3;A3+2#=<A6),(A6+5#=<A4;A4+2#=<A6),(A6+5#=<A5;A5+2#=<A6),(A1+4#=<A2;A2+2#=<A1),(A1+4#=<A3;A3+2#=<A1),(A1+4#=<A4;A4+2#=<A1),(A1+4#=<A5;A5+2#=<A1),(A2+2#=<A3;A3+2#=<A2),(A2+2#=<A4;A4+2#=<A2),(A2+2#=<A5;A5+2#=<A2),(A3+2#=<A4;A4+2#=<A3),(A3+2#=<A5;A5+2#=<A3),(A4+2#=<A5;A5+2#=<A4),(B1+1#=<B2;B2+1#=<B1),(B1+1#=<B3;B3+1#=<B1),(B1+1#=<B4;B4+1#=<B1),(B1+1#=<B5;B5+1#=<B1),(B1+1#=<B6;B6+1#=<B1),(B2+1#=<B3;B3+1#=<B2),(B2+1#=<B4;B4+1#=<B2),(B2+1#=<B5;B5+1#=<B2),(B2+1#=<B6;B6+1#=<B2),(B3+1#=<B4;B4+1#=<B3),(B3+1#=<B5;B5+1#=<B3),(B3+1#=<B6;B6+1#=<B3),(B4+1#=<B5;B5+1#=<B4),(B4+1#=<B6;B6+1#=<B4),(B5+1#=<B6;B6+1#=<B5)),labeling([up],[Last])), Last),
	statistics(runtime, [_Runtime_1_|_]),
	fd_statistics(backtracks, _Backtracks_),
	_Runtime_ is _Runtime_1_-_Runtime_0_,
	format('~3d seconds\n', [_Runtime_]),
	format('~w bactracks\n\n', [_Backtracks_]).
