A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Untitled - Stikked
From Walloping Monkey, 11 Years ago, written in Prolog.
Embed
  1. use_module(library(http/json)).
  2. use_module(library(http/json_convert)).
  3. use_module(library(clpfd)).
  4. /*edge(node(From), node(Dest)).*/
  5. /*activator(node(A)) :- activates(node(A), node(D)), A \== D.*/
  6. inhibitor(node(I)) :- inhibates(node(I), node(D)), I \== D.
  7.  
  8. printlist(l).
  9. printlist([]).
  10. printlist([X|List]) :-
  11.       write(X), nl,
  12.       printlist(List).
  13.  
  14. %haspath(X, Y) :- path(X, Y, _).
  15. %table path(+,+,-,min,min).
  16. % 3
  17. /*path(X, Y, Path) :- path(X, Y, _, _, Path).
  18. %5 simple
  19. path(X, Y, 1, Cost, [X,Y]) :- edge(X, Y, Cost).
  20. % 5 extended
  21. path(X, Y, Length, TotalCost, [X|[Z|Path]]):-
  22.      %X \== Y, X \== Z,
  23.      edge(X, Z, Cost),
  24.      %not(member(X, Rest)),
  25.      path(Z, Y, SubLength, SubCost, [Z|Path]),
  26.      not(member(X, Path)),
  27.      Length is SubLength + 1,
  28.      TotalCost is Cost + SubCost.*/
  29.  
  30. %path(X, Y, Path) :- path(X, Y, _, _, Path).
  31. %path(X, Y, Length, Cost, Path):- path(X, Y, [], Length, Cost, Path).
  32. %
  33. path(X, Y, Visited, 1, Cost, [X|Visited]):- edge(X, Y, Cost).
  34.  
  35. path(X, Y, Visited, Length, TotalCost, [X|[Z|Rest]]):-
  36.                         edge(X, Z, Cost),
  37.                         Y\==Z,
  38.                         \+member(Z, Visited),
  39.     path(Z, Y, [Z|Visited], SubLength, SubCost, [Z|Rest]),
  40.  
  41.                         %not(member(X, Rest)),
  42.                         Length is SubLength + 1,
  43.                         TotalCost is Cost + SubCost.
  44.  
  45.  
  46.  
  47.  
  48. path2(A,B,Path,Len,Cost) :-
  49.        travel(A,B,[A],Q,Len,Cost),
  50.        reverse(Q,Path).
  51.  
  52. travel(A,B,P,[B|P],1,Cost) :-
  53.        edge(A,B,Cost).
  54. travel(A,B,Visited,Path,Length,TotalCost) :-
  55.        edge(A,C,Cost),
  56.        C \== B,
  57.        \+member(C,Visited),
  58.        travel(C,B,[C|Visited],Path,L1,C1),
  59.        Length is 1+L1,
  60.        TotalCost is Cost + C1.
  61.  
  62. shortest(A,B,Path,Length,Cost) :-
  63.    setof([C,P,L],path2(A,B,P,L,C),Set),
  64.    Set = [_|_], % fail if empty
  65.    minimal(Set,[Cost,Path,Length]).
  66.  
  67. minimal([F|R],M) :- min(R,F,M).
  68.  
  69. % minimal path
  70. min([],M,M).
  71. min([[Path,Length]|R],[_,M],Min) :- Length < M, !, min(R,[Path, Length],Min).
  72. min([_|R],M,Min) :- min(R,M,Min).
  73.  
  74. %table sp(+,+,-,min).
  75. sp(X,Y,[(X,Y)],(W,1)) :-
  76.         edge(X,Y,W).
  77. sp(X,Y,[(X,Y)],(W,1)) :-
  78.         edge(X,Y,W).
  79. sp(X,Y,[(X,Z)|Path],(W,Len)) :-
  80.         edge(X,Z,W1),
  81.         sp(Z,Y,Path,(W2,Len1)),
  82. %       not(member(X, Path)),
  83.         Len is Len1+1,
  84.         W is W1+W2.
  85.  
  86.  
  87. node(protein01).
  88. node(protein02).
  89. node(protein03).
  90. node(protein04).
  91. node(protein05).
  92. edge(protein01, protein02, 1).
  93. edge(protein01, protein03, 1).
  94. edge(protein02, protein03, 2).
  95. edge(protein02, protein05, 1).
  96. edge(protein03, protein04, 3).
  97. edge(protein04, protein05, 1).
  98. edge(protein05, protein01, 3).
  99.  
  100. edge(a,e,1).
  101. edge(e,d,1).
  102. edge(d,c,1).
  103. edge(c,b,3).
  104. edge(b,a,3).
  105. edge(d,a,8).
  106. edge(e,c,1).
  107. edge(f,b,6).
  108.  
  109. time(exp01, 1). % 00h
  110. time(exp02, 2). % 12h
  111. time(exp03, 3). % 24h
  112. time(exp04, 4). % 36h
  113. % ...
  114.  
  115. exp(gene01, exp01, 8.1).
  116. exp(gene02, exp01, 7.0).
  117. exp(gene03, exp01, 1.0).
  118.  
  119. exp(gene01, exp02, 2.0).
  120. exp(gene02, exp02, 2.4).
  121. exp(gene03, exp02, 3.0).
  122.  
  123. exp(gene01, exp03, 3.0).
  124. exp(gene02, exp03, 2.8).
  125. exp(gene03, exp03, 2.7).
  126.  
  127. exp(gene01, exp04, 1.0).
  128. exp(gene02, exp04, 0.1).
  129. exp(gene03, exp04, 10.0).
  130.  
  131. activates(Source, Target, []) :-
  132.         exp(Source, Currexp, 0),
  133.         exp(Target, Currexp, Tpvalue),
  134.         Tpvalue > 0, !, fail.
  135. activates(Source, Target, []) :-
  136.         exp(Source, Currexp, Spvalue1),
  137.         exp(Target, Currexp, Tpvalue1),
  138.         time(Currexp, Currtime),
  139.         time(Furtherexp, Furthertime),
  140.         Furthertime is Currtime + 1,
  141.         exp(Source, Furtherexp, Spvalue2),
  142.         exp(Target, Furtherexp, Tpvalue2),
  143.         Spvalue2 > Spvalue1,
  144.         Tpvalue2 < Tpvalue1,
  145.         !, fail.
  146.  
  147. activates(Source, Target, [Currexp|Experiments]) :-
  148.         Source \== Target,
  149.         exp(Source, Currexp, Spvalue1),
  150.         exp(Target, Currexp, Tpvalue1),
  151.         time(Currexp, Currtime),
  152.         time(Furtherexp, Furthertime),
  153.         Furthertime is Currtime + 1,
  154.         exp(Source, Furtherexp, Spvalue2),
  155.         exp(Target, Furtherexp, Tpvalue2),
  156.         \+member(Currexp, Experiments),
  157.         Spvalue2 >= Spvalue1,
  158.         Tpvalue2 >= Tpvalue1,
  159.         !,
  160.         activates(Source, Target, Experiments).
  161. activators(Set) :- setof([G1, G2, Diff1, Diff2, W], (E1 \== E2, exp(G1,E1,V1), exp(G2, E1, V2), G1 \== G2, time(E1,T1), time(E2,T2), T2 is T1 + 1, exp(G1, E2, V3), exp(G2, E2, V4), V3 >= V1, V4 >= V2, Diff1 is V3 - V1, Diff2 is V4 - V2, W is Diff1 / Diff2), Set).
  162.  
  163. inhibitors(Set) :- setof([G1, G2, Diff1, Diff2, W], (E1 \== E2, exp(G1,E1,V1), exp(G2, E1, V2), G1 \== G2, time(E1,T1), time(E2,T2), T2 is T1 + 1, exp(G1, E2, V3), exp(G2, E2, V4), V3 > V1, V4 < V2, Diff1 is V3 - V1, Diff2 is V4 - V2, W is Diff1 / -Diff2), Set).
  164.  
  165. /*relation :- activates(node(Source)), (node(Destination)), (Source), Source \== Destination.
  166. relation :- inhibates(node(Source)), (node(Destination)), inhibitor(Source), Source \== Destination.
  167. */
  168.  
  169. /* map(M, K, V). */
  170. map(Assoc, Keys, Values) :-
  171. group_pairs_by_key([a-2,a-8, a-3,b-4], Assoc),
  172.         pairs_keys(Assoc, Keys),
  173.         pairs_values(Assoc, Values).
  174.  
  175. test2(Name, ListAssoc, X) :-
  176.  Name = 'LIGT',
  177.  ListAssoc =  [v(1,5,5), v(3,3,6), v(7,12,12)],
  178.  X = [sample(Name, ListAssoc)].
  179.  
  180. test3(X, L, N, Assoc) :- test2(X, L, N), list_to_assoc(L, Assoc).
  181. test4(v(Time,VFrom,VTo), LAssoc) :-
  182.         group_pairs_by_key([Time-VFrom, Time-VTo],LAssoc).
  183.  
  184. solve(MaxTime, Samples, LAssoc) :-
  185.     %make_samples(MaxTime, Samples, LAssoc),
  186.     make_graph(MaxTime, Samples, Graph),
  187.     make_labelling(LAssoc).
  188.  
  189. make_samples(_, [], []).
  190. make_samples(MaxTime,
  191.              [sample(Name, Exps)|Samples], LAssoc) :-
  192.         %order_experiments(Exps, OrderedExps),
  193.         %make_experiments(MaxTime, OrderedExps, LAssoc),
  194.         make_samples(MaxTime, Samples, LAssoc).
  195.  
  196.         %make_graph(_, [], []).
  197. %make_graph(MaxTime, [sample(Name, Exps)|samples], Graph) :-.
  198.  
  199. make_experiments(_, [], _, []) :- !.
  200. make_experiments(MaxTime, Exps, SuggestedNodes, Graph) :-
  201.         pre_check_exps_length(Exps), !,
  202.         make_exps(MaxTime, Exps, GeneratedGraph), !,
  203.         (make_graph(SuggestedNodes, GeneratedGraph, Graph), !
  204.         ;write('Cannot do anything with the suggested nodes'), !, fail
  205.         ),
  206. %       length(Exps, L),
  207. %       write(['length is ', L]),
  208.         findall(G, member(exp(G,_,_), Exps), Gs),
  209.         sort(Gs, Genes),
  210.         findall(N, member(node(N, _, _, _), Graph), Ns),
  211.         sort(Ns, Nodes).
  212.  
  213. make_graph(SuggestedNodes, Generated, Graph) :-
  214.      append(SuggestedNodes, Generated, Union),
  215.      sort(Union, Sorted),
  216.      merge_nodes(Sorted, [], Graph), !.
  217.      % TODO get_nodes() recursively... merge each node
  218. make_graph([], A, Sorted) :- sort(A, Sorted).
  219.  
  220. /*merge_network([],[], _).
  221. merge_network([node(A,B,C,D)|T], /*Acc, */Merged) :-
  222.      member(node(A,B,_,_), Acc),
  223.      merge_nodes(T, Acc, Merged)
  224.      ;
  225.      merge_nodes([node(A, B, C, D)|T], [], Merged),
  226.      append(DistinctNodes, Acc, Merged),
  227.      merge_nodes(T, Acc, Merged)*/
  228.  
  229. merge_nodes(Nodes, Acc, Merged) :-
  230.     % find nodes with same orgin/destination than current
  231.     nth1(1, Nodes, node(From,To,_,_)),
  232.     get_nodes(Nodes, From, To, TreatedNodes),
  233.     % generate a node that matches as best as possible the targeted values in his range
  234.     gen_interval(TreatedNodes, BestInterval),
  235.     % add it to
  236.     subtract(Nodes, TreatedNodes, RemainedNodes),
  237.     append([BestInterval], Acc, TempMerged),
  238.  
  239.     %append(, , Merged),
  240.    % merge_nodes(T, Acc, Merged),
  241.     merge_nodes(RemainedNodes, TempMerged, Merged), !
  242.     .
  243. merge_nodes([], N, N).%[node(A, B, C, D)], [node(A, B, C, D)]).
  244.  
  245. min_value(A, B, A) :- A =< B, !.
  246. min_value(B, A, A) :- A =< B, !.
  247. max_value(A, B, A) :- A >= B, !.
  248. max_value(B, A, A) :- A >= B, !.
  249.  
  250. %best_interval(N,N,N).
  251.  
  252. gen_interval([node(From, To, WeightMin, WeightMax)|T], node(From, To, BestMin, BestMax)) :-
  253.     gen_interval(T, node(From, To, SubMin, SubMax)),
  254.    % node(From, To, Min, Max),
  255.     min_value(WeightMin, SubMin, BestMin),
  256.     max_value(WeightMax, SubMax, BestMax).
  257. gen_interval([node(From,To,Min,Max)], node(From,To,Min,Max)).% :- !.
  258. gen_interval([], _) :- fail.
  259.  
  260. get_nodes(Graph, GeneFrom, GeneTo, Nodes) :-
  261.      findall(
  262.          node(GeneFrom, GeneTo, B, C),
  263.          member(node(GeneFrom, GeneTo, B, C), Graph),
  264.          Nodes).
  265.  
  266. pre_check_exps_length(Exps) :-
  267.     length(Exps, L), (L < 4, write('Not enough experiments'),!, fail; L >= 4).
  268.  
  269. post_check_network_length(Network) :-
  270.     length(Network, NetworkLength), (
  271.         NetworkLength < 1,
  272.         write('Your experiments cannot generate a valid network! The generated network is empty'),
  273.         fail; !).
  274.  
  275. make_exps(_, [], []) :- !, write('rien a faire pour Exps=[]'), !.
  276. make_exps(0, _, []) :- !, format('rien a faire pour MaxTime=~w', [0]), !.
  277. make_exps(MaxTime, Exps, Network) :-
  278.  
  279.         findall(node(A,B,Weight,Weight), (
  280.           member(exp(A,Step1,ValueA1), Exps),
  281.           member(exp(B,Step1,ValueB1), Exps),
  282.           member(exp(A,Step2,ValueA2), Exps),
  283.           member(exp(B,Step2,ValueB2), Exps),
  284.         A \== B,
  285.         Step1 =< MaxTime, Step2 =< MaxTime,
  286.         % ValueA1 #>= minValue
  287.         % ValueB1 #>= minValue
  288.         Diff1 is ValueA2 - ValueA1,
  289.         Diff2 is ValueB2 - ValueB1,
  290.         Diff2 \== 0,
  291.         Weight is abs(round(100* Diff1 / Diff2)),
  292.         Weight >= 1
  293.         % Weight ins [0..1000],
  294.         % Values  = [ValueA1, ValueB1, ValueA2, ValueB2],
  295.         % Values ins [0..1000],
  296.         % Steps = [Step1, Step2],
  297.         % Steps ins [0..MaxTime],
  298.         % diff blabla #\= weight
  299.         % diff1 et diff2 #>= minDiff
  300.         ), Network),
  301.         post_check_network_length(Network)
  302.         %,getfuture(Genes, FutureExps, MaxTime + 1)
  303.         .
  304.  
  305. max_network_length(Exps, MaxLength) :-
  306.        findall(A, member(exp(A,_,_),Exps), As),
  307.        sort(As, Ss),
  308.        length(Ss, L),
  309.        MaxLength is L * L.
  310.  
  311. make_exps2_super(MaxTime, Exps, Nodes) :-
  312.         max_network_length(Exps, MaxLength),
  313.         make_exps2(MaxTime, Exps, MaxLength, Nodes),
  314.         length(Nodes, Nb),
  315.         format('Nodes size : ~w',[Nb]),
  316.         check_ins(Nodes, Exps).
  317. check_ins([node(A,B,Min,Max)|Ns],Exps) :-
  318.         check_in(node(A,B,Min,Max), Exps, _),
  319.         check_ins(Ns, Exps).
  320. check_ins(N, _) :- length(N,L), L < 1, !, fail.
  321.  
  322. check_in(node(A,B,Weight,Weight), Exps,
  323.         [exp(A,Step1,ValueA1),
  324.          exp(B,Step1,ValueB1),
  325.          exp(A,Step2,ValueA2),
  326.          exp(B,Step2,ValueB2)]) :-
  327. %       Step2 is Step1 + 1,
  328.         %A \= B,
  329.         member(exp(A,Step1,ValueA1), Exps),
  330.         member(exp(B,Step1,ValueB1), Exps),
  331.         Step2 is Step1 + 1,
  332.         A \= B,
  333.         member(exp(A,Step2,ValueA2), Exps),
  334.         member(exp(B,Step2,ValueB2), Exps),
  335.         ValueA2 \= ValueA1,
  336.         ValueB2 \= ValueB1,
  337.         Diff1 is ValueA2 - ValueA1,
  338.         Diff2 is ValueB2 - ValueB1,
  339.         Diff2 \= Diff1,
  340.         %Diff2 #\= 0,
  341.         Weight is Diff2 - Diff1,
  342.         Weight > 0, !.
  343.         /*Weight is abs(round(100* Diff1 / Diff2)),
  344.         Weight >= 1,!.*/
  345.  
  346. %make_exps2(_, _, L, Nodes) :- length(Nodes, L).
  347. make_exps2(_, _, 0, []) :- !.
  348. make_exps2(MaxTime, Exps, MaxLength,[node(A,B,MinWeight,MaxWeight)|Ns]) :-
  349.         Times = [Step1, Step2],
  350.         Weights = [MinWeight, MaxWeight],
  351.         Genes = [A, B],
  352.         Genes ins 1..2,
  353.         Times ins 0..MaxTime,
  354.         Weights ins 1..3,%0..MaxTime,
  355.         Step2 #> Step1,
  356.         MinWeight #=< MaxWeight,
  357.         A #\= B,
  358.                 length(Ns, L), L is MaxLength - 1,
  359.  
  360.         check_in(node(A,B,MinWeight,MaxWeight), Exps, MatchedExps),
  361. /*      A \== B,
  362.         Diff1 is ValueA2 - ValueA1,
  363.         Diff2 is ValueB2 - ValueB1,
  364.         Diff2 \== 0,
  365.         Weight is abs(round(100* Diff1 / Diff2)),
  366.         Weight >= 1,*/
  367. %       subtract(Exps, MatchedExps,RestExps),
  368. %
  369.         %not(member(node(A,B,_,_), No)),
  370.         %append(node(A,B,MinWeight,MaxWeight), No),
  371.         SubLength is MaxLength -1,
  372.         make_exps2(MaxTime, Exps, SubLength, Ns), !
  373.         .
  374.  
  375. getfuture(Genes, Network, FutureExps, Time) :-
  376. findall(exp(G, Step, ExprValue),
  377.         (
  378.          member(G, Genes),
  379.          member(node(X, G, _), Network), X \== G,
  380.          member(exp(G, FutureTime - 1, _), Exps),
  381.          Step is FutureTime - 1,
  382.          \+member(exp(G, Time, ExprValue), Exps)
  383.         ),
  384.         FutureExps
  385.        ).
  386.  
  387. makejobs([],[],_).
  388. makejobs([task(N,D,_,_)|Ts],
  389.          [job(N,D,TS)|Js],End) :-
  390.         TS ins 0..1000, TS + D =< End,
  391.         makejobs(Ts, Js, End).
  392.  
  393. sudoku(Rows) :-
  394.         length(Rows, 9), maplist(length_list(9), Rows),
  395.         append(Rows, Vs), Vs ins 1..9,
  396.         maplist(all_distinct, Rows),
  397.         transpose(Rows, Columns),
  398.         maplist(all_distinct, Columns),
  399.         Rows = [A,B,C,D,E,F,G,H,I],
  400.         blocks(A, B, C), blocks(D, E, F), blocks(G, H, I).
  401.  
  402. length_list(L, Ls) :- length(Ls, L).
  403.  
  404. blocks([], [], []).
  405. blocks([A,B,C|Bs1], [D,E,F|Bs2], [G,H,I|Bs3]) :-
  406.         all_distinct([A,B,C,D,E,F,G,H,I]),
  407.         blocks(Bs1, Bs2, Bs3).
  408.  
  409. problem(1, [[_,_,_,_,_,_,_,_,_],
  410.             [_,_,_,_,_,3,_,8,5],
  411.             [_,_,1,_,2,_,_,_,_],
  412.             [_,_,_,5,_,7,_,_,_],
  413.             [_,_,4,_,_,_,1,_,_],
  414.             [_,9,_,_,_,_,_,_,_],
  415.             [5,_,_,_,_,_,_,7,3],
  416.             [_,_,2,_,1,_,_,_,_],
  417.             [_,_,_,_,4,_,_,_,9]]).
  418.  
  419. /** MANUAL */
  420.  
  421. /* 1/ Get a generated network according to some experiments and constraints : */
  422.  
  423. % make_experiments(3, [exp(a,1,1),exp(a,2,2),exp(b,1,2),exp(b,2,4)], Network, [node(a,b,2)]).
  424.  
  425. test(Network) :-
  426.         MaxTime = 3,
  427.         Exps = [exp(a,1,1),exp(a,2,2),exp(b,1,2),exp(b,2,4),exp(b,3,1),exp(c,1,2),exp(c,2,3),exp(c,3,2)],
  428.         Nodes = [node(a,b,2,2)],
  429.         make_experiments(MaxTime, Exps, Nodes, Network).
  430.  
  431. test2 :-
  432.         MaxTime = 3,
  433.         Exps = [exp(a,1,1),exp(a,2,2),exp(b,1,2),exp(b,2,4)],
  434.         Nodes = [node(a,b,2,2)],
  435.         make_exps2_super(MaxTime, Exps, Nodes).
  436.  
  437. test3(Exps, Nodes) :-
  438.         MaxTime = 3,
  439.         Exps = [exp(1,1,1),exp(1,2,2),exp(2,1,2),exp(2,2,4)],
  440. %       Nodes = [node(a,b,2,2)],
  441.         make_exps2(MaxTime,  Exps, 1, Nodes).
  442. testlabel(A) :- max_network_length([exp(1,1,2),exp(2,1,1)],MaxLength), length(A, MaxLength),  A ins 1..MaxLength, all_different(A), label(A).
  443. experiences(
  444.     [exp(1,1,1),exp(1,2,3),
  445.      exp(2,1,1),exp(2,2,2),
  446.      exp(3,1,2),exp(3,2,1)
  447.     ]).
  448. testlabellazy(A, MatchedExps) :-
  449.         experiences(Exps),
  450.         max_network_length(Exps,MaxLength),
  451.         length(A, MaxLength),
  452.         %A=[B,C,D,E], % optional
  453.         A ins 0..MaxLength,
  454.         nth1(1,A,W),
  455.         check_in(node(2,1,W,W), Exps, MatchedExps), label(A).
  456.  
  457. testlabel2(A) :-
  458.        experiences(Exps),
  459.        findall(A, member(exp(A,_,_),Exps), As),
  460.        sort(As, Ss),
  461.        length(Ss, MaxLength),
  462.        MaxLength > 0,
  463.        testlabellazy2(MaxLength, Exps, A, Ss),
  464.        !,
  465.        label(A).
  466. testlabellazy2(_, _, _, []).
  467. testlabellazy2(MaxLength, Exps, A, [Current|Rest]) :-
  468.         %experiences(Exps),
  469.         %max_network_length(Exps,MaxLength),
  470.         length(A, MaxLength),
  471.         %A=[B,C,D,E], % optional
  472.         A ins 0..MaxLength,
  473.         (nth1(Current,A,W),
  474.         check_in(node(Current,_,W,W), Exps, _));true,
  475.         testlabellazy2(MaxLength, Exps, A, Rest).
  476.  
  477. testsudoku2(Rows, Nodes) :-
  478.        experiences(Exps),
  479.        findall(A, member(exp(A,_,_),Exps), As),
  480.        sort(As, Ss),
  481.        length(Ss, MaxLength),
  482.        MaxLength > 0,
  483.        sudoku2(Exps, MaxLength, Rows, Nodes),
  484.       % label(Rows),
  485.        maplist(writeln, Rows),
  486.        labelRows(Rows),
  487.        /*,makeNodesList(Rows, Nodes), */
  488.        !.
  489.  
  490. labelRows([]).
  491. labelRows([Row|Rows]) :-
  492.         label(Row),
  493.         labelRows(Rows).
  494. sudoku2(Exps, MaxLength, Rows, Nodes) :-
  495.         length(Rows, MaxLength), maplist(length_list(MaxLength), Rows),
  496.         append(Rows, Vs), Vs ins 0..MaxLength,
  497.         %maplist(all_distinct, Rows),
  498.         %transpose(Rows, Columns),
  499.        % maplist(all_distinct, Columns),
  500.         %Rows = [A,B,C,D,E,F,G,H,I],
  501.         columns(1, Exps, Rows, MaxLength, Nodes).
  502. columns(_, _, [], _, []).
  503.  
  504. % current = [_,_,_,_,_...] where _ ... are targets
  505. % and this is source ?
  506. columns(FromId, Exps, [CurrentTargets|RestTargets],MaxLength, Nodes) :-
  507.         CurrentTargets ins 0..MaxLength,
  508. %       RowId ins 0..MaxLength,
  509.         NextFromId is FromId + 1,%RowId #< NextRowId,
  510.         format('columns : Will check values for fromId ~w ~n', [FromId]),
  511.         StartTarget = 1,
  512.         checkcurrenttargets(FromId, StartTarget, Exps, CurrentTargets, MaxLength, TargetNodes),
  513.         columns(NextFromId, Exps, RestTargets,MaxLength, Ns),
  514.         append(TargetNodes, Ns, Nodes).
  515.  
  516.  
  517. checkcurrenttargets(_,_,_,[],_, []).
  518. checkcurrenttargets(FromId, TargetId, Exps, [Target|Targets]/*TargetIds*/, MaxLength, Nodes) :-
  519.         format('checktargets : Will check values for fromId ~w targetId ~w ~n', [FromId, TargetId]),
  520.         %TargetsIds = [Target|Targets],
  521.         %length(TargetIds, MaxLength),
  522.         %TargetsIds ins 0..MaxLength,
  523.         (
  524.         (   nth1(TargetId, [Target|Targets]/*TargetIds*/, Weight),
  525.         check_in(
  526.             node(FromId, TargetId,Weight,Weight),
  527.             Exps, _),
  528.             append([node(FromId, TargetId, Weight, Weight)], [], CurrentNodes)
  529.         ); true)
  530.         ,
  531.         NextTargetId is TargetId + 1,
  532.         checkcurrenttargets(FromId, NextTargetId, Exps, Targets/*TargetIds*/, MaxLength, Ns),
  533.         append(CurrentNodes, Ns, Nodes).
  534.  
  535. testlabel3(A) :-
  536.        experiences(Exps),
  537.        findall(Origin, member(exp(Origin,_,_),Exps), As),
  538.        sort(As, Ss),
  539.        length(Ss, MaxLength),
  540.        MaxLength > 0,
  541.        testlabellazy3(MaxLength, Exps, A, Ss),
  542.        !,
  543.        label(A).
  544. testlabellazy3(_, _, _, []).
  545. testlabellazy3(MaxLength, Exps, A, [Current|Rest]) :-
  546.         %experiences(Exps),
  547.         %max_network_length(Exps,MaxLength),
  548.         length(A, MaxLength),
  549.         %A=[B,C,D,E], % optional
  550.         A ins 0..MaxLength,
  551.         (nth1(Current,A,W),
  552.         check_in(node(Current,_,W,W), Exps, _));true,
  553.         testlabellazy3(MaxLength, Exps, A, Rest).
  554.  
  555.  
  556.    schedule(TSDs, Vars, End) :-
  557.            tasks(TDs), maplist(td_tsd, TDs, TSDs),
  558.            precedence_constr(TSDs, 0, End, Vars, []).
  559.  
  560.    td_tsd(T/D, task(T,_S,D)).
  561.  
  562.    precedence_constr([], End, End)                  --> [].
  563.    precedence_constr([task(T,S,D)|TSDs], End0, End) --> [S],
  564.            { S #>= 0, S + D #=< End, End1 #= max(End0, S + D),
  565.              maplist(precedence(T,S,D), TSDs) },
  566.            precedence_constr(TSDs, End1, End).
  567.  
  568.    precedence(T0,S0,D0, task(T,S,D)) :-
  569.            (   prec(T0 =< T) -> S0 + D0 #=< S
  570.            ;   prec(T =< T0) -> S + D #=< S0
  571.            ;   true
  572.            ).
  573.  
  574.    tasks([t1/5, t2/7, t3/10, t4/2, t5/9]).
  575.  
  576.    prec(t1 =< t2). prec(t1 =< t4). prec(t2 =< t3). prec(t4 =< t5).
  577. testschedule(Ts, Vars, End) :-  schedule(Ts, Vars, End), End #=< 33, labeling([min(End)], Vars).
  578. testsudoku(Rows) :- problem(1, Rows), sudoku(Rows), maplist(writeln, Rows).
  579.  
  580.  
  581. make_labelling(LAssoc) :- label(LAssoc).
  582.    /* Experiments  :- [
  583.         truc('LIGT', [v(1, 2, 3), v(2, 3, 4)]),
  584.         truc('TUV', [v(1, 2, 3), v(2, 3, 4)])].*/
  585.         /*group_pairs_by_key([Time-VFrom, Time-VTo],LAssoc).*/
  586.  
  587.  
  588. /*solve(20, []
  589.  
  590. solve(Time, Experiments, Graph, Laws) :-
  591.      DomTime ins 1..20,
  592.      DomExp ins 1..5,*/
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.