Maximizing Profit, Minimizing Time, Optimizing Working Conditions: Modeling your Business to have it...

Preview:

Citation preview

Maximizing Profit, Minimizing Time, Optimizing Working Conditions:

Modeling your Business to have it all!

Yves Lucet

Professor Computer Science

UBC Okanagan

Software Developmentvs.

Optimization• Discuss feature/pb with client, obtain input data for

acceptance tests• Implement prototype feature/model using off-the-

shelf components/solvers• Pass unit tests• Pass given acceptance tests• Could you add that? / Your solution is good… but• get better understanding of feature/pb. • iterate till client is happy or budget is depleted

What is the most critical in software development?

A. Understanding the requirements

B. Efficiency of the software: fastest using least resources

C. Fastest development

D. Cheapest software

E. None of the above

Overview

1. Simple modeling

2. Recognizing easy vs. hard problems

3. Opportunities

All images are copyright of their respective owners and used under the fair use clause.

When to optimize

• Problem is too complex: modeling it helps understanding it like writing requirements help communicating with the client.

• Problem is too large to solve on paper.

• Problem is naturally an optimization pb.

• A small improvement toward a solution gives huge savings e.g. 1% improvement gives millions of dollar in savings.

When NOT to optimize

• Problem is small: manual solution works fine

• Greedy algorithm gives the best solution already

• Problem would require unreasonable effort to make a significant difference with the current approach

• Problem is too hard to be solved other than by heuristic

Operations Research

Operations research (OR) is an interdisciplinary branch of applied mathematics and formal science that uses methods such as mathematical modeling, statistics, and algorithms to arrive at optimal or near optimal solutions to complex problems.

Faster than sampling

Evolution of an optimization problem

1. Manual approach or semi-automated: • draw graphs, • use experience

2. Standard optimization: black box function with off the shelves solver

3. Customized solver

Example: Team selection

• Objective: create the “best” teams• Solution/Variables: assignments of people

into teams• Constraints:

– black list, – spread skills among teams, – team size,– compatible schedule, people wish to tackle

specific projects, etc.

Example: Team selection

Variables: T: t x s boolean matrixTi,j = 1 if programmer j belongs to team i

1 0 0 0 1 1 0

0 0 0 1 0 0 1

0 1 1 0 0 0 0

T =

A programmer can only be assigned to one team: 1, i

jiT

Example: Team selection

Black list: B: s x s boolean matrixBi,j = 1 if programmers i doesn’t want to work with programmer j

0 1 0 0

0 0 1 1

1 0 0 0

0 1 1 0

B =

Many 1 in column j: nobody wants to work with jMany 1 in row i: i does not want to work with anybody

Example: Team selection

Skill: C: n x s matrixCi,j = rating of programmer j in skill i: 0 none, 3 average, 5 expert

0 3 0 0

0 2 4 1

0 4 0 0

5 1 1 0

C =

Project k requires at least 3 in skill i: add or max on peopleassigned to project k

Example: Team selection

Objective:

• Soft constraints: penalize

• Hard constraints: reject

...min,

,,,,

ikijji

jjkik BBTT

0,

,,,,

ikijji

jjkik BBTT

What is the key idea illustrated in the team building model?

A. Using matrices is more efficient than using lists

B. Penalizing unwanted choices by moving it from constraints to objective

C. Any constraint can be modeled using matrices and equalities/inequalities

D. All of the above

E. None of the above

Modeling: Understanding your business

• Simulators

Objective

• Maximize profit

• Minimize cost

• Maximize use of resources: – space, – material, – time: schedule

• working conditions: create the most efficient teams

(Decision) Variables

• What is a solution?– schedule– resource allocation– amount to be shipped– amount to buy/sell

Constraints

• Relations between the variables

• Filter unwanted possibilities

Optimization

min f(x) subject to g(x) <= 0 and

h(x) = 0

Variable: x

Objective: f

Constraints: inequality: g

equality: h

Are you familiar with…

A. programming

B. Some modeling (PERT charts, graphs…)

C. linear programming

D. using optimization solvers (Excel, CPLEX, Matlab, Scilab…)

E. All of the above

Modeling in Excel

• Solver add-in

• Demo: toy problem:min x-y subject to x >=0, y>=0, x+y<=1

Trip planning

Trip Planning

Scheduling

• xi: start time of task i• end time: xi + duration of task i• constraints:

– task 1 must be finished before task 2 begins– start time of 2 is after start time of 1– x2 >= x1 + 4

• x20: artificial task of duration 0: end of project; requires all previous tasks to be finished. Scheduling

