Introduction to CPLEX. Some very convenient solvers for most students include those with Excel and Matlab.

Similar documents
NEOS.jl (and other things)

CS CS Tutorial 2 2 Winter 2018

Quick Note 24. Extracting the debug.txt file from a TransPort. Digi Technical Support. February Page 1

Setting up my Dev Environment ECS 030

Simulation. Lecture O1 Optimization: Linear Programming. Saeed Bastani April 2016

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

CSE115 Lab exercises for week 1 of recitations Spring 2011

Tutorial 1: Unix Basics

Bitnami Apache Solr for Huawei Enterprise Cloud

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Lab 1 Introduction to UNIX and C

Linux Survival Guide

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

CS Fundamentals of Programming II Fall Very Basic UNIX

Telnet/SSH. Connecting to Hosts. Internet Technology 1

sftp - secure file transfer program - how to transfer files to and from nrs-labs

Datathon 2018 Connecting to MicroStrategy on AWS Cloud

5. DUAL LP, SOLUTION INTERPRETATION, AND POST-OPTIMALITY

Using WestGrid from the desktop Oct on Access Grid

SETTING UP SSH FOR YOUR PARALLELLA: A TUTORIAL FOR STUDENTS

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011)

Session 1: Accessing MUGrid and Command Line Basics

Helsinki 19 Jan Practical course in genome bioinformatics DAY 0

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

Bitnami MEAN for Huawei Enterprise Cloud

Software Installation - Accessing Linux and Checking your Environmental Variables

Lab 1: Introduction to C, ASCII ART & the Linux Command Line

Solving Linear Programs Using the Simplex Method (Manual)

You can use the WinSCP program to load or copy (FTP) files from your computer onto the Codd server.

ILOG CPLEX 10.0 Interactive Optimizer January 2006

CS Operating Systems, Fall 2018 Project #0 Description

Lab 1: Accessing the Linux Operating System Spring 2009

Math Models of OR: The Simplex Algorithm: Practical Considerations

First-Time Login Procedure on XWin32

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

AMS 200: Working on Linux/Unix Machines

Section Notes 4. Duality, Sensitivity, and the Dual Simplex Algorithm. Applied Math / Engineering Sciences 121. Week of October 8, 2018

Programming Studio #1 ECE 190

Upgrading R/Evolution Storage Systems

MPL Modeling System. Release 4.2

Introduction. Linear because it requires linear functions. Programming as synonymous of planning.

STA 303 / 1002 Using SAS on CQUEST

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

LAB #5 Intro to Linux and Python on ENGR

Link Gateway Initial Configuration Manual

Using the Zoo Workstations

Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

Parallelizing the dual revised simplex method

User Guide Version 2.0

Gurobi Guidelines for Numerical Issues February 2017

Bitnami MariaDB for Huawei Enterprise Cloud

Advanced Operations Research Techniques IE316. Quiz 2 Review. Dr. Ted Ralphs

EECS 211 Lab 2. Getting Started. Getting the code. Windows. Mac/Linux

Student Website Setup

Lab 1 Introduction to UNIX and C

Solving Scenarios in the Cloud

A Survey of Software Packages for Teaching Linear and Integer Programming

Bitnami MySQL for Huawei Enterprise Cloud

Operation Manual SSH H3C S3610&S5510 Series Ethernet Switches. Table of Contents

EECS 1710 SETTING UP A VIRTUAL MACHINE (for EECS labs)

Using Integration Utility

About shells and command lines

COSC UNIX. Textbook. Grading Scheme

What is EV3DEV? Send commands to the EV3 Upload programs and run them on the EV3

Remote Access to Unix Machines

No Food or Drink in this room. Logon to Windows machine

Release notes for CPLEX

The Command Shell. Fundamentals of Computer Science

Bitnami JRuby for Huawei Enterprise Cloud

The Ascendance of the Dual Simplex Method: A Geometric View

The SAS/OR s OPTMODEL Procedure :

Fundamentals of Integer Programming

Find out where you currently are in the path Change directories to be at the root of your home directory (/home/username) cd ~

To register and set up your access. Click the register button the next screen you see will look like this:

