Advances in Artificial Intelligence

Advances in Artificial Intelligence / 2016 / Article

Research Article | Open Access

Volume 2016 |Article ID 2959508 | https://doi.org/10.1155/2016/2959508

Noel Nuo Wi Tay, János Botzheim, Naoyuki Kubota, "Weighted Constraint Satisfaction for Smart Home Automation and Optimization", Advances in Artificial Intelligence, vol. 2016, Article ID 2959508, 15 pages, 2016. https://doi.org/10.1155/2016/2959508

Weighted Constraint Satisfaction for Smart Home Automation and Optimization

Academic Editor: Roman Bartak
Received07 Apr 2016
Accepted05 Oct 2016
Published23 Nov 2016

Abstract

Automation of the smart home binds together services of hardware and software to provide support for its human inhabitants. The rise of web technologies offers applicable concepts and technologies for service composition that can be exploited for automated planning of the smart home, which can be further enhanced by implementation based on service oriented architecture (SOA). SOA supports loose coupling and late binding of devices, enabling a more declarative approach in defining services and simplifying home configurations. One such declarative approach is to represent and solve automated planning through constraint satisfaction problem (CSP), which has the advantage of handling larger domains of home states. But CSP uses hard constraints and thus cannot perform optimization and handle contradictory goals and partial goal fulfillment, which are practical issues smart environments will face if humans are involved. This paper extends this approach to Weighted Constraint Satisfaction Problem (WCSP). Branch and bound depth first search is used, where its lower bound is estimated by bacterial memetic algorithm (BMA) on a relaxed version of the original optimization problem. Experiments up to 16-step planning of home services demonstrate the applicability and practicality of the approach, with the inclusion of local search for trivial service combinations in BMA that produces performance enhancements. Besides, this work aims to set the groundwork for further research in the field.

1. Introduction

As human lifestyle has become increasingly hectic, smart home starts to gain more prominence. Smart home is a viable solution to provide comfort for its human inhabitants, monitoring, and caregiving for the elderly. Demographic shifts towards elderly people for developed and some developing countries are a serious issue, where caregivers are in short supply relative to the population of the elderly, which is a serious issue in Japan as the elderly population is expected to reach 25.2% of the total population. Many of them will lose the ability to live independently [1, 2]. With the rising number of the elderly coupled by hectic lifestyle of the working class, the elderly cannot be provided with ample care that they need. Therefore, it is necessary for the home to provide support to handle mundane tasks and to ensure the continual welfare of its human inhabitants.

Smart homes need to provide services based on the devices that they are connected to. Given the available devices and initial state of the house, smart homes should coordinate their services in order to reach the maximum number of goals set from either human command or event triggered by generating an optimal sequence of plans. An optimum plan can mean a plan that minimizes energy consumption or maximizes comfort. For this paper, optimization is defined as minimizing a certain quantifiable cost. Besides that, the plan should also abide by constraints such as user preferences and physical limitations. An example of constraint related to user preference is the need for a room to be well lit when the user is in there while awake. An example for physical limitation constraint can be that the curtain needs to be open before the window can be swung open.

Researches related to web services and semantic web provide concepts and technologies that can support service discovery, the design and implementation of services, and providing machine understandable semantics for reasoning. The idea is adopted by ubiquitous and pervasive computing due to its ability to discover services and support for late binding of services.

Advancements in the web of things and web service technologies can shed light on service composition for building automation of the smart home. Similarities are quite significant, where both are dealing with high heterogeneity of objects, dynamic environment due to objects connection and disconnection from the system or due to contextual changes, and the need for integration and coordination of different objects to deliver complex services. Service oriented architecture (SOA) [3] complemented by automatic service composition provides the crucial approach in delivering what is required of home automation. SOA consists of independent but interoperable services that are loosely coupled, where each service only exposes its functionality to others, keeping the details of implementation hidden.

As argued by [4, 5], the main focus of previous platforms of pervasive applications does not consider complex and intelligent functionalities involving higher levels of information. Dynamic composition of complex sequence of services under uncertainty is necessary. Currently, to enable higher functionalities, tedious procedural programming is required from the user side. Besides, certain applications require manipulation and reading of values, such as counting the number of times a person goes to the toilet. Reference [4] uses artificial intelligence method, namely, constraint programming, to handle such service composition task where variables of a wider domain are required in the planning process. It performs service composition through solving constraint satisfaction problem (CSP) and implements individual services by appropriate devices. Hard constraints are used, and therefore the approach cannot (or at least very inefficiently) support optimization and partial goal fulfillment. Partial fulfillment of goals is important because certain goals might contradict each other or because they might be too complicated to solve in one go. For this, solving via hard constraints will conclude that the goal is unsatisfiable instead of trying to fulfill as many goals as possible.

