Using the OPTMODEL Procedure in SAS/OR to Solve Complex Problems. Rob Pratt, Senior R&D Manager, SAS/OR

Similar documents
Using the OPTMODEL Procedure in SAS/OR to Solve Complex Problems

SOLVING BUSINESS PROBLEMS WITH SAS ANALYTICS AND OPTMODEL

Using SAS/OR to Optimize Scheduling and Routing of Service Vehicles

SAS/OR 13.2 User s Guide. Mathematical Programming

The Decomposition Algorithm

The Mixed Integer Linear Programming Solver

SAS/OR 14.1 User s Guide: Mathematical Programming. The Mixed Integer Linear Programming Solver

SAS/OR 14.2 User s Guide. Network Optimization Algorithms

SAS/OR 15.1 User s Guide. Network Optimization Algorithms

SAS/OR 12.3 User s Guide. Network Optimization Algorithms

Introduction to Mathematical Programming IE406. Lecture 20. Dr. Ted Ralphs

Methods and Models for Combinatorial Optimization Exact methods for the Traveling Salesman Problem

15.082J and 6.855J. Lagrangian Relaxation 2 Algorithms Application to LPs

The SAS/OR s OPTMODEL Procedure :

Minimum Weight Constrained Forest Problems. Problem Definition

New Features in SAS/OR 13.1

Graphs and Network Flows IE411. Lecture 21. Dr. Ted Ralphs

A Computational Study of Conflict Graphs and Aggressive Cut Separation in Integer Programming

SAS/OR 14.2 User s Guide: Mathematical Programming. The OPTMILP Procedure

Graph Coloring Facets from a Constraint Programming Formulation

Financial Optimization ISE 347/447. Lecture 13. Dr. Ted Ralphs

Fundamentals of Integer Programming

Solving lexicographic multiobjective MIPs with Branch-Cut-Price

Notes for Lecture 24

Introduction to Mathematical Programming IE406. Lecture 16. Dr. Ted Ralphs

AMS /672: Graph Theory Homework Problems - Week V. Problems to be handed in on Wednesday, March 2: 6, 8, 9, 11, 12.

Graph and Digraph Glossary

SAS/OR 12.3 User s Guide. Mathematical Programming Examples

Outline. Column Generation: Cutting Stock A very applied method. Introduction to Column Generation. Given an LP problem

Theorem 2.9: nearest addition algorithm

Column Generation: Cutting Stock

3 INTEGER LINEAR PROGRAMMING

Introduction to Graph Theory

A Generic Separation Algorithm and Its Application to the Vehicle Routing Problem

6 Randomized rounding of semidefinite programs

Recursive column generation for the Tactical Berth Allocation Problem

Graphs: Introduction. Ali Shokoufandeh, Department of Computer Science, Drexel University

Branch-and-Cut and GRASP with Hybrid Local Search for the Multi-Level Capacitated Minimum Spanning Tree Problem

Integer Programming and Network Modeis

Chapter 1 Introduction to Optimization

Announcements Problem Set 5 is out (today)!

Paths. Path is a sequence of edges that begins at a vertex of a graph and travels from vertex to vertex along edges of the graph.

56:272 Integer Programming & Network Flows Final Exam -- December 16, 1997

SAS/OR 14.2 User s Guide: Mathematical Programming. The Quadratic Programming Solver

2. Modeling AEA 2018/2019. Based on Algorithm Engineering: Bridging the Gap Between Algorithm Theory and Practice - ch. 2

Chapter 10 Part 1: Reduction

Chapter 1 Introduction to Optimization

Construction of Minimum-Weight Spanners Mikkel Sigurd Martin Zachariasen

Branch-price-and-cut for vehicle routing. Guy Desaulniers

Analysis of Algorithms Prof. Karen Daniels

Mathematical and Algorithmic Foundations Linear Programming and Matchings

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2

Graph Coloring via Constraint Programming-based Column Generation

Combinatorial Optimization and Integer Linear Programming

Social-Network Graphs