KB How to upload large files to a JTAC Case

oit Using HTPASSWD to Password Protect Pages on Campus Web Server Web sites UMass Offi ce of Information Technologies

AN OVERVIEW OF COMPUTING RESOURCES WITHIN MATHS AND UON

Notes on AMPL for and (Adapted from notes by Sommer Gentry)

CMSC 201 Spring 2017 Lab 01 Hello World

The MIP-Solving-Framework SCIP

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

Linux/Cygwin Practice Computer Architecture

On the Optimization of CPLEX Models

You should see something like this, called the prompt :

Welcome to the Webinar. What s New in Gurobi 7.5

Cmpt 101 Lab 1 - Outline

Programming Studio #1 ECE 190

COMP9334: Capacity Planning of Computer Systems and Networks

The tool can also be accessed by clicking the Self Service Password Manager icon on your desktop, or by visiting:

Econ 172A - Slides from Lecture 9

Optimization of Design. Lecturer:Dung-An Wang Lecture 8

Author A.Kishore/Sachin WinSCP

Lab: Supplying Inputs to Programs

Artificial Intelligence

INTRODUCTION BACKGROUND DISCOVERER. Dan Vlamis, Vlamis Software Solutions, Inc. DISCOVERER PORTLET

Lab 1: Getting Started with Linux The Extremely Illustrated Version. Graham Northup

Model 5100 Remote Administration Guide

15-122: Principles of Imperative Computation

CSN08101 Digital Forensics. Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak

Chapter 7. Linear Programming Models: Graphical and Computer Methods

Transcription:

1.0 Overview Introduction to CPLEX There are a number of commercial grade LP solvers available. An excellent survey of such surveys can be found at http://lionhrtpub.com/orms/surveys/lp/lp-survey.html. You can also find a lot of free open source solvers, see http://en.wikipedia.org/wiki/list_of_optimization_software Some very convenient solvers for most students include those with Excel and Matlab. The standard one that comes with Excel uses a basic implementation of the primal Simplex method; however, it is limited to 200 decision variables. To use it, the Solver add-in must be included (not installed by default). To add this facility you need to carry out the following steps: 1. Select the menu option Tools Add_Ins 2. From the dialogue box presented check the box for Solver Add-In. On clicking OK, you will then be able to access the Solver option from the new menu option Tools Solver. If you want to see how to use it, using the LP example we have been working on, click on http://www.economicsnetwork.ac.uk/cheer/ch9_3/ch9_3p07.htm. 1

You can also buy commercial add-ons that significantly improve the power of Excel as an LP solver. For example, see http://www.solver.com/. Matlab also has a very easy to use solver. But this solver may not be the best for industrial applications because of difficulties in interfacing with Matlab and because of the solvers themselves may not necessarily be state-of-art. However, there is an addon for Matlab, called Tomlab, which compensates for this, and we have it at ISU if you want to use it. See http://tomopt.com/tomlab/about/ for more details about Tomlab. There are some other good LP solvers, including, for example, Lindo and GAMS. However, market/ems software vendors in the power engineering industry mainly use CPLEX (commercialized by ILOG later purchased by IBM). These organizations, together with the ISO s that they serve, are very interested in hiring people knowledgeable in mathematical programming (MP), and the tools available to implement MPs. If you have already been in industry, if you do not work with one of these organizations, you may find yourself interfacing with them, in which case you 2

may also benefit from familiarity with CPLEX. For the rest of you, CPLEX is an excellent LP/IP-solver platform, and I can easily make it available to you. General information about CPLEX can be found at http://www- 01.ibm.com/software/integration/optimization/cplexoptimizer/. Another attractive facility from ILOG is the capability to integrate solvers into existing code. This is available if you also acquire ILOG's Optimization Programming Language (ILOG OPL). A description at http://www.ilog.com/products/oplstudio/ states: The ILOG OPL integrated development environment (IDE) makes it easy to evaluate different modeling approaches to a problem and to integrate external data. Debugging and tuning tools support the development process, and once ready, the model can be deployed into an external application. ILOG OPL models can be easily integrated into any application written in Java,.NET or C++. Alternatively, the ILOG Optimization Decision Manager (ILOG ODM) extension to the ILOG OPL-CPLEX Development System can be used to generate a state-of-the-art decision support application based on the ILOG OPL model. So I need to tell you how to access CPLEX at ISU. 3

