job scheduling and chronobot

32
Job Scheduling and Chronobot

Upload: yetta-benjamin

Post on 03-Jan-2016

33 views

Category:

Documents


0 download

DESCRIPTION

Job Scheduling and Chronobot. Outline. What are Chronobots? Job Scheduling Problems Examples Reductions * Hill Climbing * Bin Packing Efficiency Term Project. What are Chronobots?. The chronobot is a device for storing and borrowing time in addition to knowledge. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Job Scheduling and Chronobot

Job Scheduling and Chronobot

Page 2: Job Scheduling and Chronobot

Outline

• What are Chronobots?• Job Scheduling Problems• Examples• Reductions• * Hill Climbing• * Bin Packing• Efficiency• Term Project

Page 3: Job Scheduling and Chronobot

What are Chronobots?

• The chronobot is a device for storing and borrowing time in addition to knowledge.

• Time can be exchanged or sold for money.

• Logical extension of Blog, which only exchanges knowledge.

• Exchange of individualized time.

Page 4: Job Scheduling and Chronobot

Formal Model and Characteristics of Chronobot

• Identify time/knowledge for exchange.• Search for exchange partner(s).• Bidding and negotiations.• Manage the exchange of time/knowledge.• Evaluate the results.

• Time/Knowledge Manager: manages not only one’s own time but also other people’s time through exchange. Perform information fusion to produce knowledge from multiple users.

• E-learning and distance education; offers a virtual classroom that combines the features of chat room, white board, and multimedia display.4

Page 5: Job Scheduling and Chronobot

Example of Job Scheduling Problem

• People who wish to contribute their time then place bids by submitting timetables indicating the time they may contribute.

• The system then determines the best allocation of time from these bidders.

Page 6: Job Scheduling and Chronobot

Heuristics We Wish to Optimize

There are several heuristics one may wish to optimize for allocating from these bids, depending on the application.

• Minimize the number of bidders utilized.• Minimize the amount, in money or trade ratios,

that one will pay.• Maximize compatibilities and minimize time if

different persons can complete jobs in different amounts of time.

• Combination of these heuristics.

Page 7: Job Scheduling and Chronobot

Problem Constraints

Possible constraints in a job scheduling problem include:

• Travel time between assignments if certain people will be assigned more than one job consecutively.

• Some jobs require a specific time and place while other do not.

• Compatibility issues.

Page 8: Job Scheduling and Chronobot

Example of Job Scheduling Problem

• A person(s) who needs to borrow/buy time posts his workload schedule onto the system, describing the exact table of times he wishes to borrow/buy. See example.

Time Mon

Tue

Wed

Thu

Fri

9a-10a

10a-11a X X

11a-12p X X

12p-1p

1p-2p

2p-3p

Page 9: Job Scheduling and Chronobot

Example of Job Scheduling Problem

• Bidders who wish to contribute time can post similar time-tables. In the example to the right the match is shown in bold.

• Extensions to the problem may require other information to be posted:

• If there are multiple people wanting to buy/borrow time, one may be interested in the transition time between jobs, such as the commute time between geological locations.

• Buyers may be more flexible if their jobs can be completed at more than one possible time interval.

• We may wish to assign a compatible score or a cost between each seller and each job, which can be included in part or whole in our scheduling heuristic.

M T W T F

9

10

11 X X

12 X X

1p

2p

M T W T F

9 X X

10 X X

11

12

1p

2p

Page 10: Job Scheduling and Chronobot

Brute-Force Algorithm

• A brute-force algorithm for job scheduling iteratively attempts to assigns each time slot that the buyer(s) wish to buy (there are 4 in this example) to each potential seller and checks for consistency.

• Runs in complexity O(S^T) where S is the number of sellers and T is the amount of time traded.

Page 11: Job Scheduling and Chronobot

Hill Climbing

• Hill climbing is an optimization technique which belongs to the family of Local search (optimization). It attempts to maximize (or minimize) a heuristic function f(x) for discrete states x.

• States are vertices in a graph where edges encode nearness or similarity.

• Simple hill climbing may find local maximums.• Ways to overcome this problem include

stochastic hill climbing, random walks, simulated annealing, and Ramdom-Restart hill climbing.

Page 12: Job Scheduling and Chronobot

Genetic Algorithm

• Computer simulation of a population of abstract representations of candidate solutions evolving toward better solutions.

• A typical genetic algorithm requires two things:• A genetic representation of the solution domain,

traditionally a binary string• A fitness function to evaluate the solution domain

• Usually starts from a population of randomly generated individuals and happens in generations.