Math Models of OR: The Simplex Algorithm: Practical Considerations

Exact Algorithms for NP-hard problems

Motivation for Heuristics

Approximation Algorithms

Copyright 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin Introduction to the Design & Analysis of Algorithms, 2 nd ed., Ch.

56:272 Integer Programming & Network Flows Final Examination -- December 14, 1998

Solutions for Operations Research Final Exam

Approximation Algorithms

3 No-Wait Job Shops with Variable Processing Times

Approximation Algorithms

UML CS Algorithms Qualifying Exam Fall, 2003 ALGORITHMS QUALIFYING EXAM

1 Unweighted Set Cover

SAS/OR 15.1 User s Guide. Local Search Optimization. The OPTLSO Procedure

The Linear Programming Solver

Contents. Introduction

Discrete Optimization with Decision Diagrams

The MIP-Solving-Framework SCIP

Combinatorial Optimization Lab No. 10 Traveling Salesman Problem

Dynamic programming. Trivial problems are solved first More complex solutions are composed from the simpler solutions already computed

Learning decomposable models with a bounded clique size

Column Generation Based Primal Heuristics

Foundations of Computing

The districting problem: applications and solving methods

Material handling and Transportation in Logistics. Paolo Detti Dipartimento di Ingegneria dell Informazione e Scienze Matematiche Università di Siena

An iteration of Branch and Bound One iteration of Branch and Bound consists of the following four steps: Some definitions. Branch and Bound.

Lagrangian Relaxation in CP

Computational Integer Programming. Lecture 12: Branch and Cut. Dr. Ted Ralphs

This matrix is not TU since the submatrix shown below has determinant of

Integer Programming Theory

Algorithm Design and Analysis

Traveling Salesperson Problem (TSP)

Column Generation Method for an Agent Scheduling Problem

Towards Efficient Higher-Order Semidefinite Relaxations for Max-Cut

lpsymphony - Integer Linear Programming in R

Decision Problems. Observation: Many polynomial algorithms. Questions: Can we solve all problems in polynomial time? Answer: No, absolutely not.

6. Lecture notes on matroid intersection

22 Elementary Graph Algorithms. There are two standard ways to represent a

On Covering a Graph Optimally with Induced Subgraphs

Rigidity, connectivity and graph decompositions

Combinatorial Optimization

Lecture 18. Questions? Monday, February 20 CS 430 Artificial Intelligence - Lecture 18 1

Linear Programming with Bounds

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Computational Discrete Mathematics

Two-stage column generation

Transcription:

Using the OPTMODEL Procedure in SAS/OR to Solve Complex Problems Rob Pratt, Senior R&D Manager, SAS/OR

Outline 1 Recent Features in PROC OPTMODEL 2 Graph Partitioning with Connectivity Constraints 2 / 36

SUBMIT Block Recent Features in PROC OPTMODEL Access the full SAS system without exiting OPTMODEL Build novel dynamic algorithms using statistics, matrix manipulation, visualization, interaction, etc. Syntax: proc optmodel;... submit [arguments] [/ options]; [arbitrary SAS code] endsubmit;... quit; 3 / 36

Network Algorithms Recent Features in PROC OPTMODEL PROC OPTNET: specialized procedure PROC OPTMODEL access using: I SUBMIT block I SOLVE WITH NETWORK (new in SAS/OR 13.1) Connected components Biconnected components and articulation points Maximal cliques Cycles Transitive closure Linear assignment problem Shortest path problem Minimum-cost network flow problem Minimum spanning tree problem Minimum cut problem Traveling salesman problem 4 / 36

Recent Features in PROC OPTMODEL Constraint Programming Solver PROC CLP: specialized procedure PROC OPTMODEL access using: I SUBMIT block I SOLVE WITH CLP (new in SAS/OR 13.2) Supported features and predicates I I I I I I I I Multiple solutions Strict inequalities (<, >) and disequality (6D) ALLDIFF ELEMENT GCC LEXICO PACK REIFY 5 / 36

