Optimization for Business Problems

From Bitnami MediaWiki
Jump to navigation Jump to search

The first page is here

Module 1: The Big Picture[edit]

What is OR?[edit]

  • developed by British during WWII to solve logistics problems and operational planning. OR
  • by the 1950s, "management science" replaced OR to avoid the connotation of military operations
  • OR uses: optimization, statistics, probability theory, simulation and decision analysis
  • LP is the best know mathematical optimization technique
  • Dantzig (1953) formulated the simplex method; CPLEX uses a revised version of simplex algorithm
  • Most OR today done to help organizations improve their business

What is Optimization?[edit]

  • optimization model includes: an objective, decision variables, constraints
  • purpose is to find values of the decision variables, satisfy constraints and optimize the objective function (e.g., maximize profits or minimize costs/losses)
  • using model interactively allows users to judge impact of data changes & analyze trade-offs between conflicting goals and constraints
  • inputs: demand, resource availability, costs, yields, recipes, operational constraints, customer preferences, business goals
  • inputs used to construct optimization models, solved by optimization engines that generate output
  • outputs: minimize costs, maximize yields, optimal activity timing, optimal resource assignment
  • 2 IBM ILOG products: 1) mathematical programming (linear, integer, mixed-integer, quadratic, MI quadratic) and 2) constraint programming (detailed scheduling problems, combinatorial optimization problems that can't be linearized).

Optimization Model[edit]

  • begins with scope definition, then identify objectives, decision variables, constraints
  • gather data to populate model, create and test a prototype with small data set. Then create a complete instance and test
  • the objective function is a mathematical representation of the business objectives or goals to be achieved. Always entails "minimize" or "maximize"
  • bus objectives: maximize profit, minimize cost, minimize tardiness, maximize cust service
  • decision variables: how much to produce, how many people to hire, location of a warehouse
  • decision variables have a domain (range of possible values) and upper and lower bounds (infinite bounds okay)
  • constraints define relationships among decision variables. E.g.: amount produced should be less than capacity; people hired need a minimum set of skills; total construction cost should be below budget
  • hard or soft: hard constraints are inviolable, e.g., production capacity when no additional is available. Soft constraints can be violated under certain conditions and usually involve adding a penalty to the objective to minimize the constraint violation
  • IBM ILOG CPLEX optimizer is a solver engine for MP problems, including Simplex, Barrier, and Mixed-Integer algorithms. Also offers the CP optimizer for CP problems

Module 2: Linear Programming[edit]

Intro to LP[edit]

  • LP deals with max/minimization of a linear objective function, subject to linear constraints where all the decision variables are continuous. Everything is linear (no square roots, squares, logs, combined terms, etc.)
  • constraints are expressed as equalities or inequalities with linear expressions on both LHS and RHS
  • decision variables all take values from [math]\displaystyle{ \mathbb{R} }[/math]; they cannot be restricted such that they are discontinuous
  • the canonical from is
[math]\displaystyle{ \begin{align} & \text{Find a vector} && \mathbf{x} \\ & \text{that maximizes} && \mathbf{c}^T \mathbf{x}\\ & \text{subject to} && A \mathbf{x} \leq \mathbf{b} \\ & \text{and} && \mathbf{x} \ge \mathbf{0}. \end{align} }[/math]
  • where c and b are vectors containing the objective coefficients and RHS values of the constraints, A is the matrix of constraint coefficients and x is the vector of decision variables.
  • restrictions:
    • objective function must be linear;
    • the constraints must be linear;
    • inequalities must be [math]\displaystyle{ \geq }[/math] or [math]\displaystyle{ \leq }[/math], strict inequalities aren't allowed;
    • decision variables must be continuous, not discrete

A Production Problem P1[edit]

[math]\displaystyle{ \begin{matrix} & \text{Desk} & \text{Cell} \\ \text{assembly (max 400hr)} & 12 & 24 \\ \text{painting (max 490hr)} & 30 & 24 \\ \text{profit/unit} & 12 & 20 \end{matrix} }[/math]

  • decision variables: number of desk phones and cell phones to be produced
  • objective: maximize profit ($12/desk phone, $20/cell phone)
  • constraints:
    • desk + cell output [math]\displaystyle{ \geq }[/math] 100 units
    • desk + cell assembly time [math]\displaystyle{ \leq }[/math] 400 hours
    • desk + cell painting time [math]\displaystyle{ \leq }[/math] 490 hours
  • The full model
    • desk_prod [math]\displaystyle{ \geq }[/math] 100
    • cell_prod [math]\displaystyle{ \geq }[/math] 100
    • assembly_time_limit: 0.2*desk_prod + 0.4*cell_prod [math]\displaystyle{ \leq }[/math] 400
    • painting_time_limit: 0.5*desk_prod + 0.4*cell_prod [math]\displaystyle{ \leq }[/math] 490
    • desk_prod, cell_prod [math]\displaystyle{ \in\mathbb{R} }[/math]
    • subject to maximizing: 12*desk_prod + 20*cell_prod

A Production Problem P2[edit]

  • The region delimited by the constraints define a feasible region
  • Iso-profit/iso-cost lines are parallel to the tangent of the optimum
  • Optimal solution always lies along an extreme point of the feasible region--either a vertex or an edge
  • CPLEX reports the first optimal solution found

A Production Problem P3[edit]

  • Solution to the above is desk=300, cell=850.
  • Binding constraint: if the constraint becomes an equality when the solution values are substituted (i.e., the constraint is at its limit: 0.2(300) + 0.4(850) = 400.)
  • Non-binding constraint: LHS [math]\displaystyle{ \neq }[/math] RHS given the solution values. E.g.: total production for each phone type is non-binding because 300 [math]\displaystyle{ \neq }[/math] 100 (desk) and 850 [math]\displaystyle{ \neq }[/math] 100 (cell).
  • Model is infeasible when no constraint-satisfying solution exists. This may be because: 1) the formulation is wrong, 2) the data are wrong, or 3) there's a real-world conflict among objectives in the system being modeled.
  • CPLEX provides tools to help identify potential causes of infeasibility.
  • Correcting an infeasible model entails knowledge of the real-world situation.
  • CPLEX might suggest relaxing one or more constraints. E.g., 0.2*desk + 0.4*cell [math]\displaystyle{ \leq }[/math] 400 might be relaxed to 440, representing a relaxation of the RHS of the equation.
  • A soft constraint can be used to relax the model. A soft constraint maybe violated, a hard constraint may NOT be violated.
  • Converting hard constraints to soft constraints is one way to relax assumptions. E.g.,
    • add an overtime term: 0.2*desk + 0.4*cell [math]\displaystyle{ \leq }[/math] 400 + overtime, subject to
    • a hard limit to the overtime term: overtime [math]\displaystyle{ \leq }[/math] 40, and an additional cost constraint
    • maximize: 12*desk + 20*cell - 2*overtime
  • a variable is unbounded when one or both of its bounds is infinite.
  • an unbounded model exists when its objective value can be increased/decreased arbitrarily (usually a sign of mispecification); this usually implies that an important constraint is either missing or insufficiently restrictive