Blending: What is the best mix?Ferdinand Feed Company receives four raw grains from which it blends its dry pet food the 8-ounce=0.5 lb mixture at minimum cost to meet the minimum daily requirements of 6 units of vitamin C, 5 units of protein, and 5 units of iron.

Cost and grain properties

Vitamin C Protein Iron

Grain Units/lb Units/lb Units/lb Cost/lb

1 9 12 0 $.75

2 16 10 14 $.90

3 8 10 15 $.80

4 10 8 7 $.70

Blending

n-Queen

n-Queen Excel

n-Queen Scilab

Earth moving problem• Given a road design (vertical & horizontal),

move the earth to cut hills, fill holes while minimizing moving costs

• Linear Programming pb: EASY!

Earth moving problem (cont): Blocking sections

• We forgot to tell you… Some moves cannot happen till a hill is cut or hole filled since the grade is too steep

• Some moves require a bridge before they can be made

• Mixed Integer Programming pb: HARD

Classifying problems

1. real/continuous vs. integer/discrete (MIP/MINLP)

2. convex vs. nonconvex

3. linear (LP) vs. nonlinear (NLP)

4. smooth vs. nonsmooth

• Others: quadratic, network flow, etc.

What makes a problem hard to solve

• The mathematical relationships between the objective and constraints, and the decision variables

• The size of the model (number of variables and constraints) and its sparsity

• The use of integer variables - memory and solution time may rise exponentially as you add more integer variables

Easy vs. Hard

Hard = NP hard. Easy = Polynomial• Easy: Linear Programming, Convex• Hard: Discrete, nonconvex global optimization,

nonconvex quadratic programming

How about smooth?• Smooth: fast converging algorithm• Nonsmooth: slower convergence… sometimes

What makes a problem hard to solve?

A. Mathematical relation between variables and constraints

B. Size

C. Presence of integer variables

D. B and C but not A

E. A, B and C

How do they solve it?

• real value: – Linear: Simplex (Active Set), Interior Point (Newton)– Nonlinear: Newton (and variants)– Direct Search methods: Nelder-Mead…– Heuristics: Simulated Annealing, genetic algs…

• integer value: – Relax to get a bound– Build associated problem (dual)– Branch and Bound

Relaxing:  to make less severe or stringent

http://www.danaquillman.com/

Smooth Problems: Amazing!

Large Scale: Radiotherapy

Existing Software

“Free”– lp_solve– SCIP (research only)– Scilab– Galahad (Lancelot…)

Commercial– Excel– CPLEX, ILOG (IBM)– GAMS– Matlab– LINGO– BARON– AIMMS– XPRESS-MP

http://wiki.mcs.anl.gov/NEOS/index.php/Optimization_Software_Guide

http://scip.zib.de/

Performance

Most used algorithms

The most used algorithms are:

A. Simplex for linear programming

B. Nelder-Mead (sampling method)

C. Newton and variant

D. Simulated Annealing

E. Don’t know any of these algorithms so can’t answer

1. Model small/easy problem in Excel

2. Ask experienced people for tips i.e. understand your solution: global, local, sensitivity, etc.

3. Contact researchers: They are always looking for problems to solve!

Keep in Mind: the best solution is the one that works for you!

Opportunities & Funding

• Graduate students support: MITACS Accelerate program

• NSERC Student support: – Industrial Undergraduate Student Research Awards

(USRA)– Industrial Postgraduate Scholarships (IPS)– Industrial R&D Fellowships (IRDF)– Collaborative Research and Development (CRD)

Grants

• Industry/University contracts

http://www.nserc-crsng.gc.ca/Partners-Partenaires/IndPrograms-IndProgrammes_eng.asp

http://www.acceleratecanada.ca/

http://www.mitacs.math.ca

What would you do if you suspect your problem can be solved with

optimization tools?A. Hand it to someone else i.e. run awayB. Call me to discuss itC. Write an ad hoc algorithm that seems to workD. Write a short specification, attempt to create a

model and use a solver; ask for advice if stucks.

E. Create an optimization model, use an off-the-shelf solver, and argue vehemently whatever output it gives is the best solution

Contact Information

• Yves Lucet, Computer Science,OCANA (Optimization Convex Analysis and Nonsmooth Analysis) research group

• OCANA Research group: http://people.ok.ubc.ca/ylucet/

• Patricia Lasserre, • Yves Lucet,• Shawn Wang.

• Heinz Bauschke, • Yong Gao, • Donovan Hare, • Warren Hare,

Recommended