COFOR Loop Recent Features in PROC OPTMODEL Uses multiple threads to execute SOLVE statements in parallel across iterations of loop Syntax for serial FOR loop: for {i in ISET} do;... solve...;... end; Syntax for parallel COFOR loop: cofor {i in ISET} do;... solve...;... end; 6 / 36

Problem Description Given undirected graph, node weights, positive integer k, target t 2 Œ`; u Partition node set into k subsets, each with total weight within Œ`; u Usual objective: minimize sum of edge weights between parts of partition Our objective: find most balanced partition I Minimize total absolute deviation of subset weight from target (L 1 norm) I Minimize maximum absolute deviation of subset weight from target (L 1 norm) Connectivity constraints: each of the k resulting induced subgraphs must be connected 7 / 36

Motivation Graph Partitioning with Connectivity Constraints Dennis E. Shasha, Doctor Ecco s Cyberpuzzles (2002) I Political districting Advanced Analytics and Optimization Services consulting engagement I Assigning service workers to customer regions INFORMS OR Exchange posting (Jan. 2013) www.or-exchange.com/questions/7248/graph-partitioning-with-connectivity-constraints I Forestry 8 / 36

Map from Shasha (2002) 9 / 36

Map Represented as Graph 10 / 36

Node Weights (Populations) 11 / 36

Feasible Solution for 14 Clusters, Bounds 12000 100 12 / 36

Solution Approaches Compact MILP formulation with IsCapital[i] binary variables and nonnegative flow variables Row generation, dynamically excluding disconnected subsets Column generation, dynamically generating connected subsets Column generation, statically generating all possible connected subsets 13 / 36

Solution Approaches Compact MILP formulation with IsCapital[i] binary variables and nonnegative flow variables Row generation, dynamically excluding disconnected subsets Column generation, dynamically generating connected subsets Column generation, statically generating all possible connected subsets 13 / 36

OPTMODEL Code: MILP Solver Master MILP problem: Given all feasible subsets, solve cardinality constrained set partitioning problem 1 /* master problem: partition nodes into connected subsets, 2 minimizing deviation from target */ 3 /* UseSubset[s] = 1 if subset s is used, 0 otherwise */ 4 var UseSubset {SUBSETS} binary; 5 6 /* L_1 norm */ 7 num subset_population {s in SUBSETS} = sum {i in NODES_s[s]} p[i]; 8 num subset_deviation {s in SUBSETS} = abs(subset_population[s] - target); 9 min Objective1 = sum {s in SUBSETS} subset_deviation[s] * UseSubset[s]; 10 11 /* each node belongs to exactly one subset */ 12 con Partition {i in NODES}: 13 sum {s in SUBSETS: i in NODES_s[s]} UseSubset[s] = 1; 14 15 /* use exactly the allowed number of subsets */ 16 con Cardinality: 17 sum {s in SUBSETS} UseSubset[s] = num_clusters; 18 19 problem Master include 20 UseSubset Objective1 Partition Cardinality; 14 / 36

Static Column Generation 1 Generate all possible connected subsets with weights close enough to target 1 Relax connectivity and find all possible subsets 2 Postprocess to filter out disconnected subsets 2 Solve cardinality constrained set partitioning master problem 15 / 36

Static Column Generation 1 Generate all possible connected subsets with weights close enough to target 1 Relax connectivity and find all possible subsets 2 Postprocess to filter out disconnected subsets 2 Solve cardinality constrained set partitioning master problem 15 / 36

Static Column Generation 1 Generate all possible connected subsets with weights close enough to target 1 Relax connectivity and find all possible subsets 2 Postprocess to filter out disconnected subsets 2 Solve cardinality constrained set partitioning master problem 15 / 36

Features Used in PROC OPTMODEL MILP solver to compute maximum subset size for each node (COFOR loop) Network solver (all-pairs shortest path) to generate valid cuts that encourage connectivity Constraint programming solver to generate subsets (multiple solutions) Network solver (connected components) to check connectivity (COFOR loop) MILP solver to solve set partitioning problem 16 / 36