Algorithms for Solving LP, P1[edit]

  • Simplex method developed by George Dantzig in 1947. Iterative method that starts with an initial feasible solution and continues until it stops. It starts at a vertex, and proceeds vertex-by-vertex until reaching an optimum
  • Revised in 1953 by Danzig and W. Orchard-Hays
  • CPLEX studio uses the revised method
  • Duality: every LP max(min)imization has a dual min(max)imization problem
  • Each constraint (x) has an associated dual variable (y); any feasible solution to the dual problem is an upper bound to the primal problem.. Any feasible solution to the primal problem is a lower bound to the dual problem
  • The optimal objective of the dual and primal are equivalent where these bounds meet
  • The dual can help solve difficult primal problems by providing a bound that, best case, equals the optimal solution of the primal
  • The values of the dual (or shadow) prices are reported by CPLEX
  • For each constraint in the primal problem its dual price indicates how much the dual objective will change with a unit change in the RHS of the constraint. The dual price of a non-binding constraint is always zero. The dual price of a binding constraint can be used to determined whether more of, e.g., a resource should be increased.
  • The dual simplex algorithm uses the dual to try and find an optimal solution, without regard to feasibility. It then moves, gradually decreasing the infeasibility while maintaining optimality until it reaches a feasible solution

Algorithms for Solving LP, P2[edit]

  • A solution at a vertex is a basic solution. The simplex algorithm involves taking a subset of the variables--the non-basic variables--to zero at each iteration. The remaining variables are the basic variables.
  • The reduced cost of a variable indicates how much the objective will change for a unit change in the variable value
  • Under the usual form of [math]\displaystyle{ \min c^Tx, Ax=b, x\geq 0 }[/math], the reduced costs are [math]\displaystyle{ c - y^TA }[/math], where y is the vector of dual variables. The basic solution is optimal if [math]\displaystyle{ c - y^TA \geq 0 }[/math].
  • Multiple solutions exist when one or more non-basic variables with a zero reduced cost exist in an optimal solution.
  • CPLEX can determine the values of reduced costs
  • The difference between the LHS and RHS of a constraint is the slack value for that constraint. For a binding constraint, the slack value is zero by definition. Non-binding constraints always have a slack value.
  • Degeneracy occurs when the algorithm cycles between non-optimal solutions. CPLEX's solvers perturb the variable bounds to avoid this.
  • The Barrier Method starts inside the feasible region and moves through it to find the optimal solution, using a predictor-corrector algorithm.

