%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% phiCAD2NC %%% %%% ANC-Plan Generation %%% %%% Michael Sintek First Version: August 1991 %%% %%% Harold Boley, Markus Perling Current Version: June 1997 %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Input: skeletal-plans % Output: abstract NC programs: % anc-program ::= [ { }* ] gen-anc-plan(skp[Globals,[]]) :& []. gen-anc-plan(Skp) :- get-promising-tool(no-tool, 0, no-actions, no-rest-skp, get-tools(extract-actions(get-skp-top(Skp))), Skp, Best-tool, Best-costs, Best-actions, Best-rest-skp), pretty-print(Best-actions), rf-princ(Best-costs), rf-princ(->), rf-terpri(), pretty-print(Best-rest-skp), rf-terpri(), rf-terpri() & appfun(Best-actions,gen-anc-plan(Best-rest-skp)). % get-promising-tool % ------------------ % call: get-promising-tool( % % % % % % % % % ) get-promising-tool(Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, Best-rest-skp-so-far, [], % no more tools Skp, Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, Best-rest-skp-so-far). get-promising-tool(Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, Best-rest-skp-so-far, [Tool|Rest-tools], Skp, Best-tool, Best-costs, Best-actions, Best-rest-skp) :- new-once(compute-costs(Skp,Tool,Actions,Rest-plan,Costs)), >(Costs,Best-costs-so-far), get-promising-tool2 % check if rest plan is empty (Tool, Costs, Actions, Rest-plan, Rest-tools, Skp, Best-tool, Best-costs, Best-actions, Best-rest-skp). get-promising-tool(Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, Best-rest-skp-so-far, [Tool|Rest-tools], Skp, Best-tool, Best-costs, Best-actions, Best-rest-skp) :- get-promising-tool(Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, Best-rest-skp-so-far, Rest-tools, Skp, Best-tool, Best-costs, Best-actions, Best-rest-skp). get-promising-tool2(Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, [], % empty rest plan -> Rest-tools, % ignore rest tools Skp, Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, []). get-promising-tool2(Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, Best-rest-skp-so-far, Rest-tools, Skp, Best-tool, Best-costs, Best-actions, Best-rest-skp) :- get-promising-tool(Best-tool-so-far, Best-costs-so-far, Best-actions-so-far, Best-rest-skp-so-far, Rest-tools, Skp, Best-tool, Best-costs, Best-actions, Best-rest-skp). compute-costs(Skp,Tool,Actions,Rest-plan,Costs) :- [Actions,Rest-plan,Step-costs] .= skp-exec-action(Skp,Tool), Costs .= +(Step-costs,*(0.7,count-com-actions(Rest-plan))).