Column Generation Subproblem Given node populations p i and target population range Œ`; u Find all connected node subsets close to target population Binary variable x i indicates whether node i appears in subset ` P p i x i u i2n Connectivity hard to impose directly, so relax (but do not ignore) 17 / 36

Valid Cuts for Nodes Too Far Apart m i : max # nodes among feasible subsets that contain node i If shortest path distance d ij min.m i ; m j / then x i C x j 1 18 / 36

OPTMODEL Code: MILP Solver 1 /* maxnodes[i] = max number of nodes among feasible subsets that contain node i */ 2 num maxnodes {NODES}; 3 4 /* UseNode[i] = 1 if node i is used, 0 otherwise */ 5 var UseNode {NODES} binary; 6 7 max NumUsed = sum {i in NODES} UseNode[i]; 8 9 con PopulationBounds: 10 target - deviation_ub 11 <= sum {i in NODES} p[i] * UseNode[i] 12 <= target + deviation_ub; 13 14 problem MaxNumUsed include 15 UseNode NumUsed PopulationBounds; 16 use problem MaxNumUsed; 17 18 put Finding max number of nodes among feasible subsets that contain node i... ; 19 cofor {i in NODES} do; 20 put i=; 21 fix UseNode[i] = 1; 22 solve with MILP / loglevel=0 logfreq=0; 23 maxnodes[i] = round(numused.sol); 24 unfix UseNode; 25 end; 19 / 36

OPTMODEL Code: Network Solver 1 /* distance[i,j] = shortest path distance (number of edges) from i to j */ 2 num distance {NODES, NODES}; 3 /* num one {EDGES} = 1; */ 4 put Finding all-pairs shortest path distances... ; 5 solve with NETWORK / 6 links = (include=edges /*weight=one*/) 7 shortpath 8 out = (spweights=distance); 20 / 36