For example, a given mother is requesting the TV to switch to channel 1, whereas her daughter requests channel 2. These two goals contradict each other. Service composition via hard constraints will conclude that the goals are not satisfiable, instead of trying to fulfill one of their wishes (such as switching to channel 1 to fulfill the mother’s wishes as the goal imposed by her is considered much more important compared to the daughter). Such problems can be solved with soft constraints by introducing weights.

This work is built on the previous work on Informationally Structured Space (ISS) [6] by providing it with automated planning and optimization. It aims to extend the smart home automated planning approach in [4] from using CSP to Weighted Constraint Satisfaction Problem (WCSP). WCSP endows constraints with weights, which transforms them into soft constraints where optimization can be implemented. Branch and bound with depth first search is applied to solve the planning problem represented as WCSP, where the lower bound is estimated via bacterial memetic algorithm (BMA). Memetic algorithms have been shown to be effective in handling weighted constraints that give good enough solutions [7]. Test on various plan sequences and modifications shows the applicability of the approach in generating optimal plans in fulfilling the maximum number of goals. It lays the necessary groundwork and obtains implications for further development. This work will not cover the middleware implementation. Services are described by preconditions, effects, and properties, which resemble those of web services, such that they can be easily translated to current web service technologies.

This work is on high level planning. We like to consider smart devices such as the Google Nest that is capable of learning and adjusting as a composed service that we can call upon, or there are inferred results, which can be used by planning. This is likened to the automatic setup of surveillance system or robot navigation to a certain cabinet in a certain room. The former can be achieved through service composition via association with SWRL or SPARQL language [8]. The latter can have a built-in path finding algorithm that works with high level planning, where high level planning has to ensure proper working environment for low-level functions [9]. Theoretically, planning itself can handle all the tasks, including device association and low-level path finding. But, due to efficiency issue, it is considered that composed service and low-level tasks can be called upon as an actor of a particular planning operator.

The outline of the paper is as follows. Section 2 discusses the related works on home automation and service composition. The approach to solve planning problem through WCSP is presented in Section 3. Experiments are provided in Section 4 to demonstrate the applicability of the approach. Finally, the work is concluded in Section 5.

2. Background

The main focus of this paper is on home automation. Various home automation systems have been developed over time that employ the SOA architecture complemented by web technologies.

Home automation for inferring environment state is developed in [10]. It uses DogOnt ontology [11] to determine environment states like whether a certain room is smoke-free and mosquito-free depending on which rooms are adjacent and whether certain doors or windows are open or not. This work shows that additional information of environments can be inferred by defining a set of rules. Although it does not include service composition, since it only deals with sensors, nevertheless, it provides insight into generating rules as goals for service composition to work on.

The work in [12] uses knowledge representation and automated reasoning to create a self-adapting framework for managing user profiles and device services. Rule matching need not be exact, where it allows potential or intersection matches, which is the case in most practical situations. It supports partial or disjoint matches, where requests and supplied resources have conflicting features and when no other matches are possible. Service composition is performed through constant running of concept abduction algorithm [13] and selecting services to cover missing features. But such service composition will not be applicable if complex sequence of service is needed. Situation is made worse under uncertainty. A more flexible system is developed in [14], where the case study is to maximize human comfort and energy efficiency.

Building automation adopting SOA and device profile for web service (DPWS) is proposed in [5]. Context information is obtained for processing before being used to guide service composition, complemented by policy rules and composition plans. To handle dynamic changes during service composition, it uses service composition plans to describe users requirements by Composition Plan Description Language (CPDL). Similar to [12], service composition does not support construction of complex sequence of services, such as the case of robot query on users preferred activity before preparing the environment for such activity.

Kaldeli et al. [4, 15] developed a home automation service composition based on SOA that is capable of complex composition of a sequence of services using constraint programming. Unlike previous methods, the system does not require manual construction of subplans. It handles context awareness and is able to deal with an uncertain situation by dynamic replanning. By using constraint programming, it can also handle variables with large domain efficiently. But the work employs hard constraints. It cannot fulfill partial goals as well as optimizing plans.