• In each generations, the fitness of every individual is evaluated and stochastically selected to form a new population.

Page 13: Job Scheduling and Chronobot

Simulated Annealing

• Simulated Annealing addresses the issues of local maximums (minimums) by allowing for downhill (uphill) moves.

• Inspired by annealing in metallurgy, a technique involving heating and controlled cooling of a material to increase the size of its crystals and reduce their defects.

• Each step of the simulated annealing algorithm replaces the current solution by a random “nearby” solution, chosen with a probability that depends on the difference between the corresponding function values and a global parameter T (temperature).

Page 14: Job Scheduling and Chronobot

Job Scheduling and Genetic Algorithms

• In Job Scheduling, one can represent solutions as a string of sellers to indicate which seller will be covering each buyer-time period tuple.

• Fitness can be defined as the number of conflicts in each candidate solution, being zero for a correct solution.

Page 15: Job Scheduling and Chronobot

Relationships to Bin Packing Problem

Bin packing problem:• Given objects of different sizes• Given a bin size• Want to minimize the number of bins used to

pack these objects.

Common applications in Bin-Packing include• filling up containers• loading trucks with weight capacity• creating file backup in removable media

Page 16: Job Scheduling and Chronobot

Bin Packing Heuristics

Common Heuristics for Bin-Packing include:• Next fit: place in right-most bin, starting a new

bin if necessary (does not go back to old bins).• First fit: left-most bin that still has enough room.• Last fit: right-most bin that still has enough room,

starting a new bin if necessary.• Best fit: fullest bin that still has room.• Worst fit: emptiest bin that still has room.

Page 17: Job Scheduling and Chronobot

Bin Packing Example

• Suppose we have bins of capacity 10 and we wish to pack items of size 3, 6, 2, 1, 5, 7, 2, 4, 1, 9.

• The optimal solution uses 4 bins (3+2+5, 6+4, 1+7+2, 1+9).

Page 18: Job Scheduling and Chronobot

Bin Packing as a Job Scheduling Problem

• The Bin Packing problem can be thought as a special case of the Job Scheduling problem.

• The items to be packed are jobs requiring a fixed amount of time to be scheduled, where there are no time/geographical constraints.

• The bins are bidders, and all bidders can cover an fixed amount of time.

• There is no transition time between jobs.

Page 19: Job Scheduling and Chronobot

Next-Fit Heuristic• Next-fit has the advantage of allowing us

to finalize bins before we pack everything. This may be useful in some applications such as filling trucks for a delivery

Page 20: Job Scheduling and Chronobot

First-Fit Heuristic• First-Fit is an extension of Next Fit that

allows us to go back to old bins if they will fit. However, we lose the advantage of being able to finalize bins unless they are completely filled.

Page 21: Job Scheduling and Chronobot

Efficiency of Algorithms

• First Fit Decreasing strategy, operates by first sorting the items to be inserted in decreasing order by volume, and then inserting each item into the first bin in the list with sufficient remaining space.