Valid Cuts for Small-Population Nodes If x i D 1 and p i < ` then x j D 1 for some neighbor j of i x i P j 2N i x j 21 / 36

Valid Cuts for Pairs of Small-Population Nodes If x i D x j D 1 and p i C p j < ` then x k D 1 for some neighbor k in moat around fi; j g x i C x j 1 P k2.n i [N j /nfi;j g x k 22 / 36

Valid Cuts for Pairs of Small-Population Nodes Can replace this cut with two stronger cuts If (x i D 1 or x j D 1) and p i C p j < ` then x k D 1 for some neighbor k in moat around fi; j g P x i x j x k k2.n i [N j /nfi;j g P x k k2.n i [N j /nfi;j g 23 / 36

Valid Cuts for Sets with Small Population More generally, if x i D 1 for some i 2 S N such that P p j < ` then x k D 1 for some neighbor k in moat around S P x i x k k2.[ j 2S N j /ns Known as ring inequalities in the literature j 2S 24 / 36

OPTMODEL Code: Constraint Programming Solver 1 set NODE_PAIRS = {i in NODES, j in NODES: i < j}; 2 3 /* cannot have two nodes i and j that are too far apart */ 4 con Conflict {<i,j> in NODE_PAIRS: distance[i,j] >= min(maxnodes[i],maxnodes[j])}: 5 UseNode[i] + UseNode[j] <= 1; 6 7 /* if UseNode[i] = 1 and p[i] < target - deviation_ub 8 then UseNode[j] = 1 for some neighbor j of i */ 9 con Moat1 {i in NODES: p[i] < target - deviation_ub}: 10 UseNode[i] <= sum {j in NEIGHBORS[i]} UseNode[j]; 11 12 /* if (UseNode[i] = 1 or UseNode[j] = 1) and p[i] + p[j] < target - deviation_ub 13 then UseNode[k] = 1 for some neighbor k in moat around {i,j} */ 14 con Moat2_i {<i,j> in NODE_PAIRS: p[i] + p[j] < target - deviation_ub}: 15 UseNode[i] <= sum {k in (NEIGHBORS[i] union NEIGHBORS[j]) diff {i,j}} UseNode[k]; 16 con Moat2_j {<i,j> in NODE_PAIRS: p[i] + p[j] < target - deviation_ub}: 17 UseNode[j] <= sum {k in (NEIGHBORS[i] union NEIGHBORS[j]) diff {i,j}} UseNode[k]; 18 19 problem Subproblem include 20 UseNode PopulationBounds Conflict Moat1 Moat2_i Moat2_j; 21 use problem Subproblem; 22 23 put Solving CLP subproblem... ; 24 solve with CLP / findallsolns; 25 /* use _NSOL_ and.sol[s] to access multiple solutions */ 26 SUBSETS = 1.._NSOL_; 27 for {s in SUBSETS} NODES_s[s] = {i in NODES: UseNode[i].sol[s] > 0.5}; 25 / 36

Constraint Programming Solver Log NOTE: Problem generation will use 4 threads. NOTE: The problem has 66 variables (0 free, 0 fixed). NOTE: The problem has 66 binary and 0 integer variables. NOTE: The problem has 5123 linear constraints (5122 LE, 0 EQ, 0 GE, 1 range). NOTE: The problem has 42926 linear constraint coefficients. NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range). NOTE: The experimental CLP solver is called. NOTE: All possible solutions have been found. NOTE: Number of solutions found = 4472. CARD(SUBSETS)=4472 26 / 36

OPTMODEL Code: Network Solver 1 /* check connectivity */ 2 set NODES_THIS; 3 num component {NODES_THIS}; 4 set DISCONNECTED init {}; 5 cofor {s in SUBSETS} do; 6 put s=; 7 NODES_THIS = NODES_s[s]; 8 if card(nodes_this) <= 3 then continue; /* connected */ 9 solve with NETWORK / 10 links = (include=edges) 11 subgraph = (nodes=nodes_this) 12 concomp 13 out = (concomp=component); 14 if or {i in NODES_THIS} (component[i] > 1) 15 then DISCONNECTED = DISCONNECTED union {s}; 16 end; 17 SUBSETS = SUBSETS diff DISCONNECTED; 27 / 36

Network Solver Log s=1 NOTE: The SUBGRAPH= option filtered 145 elements from EDGES. NOTE: The number of nodes in the input graph is 4. NOTE: The number of links in the input graph is 3. NOTE: Processing connected components. NOTE: The graph has 1 connected component. NOTE: Processing connected components used 0.00 (cpu: 0.00) seconds.... s=28 NOTE: The SUBGRAPH= option filtered 144 elements from EDGES. NOTE: The number of nodes in the input graph is 6. NOTE: The number of links in the input graph is 4. NOTE: Processing connected components. NOTE: The graph has 2 connected components. NOTE: Processing connected components used 0.00 (cpu: 0.00) seconds.... s=4472 NOTE: The SUBGRAPH= option filtered 144 elements from EDGES. NOTE: The number of nodes in the input graph is 5. NOTE: The number of links in the input graph is 4. NOTE: Processing connected components. NOTE: The graph has 1 connected component. NOTE: Processing connected components used 0.00 (cpu: 0.00) seconds. CARD(SUBSETS)=2771 28 / 36

OPTMODEL Code: MILP Solver 1 /* master problem: partition nodes into connected subsets, 2 minimizing deviation from target */ 3 /* UseSubset[s] = 1 if subset s is used, 0 otherwise */ 4 var UseSubset {SUBSETS} binary; 5 6 /* L_1 norm */ 7 num subset_population {s in SUBSETS} = sum {i in NODES_s[s]} p[i]; 8 num subset_deviation {s in SUBSETS} = abs(subset_population[s] - target); 9 min Objective1 = sum {s in SUBSETS} subset_deviation[s] * UseSubset[s]; 10 11 /* each node belongs to exactly one subset */ 12 con Partition {i in NODES}: 13 sum {s in SUBSETS: i in NODES_s[s]} UseSubset[s] = 1; 14 15 /* use exactly the allowed number of subsets */ 16 con Cardinality: 17 sum {s in SUBSETS} UseSubset[s] = num_clusters; 18 19 problem Master include 20 UseSubset Objective1 Partition Cardinality; 21 22... 23 24 use problem Master; 25 put Solving master problem, minimizing Objective1... ; 26 solve; 29 / 36

MILP Solver Log Graph Partitioning with Connectivity Constraints NOTE: Problem generation will use 4 threads. NOTE: The problem has 2771 variables (0 free, 0 fixed). NOTE: The problem has 2771 binary and 0 integer variables. NOTE: The problem has 67 linear constraints (0 LE, 67 EQ, 0 GE, 0 range). NOTE: The problem has 17334 linear constraint coefficients. NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range). NOTE: The OPTMODEL presolver is disabled for linear problems. NOTE: The MILP presolver value AUTOMATIC is applied. NOTE: The MILP presolver removed 1092 variables and 0 constraints. NOTE: The MILP presolver removed 7089 constraint coefficients. NOTE: The MILP presolver modified 0 constraint coefficients. NOTE: The presolved problem has 1679 variables, 67 constraints, and 10245 constraint coefficients. NOTE: The MILP solver is called. Node Active Sols BestInteger BestBound Gap Time 0 1 0. 96.3214286. 1... 0 1 0. 113.1320755. 1 0 1 1 124.0000000 117.1666667 5.83% 2 NOTE: The MILP solver added 40 cuts with 2752 cut coefficients at the root. 4 0 1 124.0000000 124.0000000 0.00% 2 NOTE: Optimal. NOTE: Objective = 124. 30 / 36