Home automation requires service composition to be functional. Here, we will review some service composition methods that are applied or are closely overlapping with the methods used in home automation. More detailed review on service composition can be obtained from [16].

In [17], OWLS-XPlan uses the semantic descriptions of atomic web services defined in OWL-S for planning purposes. Given the atomic services, the XPlan planning module will generate the sequence of services to fulfill a goal. In the work, an XML dialect of planning domain definition language (PDDL) is developed; thus, the system is PDDL compliant. Although the system obtains semantic descriptions in OWL-S, it is not utilized and semantic awareness is not achieved. Exact matching for service inputs and outputs is required from the planning module. This is the downside, as the most practical situation does not allow exact matching.

A framework developed in [18, 19] converts web service composition tasks into planning problems expressed in PDDL. The framework will then convert the devised plan into an OWL-S composite process description. The framework translates atomic OWL-S processes to planning operators, from which it derives the set of actions to achieve goals. Contrary to [17], when no exact composite services can be found, semantic information is utilized to obtain composite services that best approximate the goal.

To deal with complex tasks and to reduce planning complexity, hierarchical task network (HTN) [20] is introduced. It uses method definitions in its planning domain description, which specifies how the complex tasks can be broken down into more manageable tasks [21, 22]. The planning problem can then be specified as a list of tasks to perform. The planner will then solve the problem by applying the breaking down of tasks to every task in the task list. This process continues until the tasks are reduced to their atomic planning operator constituents that correspond to a solution plan. The main disadvantage of this approach lies in the fact that the planning process requires that certain decomposition rules be specified due to its hierarchical nature. This means that it needs to be encoded in advance by an expert.

The methods discussed thus far either require exact matchups between inputs, outputs, and variables or assume certain ontologies to handle heterogeneities or require specifications of user intention and procedural templates. Domain and goal modeling through CSP is developed to create a language that allows users to express goals without having to know about the details and interdependencies between services [4, 15, 23]. Its domain representation is of similar concept to the Multivalued Planning Task (MPT) encoding [24]. Besides, another advantage is that it is able to handle variables with large domain efficiently, which is quite prevalent in the field of autonomous home such as temperature value and user location. Although the CSP planner might be slower than some state-of-the-art methods [22, 25, 26], it can support complex goals and can handle variables with large domain efficiently. To be able to support optimization capability, constraints need to be endowed with weights, thus extending CSP to WCSP.

3. The Proposed System

A system to compose complex plans that are optimized is built based on WCSP. This section will first consider the domain description of the problem and how representing the planning problem as CSP and solving it help generate complex plans to achieve goals. The CSP approach described is based on the work of Kaldeli et al. [4]. Subsequently, extension to WCSP through branch and bound method will be explained.

3.1. Planner Module

This section introduces the planning/implementation process devised for performing automated planning and execution under an uncertain situation. Figure 1 shows the flow chart of the planning and plans implementation process, which is central to the planning/implementation block of the ISS framework. With the services that come from devices connected to the ISS, the planner will plan a sequence of actions to be implemented to fulfill goals.

Variables are instances to record knowledge (termed as knowledge variable) or act as a switch pertaining to a corresponding object (termed as effect variable). An example of a knowledge variable is the variable that records room temperature. For effect variable, an example is a variable , which turns the TV on if it is of state 1.

An activity is a service that is being wrapped with appropriate parameters, effects, and preconditions. Examples are shown in Tables 1 and 2. At planning stage, information of devices associated with the activities is obscured from the planner. Activity’s role is to manipulate the values of the variables, which have correspondence with the physical world associated during variable binding. An activity contains preconditions and effects. Preconditions are conditions that need to be true before the activity can be executed. Effects are the changes that the activity makes when the activity is finished without any glitches or unforeseen circumstances.


Name Precondition Effect Weight

generatorON n/a 2
lightON 3
fanON 2


Name Precondition Effect Wt

generator1ON 3
generator1OFF 3
generator2ON 2
generator2OFF 2
lightDim’n’ON
lightDim’n’OFF
lightBright’n’ON
lightBright’n’OFF
fan’n’ON
fan’n’OFF
door’n’Open 2
door’n’Close 2
window’n’Open
window’n’Close
curtain’n’Open
curtain’n’Close
TVON 2
TVOFF 2
SwitchChannel 2
GetUPchannel 2
GetWeather 2