• no more than 11/9 OPT + 1 bins (where OPT is the number of bins given by the optimal solution

• Sorting operation is time-expensive (O(n log n) on top of an O(n) algorithm), but without it one obtains a looser bound of 17/10 OPT + 2 bins.

Page 22: Job Scheduling and Chronobot

Tentative Term Project Plans• Heuristics for various different sets of Job Scheduling problems that

are restricted in some way.• Possible restrictions include:• * No transition time. This is a practical assumption in online jobs.• * Fixed transition time. This is practical when the transition times are

fairly small and close together, such as talking about jobs within the Pittsburgh area. In this case we can always use the worst-case transition time without too much sacrifice.

• * Eliminate compatibility issues (i.e. everybody can complete jobs in same amount of time for same amount of cost or trade ratios.) This is a more reasonable assumption when all the jobs are closely related or mostly involve labor rather than knowledge.

Page 23: Job Scheduling and Chronobot

Term Project

• Assumptions I made in job scheduling problem

• Constant transition time between tasks; this is a reasonable assumption when transition times are relatively small, such as tasks within Pittsburgh.

• Wish to minimize the number of sellers we use.

Page 24: Job Scheduling and Chronobot

Genetic Algorithms

• Computer simulation of a population of abstract representations of candidate solutions evolving toward better solutions.

• A typical genetic algorithm requires two things:

• A genetic representation of the solution domain, traditionally a binary string

• A fitness function to evaluate the solution domain

Page 25: Job Scheduling and Chronobot

Genetic Algorithms for Job Scheduling

• We represent solutions as a string of sellers who will cover each buyer/time tuple. These solutions can produce offspring by mutation , such as random changes to one or two numbers in the solution, or crossover, meaning a merging of two solution.

• The fitness function will need to measure two goals; how good is our solution to being a legitimate solution without any conflicts, and given it is a legitimate solution how good is it in terms of heuristics that we wish to maximize/minimize, such as the number of sellers used.

Page 26: Job Scheduling and Chronobot

Data Representation /* Number of time slots in the schedule */ public static int numTimeSlots;

/* The amount of time we need to transistion between different tasks */ public static int transistionTime;

/* Total number of buyers and sellers */ public static int numSellers; public static int numBuyers;

/* Array of sellers, each one being an array for their timetable */ public static boolean[][] Sellers;

/* Array of buyers, each one being an array for their timetable */ public static boolean[][] Buyers;

Page 27: Job Scheduling and Chronobot

Conflict checking /* Solutions are given as an array indicating the seller for each (buyer, time) tuple */ public static int numConflicts (int[][] BuyerTimes) { int count = 0;

for (int B=0; B<numBuyers; B++) {

for (int T=0; T<numTimeSlots; T++) {

int S = BuyerTimes[B][T];

if (S==-1) { if (Buyers[B][T]) count++; /* No sellers covering this (buyer, time) tuple */ continue; }

/* Seller not available at this time */ if (Sellers[S][T]==false) { count++; }

/* Check for conflicts within the transition time interval */ for (int i=0; ((i<transistionTime) && ((T+i)<numTimeSlots)); i++) for (int B2=0; B2<numBuyers; B2++) { if (B==B2) continue; /* Same task; no need to check conflicts */

int S2 = BuyerTimes[B2][T+i];

if (S2==-1) continue; /* No conflict; no task at conflicting time */

if (S2==S) count++; /* Conflict of seller S with tasks from buyers B and B2 */ } } }

Page 28: Job Scheduling and Chronobot

Heuristic Functions• Return a negative integer if there is a conflict to indicate how many conflicts we have; otherwise return a non-negative integer to indicate

how good our solution is.

/* Heuristic function */ public static int score (int[][] BuyerTimes) { /* Return a low score if there are a lot of conflicts. */ int NC = numConflicts (BuyerTimes); if (NC > 0) return (-NC);

/* Return a high score if fewer sellers are used in the correct solution. */ boolean[] SellerUsed = new boolean[numSellers]; for (int i=0; i<numSellers; i++) SellerUsed[i]=false;

for (int B=0; B<numBuyers; B++) for (int T=0; T<numTimeSlots; T++) {

int S = BuyerTimes[B][T];

if (S!=-1) SellerUsed[S] = true; }

int count=0;

for (int i=0; i<numSellers; i++) if (SellerUsed[i]) count++;

/* The fewer the number of sellers used the higher the score should be */ return numSellers-count; }

Page 29: Job Scheduling and Chronobot

Genetic Algorithm• Mutation: Randomly change each entry with a probability of

1/(numBuyers*numTimeSlots). In other words, we change about one entry on the average case, but can, in theory, change all of the entries.

• By doing it this way we allow all solution nodes to be connected and reduce the potential for local maximums.

for (int i=0; i<numBuyers; i++) ░ for (int j=0; j<numTimeSlots; j++) { ░ ░ if (numBuyers*numTimeSlots*Math.random() < 1.0) Solution[i][j] = (int) ( numSellers * Math.random() ); ░ /* Randomly mutate some solution slots */ ░ } ░

Page 30: Job Scheduling and Chronobot

Testing

• The algorithm is tested by assigning numTimeSlots = 20, transistionTime = 2, and varying the number of buyers and sellers. The timetables are determined randomly with each slot being available with a probability of 1/2.

• The complexity is measured by the average number of iterations required to reach a non-conflicting solution.

Page 31: Job Scheduling and Chronobot

# Iterations to Reach Non-Conflicting Solution

Num Sellers

Num Buyers

20 40 60 80 100

5 1213 823 1536 2570 1252

10 25970 3588 2245 2176 3383

15 8131 4931 5573 3469

20 20155 11267 7720 11090

25 53668 18998 13871 13516

30 71860 21763 19890

Page 32: Job Scheduling and Chronobot

Observations

• It appears that for cases where the number of sellers is a lot greater than the number of buyers, the complexity of this algorithm is independent of the number of sellers.

• However, it appears to be difficult to decide when the algorithm has reached its local maximum as it often makes a jump after many iterations.