Creating a Notebook in IBM Cloud Pak For Data as a Service[edit]

  • Login at https://dataplatform.cloud.ibm.com
  • Create an empty project on the Watson Studio homepage (-->Create a Project)
  • Click "Add to Project" and choose Notebook as the asset type
  • Click From URL in the new notebook window (or set a blank one or import one)
  • Enter a name for the notebook in the Name field
  • Click Create


Module 3: Network Models[edit]

Intro to Networks[edit]

  • Several types of OR problems involve networks: distribution (transportation networks), assignments (tasks and workers), planning (critical path analysis)
  • Many are special LP problems for which specialized algorithms exist
  • Any network comprises two types of object: nodes and edges. An edge connects two nodes. An edge can be directed, if an edge from i to j is different from an edge from j to i. A sequence of edges connecting two nodes is called a chain. When the edges are directed such that the chain can be completely traversed it is called a path.

Transportation Problem[edit]

  • Involves a set of supply nodes and a set of demand nodes. Objective is to minimize cost from the supply nodes to demand nodes without exceeding the supplier's capacity.
  • Supply and demand are indicated on their respective nodes and transportation costs are represented by the edges.
  • There is one variable, [math]\displaystyle{ x_{i,j} }[/math], which represents the quantity transported from supply node i to demand node j. The objective is to minimize the total transport cost across all edges.
  • The constraints are flow conservation constraints. The domain for shipments on the allowable (connected) edges is set to be [math]\displaystyle{ \geq 0 }[/math]; the "disallowed" (unconnected) edges are set to zero.
  • If all supply and demand capacities are integers, the decision variables will take on integer values as well.

Transshipment Problem[edit]

  • Similar to transportation problem, but with intermediate nodes
  • It's possible to write a transshipment problem as a transportation problem, which allows CPLEX to exploit transportation-specific algorithms

Assigment Problem[edit]

  • Assign one set of items to another while optimizing an objective, e.g., minimizing hiring costs
  • First constraint group specifies each job is filled by exactly one worker; the second group specifies that each worker has exactly one job.
  • Each node and each demand capacity are set to one. This is (another) special case of the transportation problem.
  • Integrality property: if all capacity and demand quantities are integers, the variables will take integer values.

Shortest Path Problem[edit]

  • Finding the shortest path through a network, like the minimum travel time between 2 cities
  • Special case of the transshipment problem, where there is exactly one supply node and one demand node, both equal to one.
  • Objective is to minimize total travel time. Constraints are flow conservation constraints

Critical Path Analysis[edit]

  • Used in project planning to determine which activities derail the overall project
  • The critical path is the longest path in the network; it represents the minimum completion time for the project
  • Kitchen remodeling: plumbing and elec can be done in tandem; others, sink installation, depend on others (plumbing complete)
  • Certain nodes may be "dummy" tasks: they have no minimum time associated with them but represent precedence in the sequence of completing a path

Lab 2[edit]

  • Add to project+ and select Notebook
  • Click From URL. Go to https://github.com/IBMDecisionOptimization/tutorials
  • Browse to jupyter--> Beyond_Linear_Programming.ipynb
  • Click Raw and copy the URL
  • Return to project and enter a name in the Name field
  • Paste the notebook URL in Notebook URL; click Create
Actual Workflow
  • IBM CloudPak --> select project --> New Asset (top right) --> Jupyter Notebook Editor--> From URL--> paste above link