The following is the explanation for the process flow shown in Figure 1. The system starts at state −1, where initialization is performed and connection is set up. At this stage, it is required that variables are already bound and activities are ready. The system will restart at stage −1 if there are changes to the number of variables and services due to device connection or disconnection or failure. After initialization, goal is obtained and planning is implemented. If a sequence of activities is found that can fulfill the goal, the system will proceed to stage 1. Otherwise, it will proceed to stage 4, indicating a failure. Stage 1 deals with getting the next activity in sequence to be executed. After the next activity is selected, it will proceed to stage 2, which is orchestration of activities. Before execution occurs, it needs to check whether the precondition is fulfilled, upon which, if not, it will proceed to stage 0 for replanning. If the precondition is fulfilled, activity is executed by sending command to the relevant devices. After the device finishes executing the activity, the system will proceed to stage 3. Connection loss or device failure is bound to happen, which will delay or stop executing the activity altogether. Given this situation, stage 2 has a time-out threshold, upon which if the threshold is reached, the system will assume that the current plan does not work and proceed to stage 0. Despite being not implemented yet, this event can be logged to record the number of failures a certain device faces. This can help determine the quality of service of the devices, such that it can be used as a weight when selecting services. Stage 3 checks for 2 things: whether there is any activity left for execution (if true, the system will proceed to stage 1 to get the next activity) and if there is none, it will check whether the goal is fulfilled or not. If the final goal is not fulfilled, then it will proceed to stage 4, otherwise, to stage 5, indicating a success. Given stage 4 or stage 5, the system will proceed to stage 6. Stage 6 records a log of past events, obtains a new goal, and proceeds to stage 0. Stage 0 is similar to stage −1 except that it does not need to perform initialization.

3.2. Preliminaries

Domain description for activity planning is based on the work of [15]. We denote as variable set (list of variables). contains variables, which consist of knowledge, effect, and response variables confined by their own domain. Response variables represent information that can only be obtained from objects, information that comes from sources not within . During planning stage, response variables remain the same throughout all planning sequences and represent an unknown value (thus, initialization constraint is imposed on them). From [15], the response variables can take on whatever value to facilitate constraint satisfaction during planning that employs an optimistic approach (values taken on by response variables are considered true).

A state is a tuple of values to variables at a particular plan implementation sequence with index that is denoted as , where , confined by their domains denoted by . As there is a finite limit to the number of sequences per plan being planned denoted as , thus, . For the current work, domains of the variables remain unchanged over time.

is the set of activities, where . is the identifier of the activity. There is an additional activity in that does nothing. It has no preconditions and effects, termed as .

is the precondition that needs to be met before the activity can be executed, such as the location being known as a precondition to implement the weather forecast web service. Precondition of an activity can be described as follows:where , is a constant, is a binary operator, is a relational operator, and is a Boolean relation.

is the changes that will be induced after the activity is completed. It emulates how the variables will change given the activity is run by its corresponding objects such that its logical formulation can be used to impose constraints on subsequent sequence of the plan for activity planning. It should be emphasized that the actual object manipulates variables during run-time after planning instead of the formulation (which is only used for planning). Effect of an activity can be formulated as or a combination of the following: , , and , where or , are constants and is the sum, subtraction, and Boolean operation.

Given the goals, which are represented as propositions, activity planning can be obtained to fulfill the goal by representing the problem as constraint satisfaction problem (CSP) and solve it [4, 15]. A constraint satisfaction problem is a triple , where is a set of variables, is the set of domains of the variables in , and is a set of constraints over . consists of every state up to index , where , is a set of response variables, and is the chosen goal at sequence index . A solution to a CSP is an assignment of values to the variables in such that the values fall within and all constraints in are satisfied, which is normally obtained from backtracking methods [27].

consists of constraints imposed by a chosen activity at from activity preconditions and effects, law of inertia, initial and final variable state, and maintenance of achieved goal constraints. Initial variable state is just a constraint that dictates the values of all variables (obtained from object state module) before any planning. Final state constraint consists of the goal proposition that needs to hold at sequence index .

Constraints from activity preconditions:Constraints from activity effects:where is the law of inertia, which indicates that for every other variable var (excluding those from ) not affected by , .

Maintenance of Achieved Goal Constraint. This constraint dictates that whenever a goal is achieved at sequence index Maintenance of achieved goal constraint is just one of the goals specified in [15, 23], though it is sufficient for the current work.