2.0 Accessing CPLEX CPLEX version 10.1.0 resides on an ISU server called pluto. To access it, you will need to logon to pluto. To do that, you will need a telnet and ftp facility. I suggest using the facilities WinSCP2 and PuTTY. WinSCP2 is an ftp facility. PuTTY is a free implementation of Telnet and SSH for Win32 and Unix platforms, along with an xterm terminal emulator. Links to download both of these programs is found at http://clue.eng.iastate.edu/downloads.shtml. The WinSCP2 download page is at http://winscp.net/eng/download.php#download2, where you should click on [Download]. Once installed, when you bring up the program, click on New. In the screen, type into the Hostname the a server name get to one of the servers which has CPLEX installed. These servers are listed at http://it.engineering.iastate.edu/remote/. For example, you can type linux-7.ece.iastate.edu. Also enter you username and password, and then click Login. Once logged in, a navigation screen for your local machine will appear on your left, and a navigation screen for the remote machine will appear on your right. You can click on the up directory towards the top of each screen to move upwards, and of course just click on a directory to move down into it. 4

To transfer a file from your local machine to the remote machine, use the left screen to navigate to the directory on your local machine where the file resides. Then click once on the file you want to transfer. (If you want to transfer multiple files, you can click once on each file while holding down the control key.) Now navigate to the directory on your remote machine where you want to put the file. Once there, click on the Files menu above the left hand screen, and choose Copy. The program will verify that you want to copy, and if you affirm, it will copy. To download PuTTY, 1. The PuTTY download page is at www.chiark.greenend.org.uk/~sgtatham/putty/download.html. At this page, you will find some alternatives; I used (successfully) the installer, putty-0.61-installer.exe. 2. Run PuTTY and get the window shown in Fig. 1. Input linux-7.ece.iastate.edu in the Host Name 5

Fig. 1 Run PuTTY 3. Use your ISU username and password to log in. You will find yourself on a unix terminal emulator. 4. You might like to create a working directory. To do this, use mkdir DirectoryName, where DirectoryName is the name of the directory you want to use. To enter that directory, use cd DirectoryName. You can see what files reside in that directory using the command ls. 5. To run CPLEX, type cplex122. Although you can use CPLEX from a command line, I find it is almost always better to prepare a file. It is probably better to prepare a file on your own computer, and then port it over to the server. 2.0 A CPLEX Example To illustrate this process, I will solve the following problem using CPLEX. 6

max F 5x 1 4x2 3 Subject to 2x 1 3x2 x3 4x 1 x2 2x3 3x 1 4x2 2x3 1 0, x2 0, x3 x 5 11 The first thing to do is to construct a file containing the problem. To construct this file, you can use the program called notepad under the accessories selection of the start button in Windows. Once you open notepad, you can immediately save to your local directory under the filename filename.lp. You can choose filename to be whatever you want, but you will need the extension lp. To obtain the extension lp when you save, you should do save as and then choose all files. Otherwise, it will assign the suffix.txt to your file. Here is what I typed into the file I called ex2.lp 8 0 x 3 7

maximize 5 x1 + 4 x2 + 3 x3 subject to 2 x1 + 3 x2 + x3 <= 5 4 x1 + x2 + 2x3 <= 11 3 x1 + 4 x2 + 2 x3 <= 8 x1 >= 0 x2 >= 0 x3 >= 0 end The format of the above file is quite forgiving. Nonetheless, your first time through, perhaps you should do it exactly as I have done. Once I saved the file ex2.lp on my local hard drive, I then used WinSCP to port it over to the server, where I saved it in a special directory I had set up for this. Then I used PuTTY to telnet to the server, where I then used the cd command to go into the directory where the ex2.lp file was located. Once in that directory, I typed cplex122 at the command prompt. The following is the log of my CPLEX session from this point on: [jdm@linux-6 458]$ cplex122 8

