• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
CPSC 533 - Artificial Intellience
 

CPSC 533 - Artificial Intellience

on

  • 293 views

 

Statistics

Views

Total Views
293
Views on SlideShare
293
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    CPSC 533 - Artificial Intellience CPSC 533 - Artificial Intellience Document Transcript

    • CPSC 533 – Artificial Intelligence TA Scheduling Problem Search Models Contributors: Kamal Singh Hanif Mohamed Cledelyn ‘Jenica’ Santos Nitin Puri John Lin
    • TABLE OF CONTENTSSET-BASED SEARCH...............................................................................3 SEARCH MODEL .....................................................................................................3 Problem Definition ..................................................................................................3 Extension Rules .......................................................................................................3 Control of the Or-Tree..................................................................................4 Ordering..................................................................................................................4 Start State................................................................................................................4 Search Control ........................................................................................................4 fselect .....................................................................................................................4 Goal Condition........................................................................................................5 SET-BASED SEARCH EXAMPLE .....................................................................................6AND-TREE BASED SEARCH .................................................................9 SEARCH MODEL .....................................................................................................9 Problem Definition ..................................................................................................9 Division Relation .....................................................................................................9 Extension Rules .......................................................................................................9 Search Controls .....................................................................................................10 fBound ..................................................................................................................10 fleaf .....................................................................................................................11 ftie.......................................................................................................................11 fTrans ...................................................................................................................11 Hard Constraints ...................................................................................................11 Soft Constraints .....................................................................................................12 AND-TREE BASED SEARCH EXAMPLE............................................................13 2
    • SET-BASED SEARCHSEARCH MODELFor our set-based search model, we define : • the set F of facts as the set of all possible valid solutions and • the set Ext of extensions as the set of all possible applications of the genetic operators and the elimination rulesPROBLEM DEFINITIONWe define F as:F = {pr = (x1,…,xn) | xi ∈ TA and Constr(pr) = True }Our set of facts is the vector (x1,…,xn) of possible assignments of TAs to labs fulfillingall of the Hard Constraints (hence Constr(pr) = True).EXTENSION RULESOur extension rule involves performing a crossover/mutation through the use of adifferent search control in an or-tree-based search as described in the search controlsection.So, Ext is defined as:Ext = {(x1,…,xn), (y1,…,yn) → (z1,…,zn) | xi, yi, zi ∈ TA and zi ∈ either xi or yi or wi.wi is not an element of xi and yi .zj ∈ TA and is generated randomly in two layers: • the first selection will choose a random value between xi and yi (elements of the parent node). The number generated will choose which parents are to be used for the crossover. • If the values generated results in a valid solution (Constr(pr) = true), then add the solution to the existing individuals. If not, then generate a random number again to choose between the possible remaining transitions. 3
    • Control of the Or-TreeIn the or-tree-based search implementation, if a transition leads to a leaf that isunsolvable (i.e., Constr(pr) = false), then the sol-entry of that leaf is set to ‘no’ and wetrack back to the parent node. In short, the repair function: • takes a search state prkm = (x1,…,xi,…,xn) where x1,…,xi ∈ TA and xi+ 1 =…= xn = ⊥, (here, prkm is a child of the parent node prk) • if Constr(prkm) = false, set sol-entry = ‘no’ • track back to the parent node prk • using Rand(), generate a random value to determine the next transition within the range prk1 to prk(m-1)ORDERINGThe ordering of the elements in the search state si is predetermined by its Eval value. IfEval(pri) ≤ Eval(pri+1), then pri will be placed before pri+1.START STATEOur start state, s0 is defined as:s0 = {( pr1,…,prn) | pri ∈ F and is randomly chosen. We realize that the randomselection is obtained by using an or-tree-based search with a random control. Our randomcontrol for this function will be a random number generator function, Rand() }.Initially, for our set-based search, the start state s0 will contain all randomly chosensolutions (our individuals). We use the or-based tree search to generate our minimumpopulation (state_min) and the maximum population (state_max) will be obtained usinggenetic operators (i.e. crossover).SEARCH CONTROLfselectThe main function of the fselect search control is to select the parents for thecrossover/mutation operation by retrieving two random values generated for 4
    • Let pr = (x1,…,xn) where pri ∈ sj | sj ∈ S.Therefore,fselect = prs and prtwhere s, t are randomly generated values and prs , prt are individuals in the current searchstate at the position indicated by s, t.Elimination Rules:When the population has reached state_max, and we need to make room for newindividuals, we use elimination rules to remove the less fit individuals (solutions) fromthe set. This is accomplished by: • state_max – state_min = num_remove (where state_max refers to the total population size, state_min referes to the minimum population size and num_remove is number of individuals to be removed). We assume that state_max and state_min are given. • The individuals to be removed are determined based on their Eval value. Once num_remove has been calculated, we know how many individuals we need to remove. The individuals with the highest Eval values are eliminated, which in this case will be the ones that are at the end of the set (based on the ordering principle described below).GOAL CONDITIONWe assume that we are given the end condition num_trans, which determines the numberof transitions (crossover/mutation) or state changes. When num_trans is reached, the endcondition is fulfilled, and the individual pr = (x1,…,xn) is returned as the solution. 5
    • Set-Based Search ExampleProblem: Schedule 2 TA’s for 2 courses with a combined 4 labs. TA Availability Captai Courses Eval Taken Bob 11,12,13 3 231 2 233 1 Joe 11,12 2 231 1 233 2 Table 1: TA InformationFor this example, we have the following information:TA = {James, Bond}Courses = {231, 233}Labcourse c1 (231) = 3Times: 11, 12, 13Labcourse c2 (233) = 1Times: 12To illustrate set based search we will use a simple example of obtaining an optimalassignment of 2 TA’s to 4 labs. We define the following: • TA = {J, B} • Labs = {231:1, 231:2, 231:3, 233:1}, which means course:labInitially, our pr = (⊥,⊥,⊥,⊥), where ⊥ represents a lab that has not yet been assigned a TA.Our goal is to obtain pr = (x1,…,xn) where each xi ∈ TA, and n = 4.We also need to assume values for the variables state_max, state_min, and num_trans,(since they will be provided), so we have the following: • state_min = 4 • state_max = 5 • num_trans = 2We also make the assumption that parents and children individuals can proceed to thenext generation.To begin with we must have a start state with state_max individuals as follows: 6
    • s0 = {( J, B, J, J), (J, B, J, B), (B, J, J, B), (J, J, J, B)} with the fitness values of (6, 7, 7, 8)The fitness values are obtained by Eval(assign), and the order of the search state has thebetter assignments in the beginning.We obtain the individuals in the above start state by using an or-tree-based search andthe transitions are selected using a random number generator. We continue to use the or-tree-based search to generate individuals until we have obtained state_min individuals.All individuals in each search state represent valid possible assignments of TA’s to labs.Next we perform a crossover/mutation in order to obtain another individual as we stillhave room. First we must randomly select two sets of parents from the search state (s0).We may then perform a crossover by using a two-layered random control for the or-treeas described in the search control for set based search. Assume we randomly selectindividuals 2 and 4 for the first crossover. Then the or-tree will go through the followingsteps: • Since this example only has two TA’s, we simply select a branch randomly; for the sake of simplicity we will consider the elements of the parents in order. • Assume we randomly select J for the assignment of the first lab (231:1), B for the second lab (231:2), J for the third lab (231:3), and B for the fourth lab (233:1); our new individual is thus (J, B, J, B) which happens to be already in the setUsing the or-tree ensures that all possible solutions contained in a search state are validsolutions that fulfill all hard constraints. So:s1 = {( J, B, J, J), (J, B, J, B), (B, J, J, B), (J, J, J, B)} with the fitness values of (6, 7, 7, 8)We can now perform a second crossover, again randomly selecting two parents. So werandomly select individuals 3 and 1. Once again we perform an or tree based search andthe two-layered randomized control to obtain a new individual (B, B, J, J) which is not inthe original search state. Now two things have occurred: • We have reached the end condition of num_trans = 2 • We also have state_max = 5; we now need to use the elimination rule to restore the number of possible solutions in the search state to state_min = 4. In other words, we must eliminate the solution with the highest fitness (at the end of the search state)s2 = { (B, B, J, J), ( J, B, J, J), (J, B, J, B), (B, J, J, B), (J, J, J, B)} with fitness values (5,6, 7, 7, 8)Since num_trans = 2, we may return the best solution (at the beginning of the searchstate), which has the lowest fitness value. 7
    • Clearly, with more TA’s and labs for assignment, we will have a much higher value fornum_trans, however, we kept the example short in order to provide a clear example ofhow we would implement a set-based search. 8
    • AND-TREE BASED SEARCHSEARCH MODELPROBLEM DEFINITION For the assignment of TA’s to a set of courses, we may define Prob and Div as follows: Prob = {(x1,…,xn) | where n is the total number of labs and xi ∈ TA ∪ {⊥}, and each position (i) represents a particular lab of a particular course, TA is the set of all TA’s, ⊥ indicates unassigned labs} + Let Prob be a set of problem descriptions and Div ⊆ Prob , a division relation. Let pr be an instance of Prob. pr = (x1,…,xn) Then the set Atree = Atree (Prob) We can solve Atree recursively as follows: • (pr, sol) ∈ Atree for pr ∈ Prob, sol ∈ {yes,?} • (pr,sol,b1,…,bn) ∈ Atree for pr ∈ Prob, sol ∈ {yes, ?}, b1,…,bn ∈ AtreeDIVISION RELATION Our division relation Div contains all division possibilities of our set Prob that are essential to solve problems of Prob. The main idea is to use Div to divide our problem Prob into a set of subproblems that will be recursively solved in order to get a solution to the original problem. Div = {(pr, pr1,…,prn) | where pr = (x1,…,xi,…,xn) and x1,…,xi ∈ TA, xi+ 1 =…= xn = ⊥; prj = (x1,…,xi, tj, x i+2,…,xn) where t1,…,tm ∈ TA (1<j<m) tk ≠ tj for all k, j and k ≠ j} We need to either preselect a subset of TA’s to consider in a particular assignment or use the entire set of TA’s for consideration of an assignment.EXTENSION RULES Let pr = (x1,…,xn). 9
    • 1. ErwΛ((pr, ?), (pr, yes)) where pr ∈ Prob such that for all x ∈ pr, x ≠ ⊥ if pr is solved. The conditions for pr being solved are: • fbound (pr) ≤ MinSol (where MinSol = Eval (pr) ), or • xi ≠ ⊥ for all i, or • Constr(pr) = false 2. ErwΛ((pr, ?), (pr, ?, (pr1, ?),…,(prn, ?))), if Div(pr, pr1,…,prn) holds 3. ErwΛ ((pr, ?, b1,…,bn), (pr, ?, b1’,…,bn)), if it holds for an i that ErwΛ(bi,bi’) and bj = bj’ for all j ≠ i. Now the pair AΛ = (SΛ, TΛ) is our and-tree-based search model, where • SΛ ⊆ Atree and • TΛ = {(s1,s2) | s1,s2 ∈ SΛ and ErwΛ(s1,s2)}SEARCH CONTROLSfBoundOur main search control will be our fBound . A smaller value of fBound will determine whichpath will have a greater probability of providing an optimal solution, hence will beexamined first.Recall that pr = (x1,…,xi,…,xn) and pr ∈ Prob. Assuming that x1,…,xi ∈ TA and xi+ 1=…= xn = ⊥We define fBound as follows:fBound (x1,…,xi ) is calculated using Eval(x1,…,xi) where xa ∈ TA, and for each ⊥(unassigned labs) we will assume an optimal assignment of 1.fBound (x1,…,xi ) = Eval(x1,…,xi) + Eval*(xi+1,…,xn)From the above statement, we see that fBound computes the best possible values of aparticular assignment by making use of the function Eval. The evaluation function Evalprovides a measure of how well an assignment meets the soft constraints. To this measureof the partial solution vector we add the sum of the values of ⊥ (given by Eval*). 10
    • fleafAssume that MinSol is ourThe fleaf function allows us to determine which leaf is to be processed next. In order forfleaf to process a leaf, it must meet either one of the following conditions: • If MinSol < fBound(pr), set the sol-entry to ‘yes’ to close the leaf as the leaf does not prove optimal. • If Constr(pr) = false, set the sol-entry to ‘yes’ as the solution fails to satisfy the constraints. • If fBound(pr) ≤ MinSol, then the value of the leaf falls within the bounds, and we look at fTrans(pr) for the next possible transition.ftieIf fBound obtains the same value for two separate search states, then ftie will select the left-most transition by default.fTransWhen a leaf requires a transition, fTrans will determine which branch to take by comparingfBound and selecting the path with the smaller fBound value. The transitions will continueuntil all the leaves have been closed.HARD CONSTRAINTSThe following hard constraints will be handled by our system: • Each course ci has to be assigned exactly labscoursei TAs. • A TA cannot be assigned two labs taking place at the same time. • A TA cannot be assigned a lab that takes place at a time (s)he has a lecture. To check this, for each TA tai we will be given a list busy(tai) that lists the times the TA cannot teach. • A TA cannot be assigned more labs than his/her contracted capacity. • TAs with bad earlier evaluations for a course should not be assigned labs of this course again. To check this, for each TA tai we will be given an exception list except(tai) that lists the courses this TA is not allowed to teach anymore. Note that this could also be formulated as a weak constraint. 11
    • • If the TA coordinator provides a certain partial assignment partassign, i.e. partassign: Courses -> (TA+$)* where $ as assignment indicates that we still have to find a TA for the course, than our solution assign is not allowed to contradict partassign (i.e. the non-$ assignments).For each hard constraint, we assume that the function Constr(pr) = true (where pr =x1,…,xn) if and only if all the hard constraints have been satisfied.SOFT CONSTRAINTSThe following are the system’s weak or soft constraints: • A TA should be assigned the labs (s)he prefers (as indicated by him/her in a preference matrix). • Ideally, a TA should be assigned to labs for one course only (so that (s)he does not have to prepare for several courses). • Labs in a course should be assigned the TAs the instructor(s) prefer for this course (as indicated by a lab preference list that is compiled for each course). • The TA coordinator wants to try to arrange a TAs schedule so that his/her labs are at convenient times for him/her. He wants to avoid cases in which a TA has on one day a lab at 8:00 and a lab at 17:00. • TAs should be assigned labs to courses they have taken themselves with good results (or have taken similar courses with good results). Note that this could also be formulated as hard constraint. For each soft constraint, we assume that the function Eval(pr) (where pr = x1,…,xn) provides a value that indicates how well a particular assignment satisfies these weak constraints. 12
    • AND-TREE BASED SEARCH EXAMPLEProblem: Schedule 2 TA’s for 2 courses with a combined 4 labs. TA Availability Captai Courses Eval Taken B 11,12,13 3 231 2 233 1 J 11,12 2 231 1 233 2 Table 1: TA InformationFor this example, we have the following information:TA = {J, B}Courses = {231, 233}Labcourse c1 (231) = 3Times: 11, 12, 13Labcourse c2 (233) = 1Times: 12Assume we have the following unassigned labs that require a TA assignment:231(Lab 1), 231(Lab 2), 231(Lab 3), 233(Lab 1)Using our vector of unassigned labs (x1,…,,xi,…xn ), where each position i represents thecourse and lab section as shown above. Placing an element from the set TA will indicatean assignment of the TA to the lab indicated by i.Using the Eval(assign) function as defined in the assignment specifications, we candetermine how well an assignment fulfills certain soft constraints.For the purpose of this example, one important assumption needs to be made, and that isthat Eval(assign) is either a 1 or a 2, where 1 = high preference, 2 = low preference.What this means is that in choosing branches of the AND-Tree, the control will select thebranch that has the lower Eval(assign) value, as this is the branch that has a greaterprobability of leading to the more optimal solution.The AND-tree begins by considering all possible TAs that can teach a particular lab, andthe search control then chooses the one with the lowest Eval value (which becomes ourbound). This process continues until a solution is found. After the solution is found, theAND-tree then builds all other parts of the tree (i.e. finds all other possible solutions) and 13
    • compares it to the solution that was found. If no other solution has a lower bound value,then we have found our optimal solution. In the AND-tree drawings below, this isexactly what happens. We begin at node 1, where the search control is faced with twopossibilities to choose from. Node 3 has a lower bound value than node 2, therefore thesearch control chooses node 3 as its next node (figure 2). This process (of choosing thenode with the lower bound) continues until a solution is found. In our example, thissolution ends up being node 22. At this point, the MinSol value is set to the bound valueof this node, which is 5. At this point, the rest of the tree is constructed, and each of thebound values for the other possible solutions is compared to MinSol. If they are greaterthan MinSol, they are closed for good and no longer considered. This process continuesuntil only one branch remains, and this is our optimal solution. In our case, the optimalsolution is the first solution our search control finds, as its bound value (5) is the lowestof any possible solution. Therefore the TA assignment for our example is (B,B,J,J). Figure 1: Left Branch of the AND-tree 14
    • Figure 2: Right Branch of AND-tree 15