There are 3 types of variables during planning, which are knowledge, effect, and response variables. Knowledge variable stores a piece of information that can be referred to in the future. Associated with every knowledge variable is a flag that indicates whether the information is updated or not (in this paper, these are variables with subscript ). Effect variables record the state objects are in. Every effect variable has a flag to indicate whether the state is changed or not (the variable is indicated by a subscript ). Response variables represent information that can only be obtained during run-time. Details on how these variables work can be found in [15, 23].

To increase the speed of the constraint satisfaction solver, only activities that are relevant to the given goals are selected. This work employs the same method used by [28]. Irrelevant activities to the goal are pruned out to reduce the search space. For every activity , a list of other activities that has at least one effect that has the potential to satisfy one of the preconditions of is found. Backward action chain is then computed. This chain of actions can be used to select the activities that are relevant to the imposed goal. is denoted as the set of relevant activities. An interesting alternative is to use dependency graph as proposed in this work [29] or to divide all the activities into effects ontology to shortlist relevant activities [30].

CSP approach employs hard constraints, which are fed to a solver to obtain a sequence of that are the activities that need to be implemented to fulfill the given goals. One example of state-of-the-art solver is Z3 SMT solver, which can efficiently obtain the plan given hard constraints [31]. The plan will be solved by continually increasing until the constraints are satisfied. Such solvers cannot handle soft constraints to perform optimization and partial fulfillment of goals, or at least not efficiently.

A Weighted Constraint Satisfaction Problem (WCSP) can be described as a tuple [32], where , is the set of domains of the variables in , and is a set of weighted constraints. One can think of as with all the constraints having infinity as weight values . The objective function is the sum of all functions in :The goal is to find the instantiation of all variables such that it minimizes the objective function.

Various approaches have been used to solve general WCSP, which includes search, clustering, and variable elimination as explained in this paper [33]. Good heuristics used can also further hasten solving process [34]. Our problem is specific to planning with domain description described previously. Therefore, internal structures can be exploited to build a solver that is specially tailored for plan composition via solving WCSP. Branch and bound with depth first search is used due to polynomial space complexity and the ability to handle constraints of high arity and wide domain, compared to methods like variable elimination [35] (though variable elimination can be combined with search to obtain a much better result [33]). Besides, using a relaxed condition of the former planning problem as shown in Section 3.5, lower bound can be easily obtained to prune the search graph.

3.3. Design of Automated Planner

Given an initial state (or initial variable instantiations), an optimized plan means a plan that can fulfill the maximum number of goals with the least number of activities (or with the least cost given the sum of the costs for all activities), where the sequences of activities need to abide by their individual precondition and effects described in Section 3.2.

Goals are constraints for the final possible variable instantiations. For example, if the goal is , then final state should be or or . Weights associated with every goal are imposed as costs if the goal is not fulfilled in the final state.

Constraints imposed by activities are the preconditions and effects. An activity can only be implemented if its preconditions are met. For example, a TV can only change its channel given the precondition that the TV is on. At the same time, it is considered (at least in planning phase) that effects of activities will definitely change the subsequent state (e.g., the act of changing TV channel will result in a change to the preferred channel). Due to uncertainty, effects might not give the desirable response during actual execution. But this is not an issue given the dynamic planning framework described in Section 3.1, which supports replanning. That said, constraints from preconditions and effects are treated as hard constraints unlike goal imposed constraints.

Activities themselves also come with weights. But unlike weights for constraints, these weights are imposed when an activity is implemented. They act as costs for their respective activities. This is important as there are times when one prefers certain activities to others. For example, during late night, a person might prefer the dimmer light to be switched on instead of the brighter ones. Therefore, the action to switch on the brighter light imposes a higher cost than its dimmer counterparts.

It is assumed that weights are determined depending on situation and time. But this paper does not deal with weight settings. Our intention is that, given a set of constraints and weights, the system will try to generate a sequence of activities as plans that is optimum. In order to achieve that, it needs to minimize the following cost function:where is the weight for implementing activity and gives the cost given whether or not precondition for is fulfilled by state at sequence . Due to precondition being a hard constraint, will return infinity if precondition is not met.

, which gives the final state when activity is implemented on state , followed by , and so on until finally .

, which gives the total cost imposed by nonfulfilled goals. is different from (5) as it only considers variables at the final state sequence, whereas (5) considers variables of all sequences.