IBM ILOG License Manager: "IBM ILOG Optimization Suite for Academic Initiative" is accessing CPLEX 12 with option(s): "e m b q ". IBM ILOG CPLEX Optimization Studio Academic Research Edition Welcome to IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer 12.2.0.0 with Simplex, Mixed Integer & Barrier Optimizers 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724- Y55 Copyright IBM Corp. 1988, 2010. All Rights Reserved. Type 'help' for a list of available commands. Type 'help' followed by a command name for more information on commands. CPLEX> read ex2.lp Problem 'ex2.lp' read. Read time = 0.02 sec. CPLEX> primopt Tried aggregator 1 time. LP Presolve eliminated 3 rows and 0 columns. Reduced LP has 3 rows, 3 columns, and 9 nonzeros. Presolve time = 0.00 sec. Iteration log... Iteration: 1 Objective = 12.500000 9

Primal simplex - Optimal: Objective = 1.3000000000e+01 Solution time = 0.00 sec. Iterations = 2 (0) CPLEX> display solution variables - Variable Name Solution Value x1 2.000000 x3 1.000000 All other variables in the range 1-3 are 0. CPLEX> display solution slacks - Constraint Name Slack Value slack c2 1.000000 slack c4-2.000000 slack c6-1.000000 All other slacks in the range 1-6 are 0. CPLEX> display solution dual - Constraint Name Dual Price c1 1.000000 c3 1.000000 All other dual prices in the range 1-6 are 0. CPLEX> quit [jdm@linux-6 458]$ A few comments about the above might be useful: 1. The command read ex2.lp was required to read the problem. Note that this command reinitializes CPLEX. Once you solve a problem, it will not resolve until you reinitialize. 10

2. Once we had read in the problem, we solved it by issuing the command primopt which calls the primal simplex algorithm. This is the algorithm we have been studying (there are other algorithms that you can call with CPLEX as well). 3. The objective function improved to 12.5 after the first iteration (from 0). 4. The problem solved in the second iteration. 5. The command display solution variables - was used to display the values of the decision variables at the solution. 6. The values of the decision variables at the solution were x 1 =2, x 2 =0, x 3 =1, and at this solution, the value of the objective function was F=13. 7. Note that CPLEX does not print the values of decision variables that are zero. 8. The command display solution slacks was used to display the values of the slacks at the solution. 9. CPLEX will name the slack variables c 1, c 2,, c m, c m+1,, c m+n where there are m constraints and n decision variables. Therefore the first m slack variables (c 1, c 2,, c m ) correspond to the explicit inequality constraints, and the last n slack variables (c m+1,, c m+n ) correspond to the nonnegativity constraints on the decision variables. 10. The values of the slack variables at the solution were c 1 =0, c 2 =1, c 3 =0, c 4 =-2, c 5 =0, c 6 =-1. 11

11. Note that CPLEX does not print the values of slack variables that are zero. 12. The fact that c 1 =0 and c 3 =0 indicates that the first and third constraints are binding. That c 2 =1 indicates the left-hand side of the second constraint is less than the right-hand-side by 1. Checking these constraints, we find Constraint 1: 2x1 3x2 x3 5 2(2) 3(0) 1 5 Constraint 2: 4x1 x2 2x3 11 4(2) 0 2(1) 10 Constraint 3: 3x1 4x2 2x3 8 3(2) 4(0) 2(1) 8 13. The fact that c 5 =0 indicates that the second inequality constraint is binding, i.e., x 2 0 which is consistent with the fact that x 2 =0. 14. The facts that c 4 =-2, c 6 =-1 is interesting because these slacks are negative. This is a result of the fact that the corresponding constraints are actually 12

greater than or less to constraints instead of less than or equal to constraints. The way they are treated in CPLEX is as follows: x 1 0 x1 c4 so that when x 1 =2, as it is in the solution, c 4 =-2. Likewise, x 3 0 x3 c6 so that when x 3 =1, as it is in the solution, c 6 =-1. So the above is a very brief and concise introduction to CPLEX. I have also provided a somewhat more detailed tutorial (although not overly-detailed) on the course website to give you a good reference to use for CPLEX. 0 0 13