# Optimal Cooking Procedure Presentation System for Multiple Recipes and Investigating Its Effect
## 4 System Overview
### Optimal Cooking Procedure Search Algorithm
#### 4.2.2 Overview of the Optimal Cooking Procedure Search Algorithm  
Algorithm 1 shows the pseudocode of a function that recursively creates a search tree used in the optimal cooking procedure search algorithm. In Algorithm 1, \(P\) is the set of cooking/washing tasks that have already been assigned a start/end time in the schedule of the cooking procedure currently being explored, \(E\) is the set of cooking tasks that satisfy the starting requirement in the current state of \(P\), and \(F\) is the set that contains only the cooking tasks in \(P\). Algorithm 1 performs preprocessing on \(E\) and initialization of a tentative optimal cooking procedure \(O\) for the first call only. Figure 9 describes the preprocessing. Then, the function _isBounded_ compares \(P\) and \(O\) to determine the bounding operation. Section 4.2.4 describes the bounding operation. Then, select one cooking task from the \(E\), and call the function _Reconstruct_. Next, the selected cooking task is added to \(P\), and the function _Reconstruct_ determines whether the parallelized result satisfies all the constraints. Then, when the constraint is found to be satisfied, update \(E\) and \(F\), and call the function _Recursive_ again. At this time, the function \(AddExecutableTask\) adds the cooking task that satisfies the starting requirement to \(E\) by the cooking task \(e\). After all the cooking tasks are added to \(P\), the function \(AddCleanUpTask\) adds the cleanup task to \(P\). Here, the washing tasks are added to the gap time when there exists a gap time in \(P\) during which the washing tasks can be performed. Finally, \(P\) and \(O\) are compared, and if \(P\) has a shorter total cooking time than \(O\), \(P\) is updated with \(O\). Algorithm 2 shows the pseudocode for the _Reconstruct_ function that parallelizes the cooking operations and checks the constraints used in Algorithm 1. In Algorithm 2, \(e\) is the cooking task to be added to \(P\), \(U\) is the set of resources allocated to \(e\), \(W\) is the set of resources in \(U\) that need to be washed before \(e\) is executed, and \(G\) is the set of gap time in \(P\) where the user is not used. Figure 4: Partial search tree in DF/IHS. Figure 3: Re-numbered task graph in Figure 1.  
```
input :\(E\) : Executable Cooking task List \(F\) : Finished Cooking task List \(P\) : Provided Schedule output :\(O\) : Optimal Cooking Schedule
1 Pre-processing for E only once ;
2 Initialize O only once ;
3 ifisBounded (O,P)then
4 return
5 ifE is not emptythen
6 foreach element \(e\) in \(E\) in order from topdo
7 isOK,P \(\leftarrow\)Reconstruct(e,P) ;
8 ifisOKthen
9 Remove(E,e) ;
10 AddFinishTask(F,e) ;
11 AddExecutableTask(E,e) ;
12 Recursive(E,F,P) ;
13
14
15
16
17
18
19
20
21 else
22 AddCleanUpTask(P) ;
23 iftime(P) \(<\)time(O) then
24\(O\gets P\) ;
25
26
```  
**Algorithm 1**Recursive Function  
Figure 5 illustrates an example of how Algorithm 2 works when task D is added to the temporary schedule \(P\) in which tasks A, B, and C are already added. ``` input :\(e\) : Cooking Task \(P\) : Provided Schedule output :\(isOk\) : Does P Satisfy Continuity \(P\) : Provided Schedule
1\(U\leftarrow\)AllocatesResources(\(e\)) ;
2\(W\leftarrow\)GetNeedWashingResources(\(U\)) ;
3 if\(W\) is not emptythen
4\(G\leftarrow\)GetNotUsingUserTime(\(P\)) ;
5 InsertWashingTask(P,W,G) ;
6 foreach element \(w\) in \(W\)do
7 AddWashingTask(P,\(w\)) ;
8 AddCookingTask(P,e) ;
9 isOK \(\leftarrow\)isSatisfyContinuity(\(P\)) ;In Algorithm 2, we first allocate the resources \(U\) to be used in \(e\) by the function \(AllocationResources\). This function allocates resources in the following order when there are multiple candidate resources to be allocated. * A resource that is not being used and does not require a washing task
* A resource that is not being used and requires a washing task
* Earliest available resource

Next, the function \(GetNeedWashinResources\) retrieves the set of resources \(W\) in \(U\) that need the washing task.