As an example, consider two goals: (1) fan is on with weight and (2) light is on with weight ; and consider an initial state where generator, light, and fan are all off (, resp., in short). Example activities are shown in Table 1.

Case 1. Activity sequence is generatorON ⇒ lightON ⇒ fanON (which means generatorON is executed, followed by lightON and finally fanON). There is no precondition of generatorON; therefore, component will return a 0. Effect from the activity will set , thus . Given this new state, precondition for lightON () is also met, and execution proceeds until fanON. Finally, the state will be . Total cost returned by is 0. Total cost of activity is generatorONlightONfanON. Since the 2 goals are fulfilled, returns 0 too. Total cost is 7.

Case 2. Activity sequence is generatorON ⇒ lightON. Execution of the plan will result in final state . All preconditions are met; thus, returns a total of 0. Total cost of activity is 5. Since goal 1 is not satisfied, returns 4. Total cost is 9.

Case 3. Activity sequence is lightON. Since the initial state is , precondition is not met. returns , rendering subsequent calculation trivial.

Equation (6) tries to find a sequence of activities that is optimal. Due to the use of logical constraints, optimization becomes complicated. Direct search is intractable, aggravated by hard constraints and its weights from .

Equation (6) can be relaxed by eliminating and, in turn, reformulated as goals. Problem reformulation is explained in Section 3.5. The relaxed optimization problem can then be used to calculate the lower bound for branch and bound via BMA explained in Section 3.6.

The planning representation as well as the heuristics used for optimization in this work assumes nonparallel encoding.

3.4. Branch and Bound Search

Search tree represents the possible paths to reach potential solutions. For our planning problem, every layer of the tree is a particular sequence of activity, which in our case has a total of layers. Every node is a particular state. Edges are the actions taken, which transform to . Figure 2 shows an example of the search tree for planning.

Depth first search branch and bound works by choosing a path that gives the best estimated cost, where the best estimated cost of the nodes for every layer except the layer of the leaf nodes is estimated via a heuristic function , given its previous cost. estimates the best possible cost to reach the goal state by using the relaxed optimization problem, which combined with previous cost gives the lower bound. A potential solution is reached when the path reaches the leaf nodes. Total cost of every potential solution will be compared with the upper bound, upon which if lower, the upper bound will be updated. Branch and bound reduces the number of search paths by pruning branches of the respective nodes where their lower bound is higher than or equal to the upper bound.

Algorithm 1 shows a recursive search algorithm for optimized planning. The result of the algorithm is , which is the optimized sequence of plans.

Result:
Upper bound (global variable) ;
Current cost ;
Sequence index ;
State initialized;
Activity sequence set to empty;
Store all relevant activities in ;
note: Recursion starts
Function ;
if    then
     if    then
     Update ;
     ;
     ;
     end
else
     for      do
     if  
     then
       ;
       note: Store the estimated lower bound if activity is applied.
           returns the weight of activity ;
      else
       ;
       note: Or else set the lower bound to ;
     end
     end
     ;
     note: Sort in ascending order based on their lower bound;
     for  Loop through    do
     note: Looping through the sorted list;
      ≔ Lower bound of current selection;
      ≔ Activity of current selection;
      ≔ State after the effect of ;
     ;
     if    then
           Break the loop;
     else
           ;
           ;
     end
     end
end

Before the algorithm starts, current cost and upper bound are set to . State is set to initial state values. Set is also constructed, which consists of a collection of relevant activities given the goals as described in [28].

The algorithm starts off by checking whether or not the last layer of the tree is reached, upon which if yes (meaning it is a potential solution), it will update if the total cost is lower. Further fine tuning can be made by checking for activity redundancy through , which checks whether the omission of certain activities will yield better result. Given a sequence of activities, will loop through each and calculate whether their omission will produce lower cost. As fast stochastic search is employed in calculating the lower bound, this comes at a price where certain redundant activity will be introduced (given activity cost does not warrant much cost relative to those imposed by goals, which is the situation for our experimentation).

If leaf nodes are not reached, current node is branched out to the subsequent layer, where each branch represents the effect from each activity. Lower bound is estimated for each node of the new layer via BMA that will be explained in Section 3.6. Lower bounds for activities that do not have their preconditions met are assigned . Besides that, further checking is performed by . checks whether the selection of a certain activity for branching coincides with pairs listed in the local search lookup table, where the lookup table is explained in Section 3.7. The activities are then sorted according to their lower bounds to determine which activity should be branched out further for evaluation. If is lower than or equal to an activity’s lower bound, that branch and the subsequent branches in the sort list are all pruned out.