Solution for 14 Clusters, Bounds 12000 100, Objective1 31 / 36

OPTMODEL Code: MILP Solver 1 /* L_infinity norm */ 2 var MaxDeviation >= 0; 3 min Objective2 = MaxDeviation; 4 con MaxDeviationDef {s in SUBSETS}: 5 MaxDeviation >= subset_deviation[s] * UseSubset[s]; 6 7 put Solving master problem, minimizing Objective2... ; 8 MaxDeviation = max {s in SUBSETS} (subset_deviation[s] * UseSubset[s].sol); 9 solve with MILP / primalin; 32 / 36

MILP Solver Log Graph Partitioning with Connectivity Constraints NOTE: The problem has 2772 variables (0 free, 0 fixed). NOTE: The problem has 2771 binary and 0 integer variables. NOTE: The problem has 2838 linear constraints (0 LE, 67 EQ, 2771 GE, 0 range). NOTE: The problem has 22845 linear constraint coefficients. NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range). NOTE: The MILP presolver value AUTOMATIC is applied. NOTE: The MILP presolver removed 1092 variables and 1110 constraints. NOTE: The MILP presolver removed 9278 constraint coefficients. NOTE: The MILP presolver modified 0 constraint coefficients. NOTE: The presolved problem has 1680 variables, 1728 constraints, and 13567 constraint coefficients. NOTE: The MILP solver is called. Node Active Sols BestInteger BestBound Gap Time 0 1 1 37.0000000 5.8468795 532.82% 1... 0 1 1 37.0000000 26.0503748 42.03% 4 NOTE: The MILP solver added 89 cuts with 4657 cut coefficients at the root. 3 1 2 36.0000000 29.0000000 24.14% 5 6 2 3 35.0000000 29.0000000 20.69% 5 7 1 5 35.0000000 29.0000000 20.69% 6 64 54 6 29.0000000 29.0000000 0.00% 7 NOTE: Optimal. NOTE: Objective = 29. 33 / 36

Solution for 14 Clusters, Bounds 12000 100, Objective2 34 / 36

Live Demo Graph Partitioning with Connectivity Constraints OPTMODEL code GraphPartitioningConnectivity.sas 35 / 36

Using the OPTMODEL Procedure in SAS/OR to Solve Complex Problems