Currently, we assume goals to be the desirable final state. Sometimes, extended goals that dictate how a plan is arranged instead of the desirable final state are needed. For example, the generator should not be switched when any electrical appliances are turned on. Algorithm 1 can be extended to support extended goals by treating such goals as preconditions for activities, such that the part Preconditions for are met and LSh_Check in Algorithm 1 can prune out inconsistent activities. The part can also be modified to support weighted extended goals such that unfulfilled extended goals will impose a higher cost on the activity. Extended goal is subject to future work.

3.5. Relaxing Optimization Problem

To obtain a larger feasible region by removing restrictions, (6) is relaxed by converting the component to goals, which gives varies from in the sense that it considers not only cost from fulfillment of goals, but also extra subgoals introduced by the conversion of .

Conversion is done under the concept that whenever an effect of an activity takes place, its precondition has to be met. Therefore, subgoals are constructed in such a way that if a variable holds a certain value in the final state and that it is different from its initial value, it implies that one of the preconditions of activities which subject that particular variable to hold that value has to be true. Currently, only variables of Boolean type are considered for conversion. Other types such as integer and finite domain sorts are subject to future research. Conversion of variables is limited to 4 types of effects pertaining to the variable, which are , , , and , where is a variable. The first two types of conversion are shown in Algorithm 2. The third type is shown in Algorithm 3, whereas the fourth is shown in Algorithm 4. The number of generated subgoals is denoted by . Extra subgoals equipped with weights reduce the effective branching factor. Optimizing the relaxed problem thus gives a better lower bound.

, is a value where either or ;
is the initial value of ;
set to empty;
if  is not a response variable  then
  for   = all activities  do
     if  Found in the effects  then
         Add precondition in ;
     end
  end
end
Add as sub-goal;
note: statement is true if at least one addition of
   precondition in it is true;
;
is the initial value of ;
set to empty;
if   is not a response variable  then
  for   = all activities  do
     if  Found in the effects  then
         Add precondition in ;
     end
  end
end
Add as sub-goal;
Add as sub-goal;
;
is the initial value of ;
set to empty;
for   = all activities   do
  if is not a response variable   then
     if  Found in the effects   then
         Add precondition in ;
     end
  end
end
Add as sub-goal;
Add as sub-goal;
3.6. Bacterial Memetic Algorithm Optimization

Bacterial memetic algorithm (BMA) is applied for finding the optimal solution for the relaxed optimization problem discussed in Section 3.5. BMA is a population based stochastic optimization technique which effectively combines global and local search in order to find good quasi-optimal solution for the given problem [36]. In the global search, BMA applies the bacterial operators, the bacterial mutation, and the gene transfer operation. The role of the bacterial mutation is the optimization of the bacteria’s chromosome. The gene transfer allows the information’s transfer in the population among the different bacteria. As a local search technique, individual reparation is applied for all bacteria.

In case of evolutionary and memetic algorithms, we have to discuss the encoding method and the evaluation of the individuals (bacteria) as well. The encoding of the individual is a sequence with indexes. The evaluation of the bacteria is calculated by BMA’s task is to generate a sequence of activities (from a pool of activities from ) such that is minimized.

The operation of the BMA starts with the generation of a random initial population containing individuals (see Algorithm 5). Every individual is a particular sequence . Next, until a stopping criterion is fulfilled (which is usually the number of generations, ), we apply the bacterial mutation, gene transfer, and local search operators. Bacterial mutation creates number of clones (copies) of an individual, which are then subjected to random changes in their genes (see Algorithm 6). The number of genes that are modified with this mutation is a parameter of the algorithm (). After the bacterial mutation, the gene transfer operation is applied at population level (see Algorithm 7). This means copying genes from better individuals to worse ones. For this reason, the population is split into two halves, according to the cost values. The number of gene transfers in one generation (), as well as the number of genes () that get transferred with each operation, is determined by the parameters of the algorithm. The last operator in each generation is the local search, which performs reparation of all individuals, using a lookup table, which describes conflicting values in the neighborhood genes of the bacterial chromosome.

Create initial population;
;
while    do
  for    to    do
     BacterialMutation()
  end
  GeneTransfer;
  for    to    do
     LocalSearch()
  end
  ;
end
Create clones of ;