Mathematical programming is an extremely powerful technology that enables companies to make better use of available resources. Mathematical programming technologies like linear programming (LP) and mixed-integer programming (MIP) have been applied in a variety of business areas, often resulting in tens or even hundreds of millions of dollars in cost savings. To give a quick sampling of the breadth of applications for LP and MIP techniques:
While the process of building a mathematical programming model will probably look like magic to a non-expert, the intent of this page is to provide a bit of insight into what goes on behind the magic, and hopefully give an indication of how you might wield some of this magic for yourself. Math programming practitioners typically have mathematical training and significant practical experience, but understanding a few simple concepts can help you get a sense of the overall process. This page provides a quick, high-level overview of mathematical programming, as well as a few useful links to additional information, including case studies and example models.
We’ll start our discussion at the point where you’ve identified a part of your business that could potentially benefit from optimization (note that we’ll use the terms “mathematical programming”, “math programming”, “mathematical optimization”, and “optimization” interchangeably here). Such opportunities are generally found wherever critical resources are being underutilized because multiple different business processes compete for resources. The goal of a mathematical programming model is to
If this description seems a bit non-specific, that’s actually due to the flexibility of math programming. LP and MIP are highly mathematical technologies that don’t make any assumptions about the type of problem you are trying to solve or your goal in solving it. The person building the optimization model can specify what it means to maximize efficiency – maximizing profit, minimizing cost, minimizing delays, etc. Similarly, your resources can be anything – money, raw materials, machines, workers, etc. It’s up to the mathematical modeler to translate the often very tangible items that are part of the business process into the very mathematical objects that are used represent them in the optimization model.
If you have a sense that optimization could be the right tool for your business problem, you have a few options for scoping the opportunity. The simplest is probably to speak with an expert. Gurobi has a number of experts on staff, plus a network of consulting partners, that can help you size up an opportunity. The initial assessment typically only takes a few hours. We also have many customers with no background in optimization who have managed to teach themselves the relevant mathematical modeling concepts and have succeeded in building and deploying sophisticated optimization models.
Once you’ve identified a business process that could benefit from optimization, the next step is to create an optimization model to exploit the opportunity. There are three main steps to this process:
Let’s talk about each of these in more detail…
As we’ve noted, the first step in using optimization is to create a mathematical model of your business problem. An LP or MIP model consists of three primary ingredients:
The challenge here is to map the business problem, which may involve tangible entities like machines or products or people, into the form described above, which involves linear constraints on decision variables. At first glance, LP and MIP may appear to be a strange choice for solving business problems. As we noted above, LP and MIP allow you to state a set of linear constraints on decision variables (e.g., ‘2x + 3y + 5z <= 5’) and a linear objective on these same variables (e.g., ‘maximize x + y + z’). MIP also allows you to specify that certain variables must take integer values. These tools then compute values for your decision variables that maximize the objective function while respecting all stated linear constraints. That’s all that LP and MIP can do. While the merits of being able to optimize over a set of linear constraints might be clear if you are solving geometry problems, the suitability for production scheduling or electricity distribution problems probably isn’t so obvious.
For now, you’ll have to take our word for it that it is possible to map a wide variety of problems to LP/MIP form. Let’s spend a minute talking about why you would want to…
When faced with the task of solving a difficult problem, the first step is often to assemble a set of tools that might help to solve that problem. While you may not be able to find a tool that solves your exact problem, you can often find one that is effective at solving a related problem. While a custom tool may be able to exploit some special property of the specific problem you are solving, a general purpose tool has the advantage that it has probably been tuned and refined over a long period of time and a variety of users and uses.
This is particularly true for LP and MIP. If you can express your model as a set of linear constraints with a linear objective, over a set of continuous or integer decision variables, then you can reap the benefit of using a technology that has undergone a process of extensive refinement and improvement over the last 50+ years. The improvements in the technology have been quite spectacular, often transforming problems that were entirely intractable a decade ago into problems that are routinely solved today. What’s more, by building an LP or MIP model for your problem, you are then able to obtain the benefits of future improvements in the technology with no additional effort on your part.
To say that the benefits of expressing your problem as an LP or MIP are due to decades of effort focused on solving the problem doesn’t fully capture the virtues of LP and MIP, though. LP and MIP sit at a juncture between rich mathematical theory, elegant computational implementations, and richness of modeling and expressiveness that is quite rare and quite special. You could set the best and brightest minds at work for 50 years on many other problem types, and you would probably not wind up with technologies that are as powerful or as elegant as LP and MIP.
Hopefully we’ve convinced you that there are substantial benefits to formulating your problem as an LP or MIP model. If so, then the next step is to talk a bit about how that is done. The fundamental building block for a MIP model is the binary decision variable. It typically capture a yes/no decision, where a value of 1 means yes and a value of 0 means no. You can use a binary variable to represent any number of business decisions (“should I build this product?”, “should I buy this raw material?”, etc.). Constraints between binary variables represent competition for resources. Constraints between binary variables and continuous variables often capture the more detailed implications of these decisions.
Let’s consider a few simple examples. If you can choose at most one from among a set of conflicting activities, that would be captured as a linear constraint on binary decision variables:
b1 + b2 + b3 <= 1
If these are all binary variables, then at most one variable in the list can take value 1, and that one would correspond to the chosen activity. Similarly, changing the inequality to an equality:
b1 + b2 + b3 = 1
…would force you to always choose one of the three possible activities.
Given a decision that is reflected in the value of a binary variable, you can use additional variables and constraints to capture the consequences of that decision. For example, if you need to transport items from one city to another, then a decision about whether to send a truck between those cities determines the maximum number of items that can be sent. By introducing a variable items[ij] to represent the
number of items sent from city i to city j, then the following linear constraint would capture the relationship between the number of items sent and a decision about whether to send a truck with a capacity of 10 items:
itemsij <= 10 * truckij
If binary variable truck[ij] is 1, then you can send up to 10 items. If it is 0, then you can’t send any items.
These are just a few examples chosen from among a large set of idioms that are useful when building a mathematical model. A typical optimization model will consist of a mix of many straightforward linear constraints (e.g., the sum of these cost variables must respect the overall budget), along with a few more idiomatic constraints. Furthermore, a typical model will consist of thousands or even millions of constraints, but the overall size is typically the result of replicating the same set of constraints over multiple pieces of input data. One of the best ways to learn these idioms is to study example models. You’ll find examples from a variety of industries that you can browse and learn from here.
If you ask an architect to design a house for you, his first thought is not going to be about how to pour concrete for the foundation. He’s going to try to identify important characteristics of the desired house (size, style, bedrooms, etc.), and then modify a house design with similar characteristics to meet your specific needs. Similarly, while understanding the low-level process of building an optimization model can be quite useful, the reality is that the mathematical modeling process is often mostly about recognizing common structure in your problem and customizing well-established models to capture the specifics of your problem.
Mathematical modeling has a number of commonly occurring model patterns that appear in many different applications. Examples include fixed-charge network flow, set partitioning, production planning, facility location, job shop scheduling, portfolio optimization, etc. It is well worth your time to familiarize yourself with common model types. Our website provides a number of example models that capture common model types. To reiterate, the model you need for your problem may not match any of these patterns exactly, but you are often better off approaching your problem by identifying a similar pattern and then thinking about how it could to customized to capture your problem, rather than trying to solve your problem from scratch.
While we’ve only mentioned LP and MIP so far, there are a number of interesting extensions that can also be solved efficiently. If your problem has a quadratic objective, involving products of decision variables rather than just linear terms, then you can solve your model as a Quadratic Program (QP) or a Mixed-Integer Quadratic Program (MIQP). If your model has quadratic constraints as well, you can solve your model as a Quadratically Constrained Program (QCP), or a Mixed-Integer Quadratically Constrained Program (MIQCP). These variants place a few restrictions on the form of the quadratic objective or constraint, but many important types of models can be cast in this form.
Another common class of models is non-linear programming (NLP) problems. While general NLP is an extremely difficult problem, such problems can often be solved using a very common and powerful approach called piecewise-linear approximation. By approximating the non-linear function using a series of linear functions, you can often transform what is typically an exceedingly difficult optimization problem into one that can be easily handled by an LP or MIP solver. Optimization solvers typically include modeling tools that make it straightforward to express a piecewise-linear function.
Once you have an idea of how to build a math programming model that would solve your problem, the next step is to write a computer program that implements your model. Gurobi provides interfaces for most of the commonly used programming languages: C, C++, Java, .NET, Python, R, and MATLAB. When people ask us which language is best for math programming, our answer is that people should use the language they are most comfortable in. All of our interfaces are thin layers that sit on top of the same optimization algorithms (implemented in C). There are difference in our various language API’s, but ultimately those differences will have a smaller impact on your productivity than working in an unfamiliar language would. Another point to consider is that mathematical models rarely live in isolation. They typically consume data from some data source, and they produce results that are consumed by some downstream process. The languages and formats of these dependent processes will influence your choice of language.
Having said that, if you don’t have a reason to prefer one language over another, we recommend you use our Python API. We’ve found that this API increases modeling productivity substantially. It includes a number of higher-level modeling constructs that reduce the gap between the mathematical model itself and the implementation of that model, which makes it a lot easier to build and maintain optimization models.
The mechanics of building the optimization model are generally quite straightforward, once you have assembled the necessary input data. Our Getting Started with the Gurobi API Tutorials work through simple examples in each of our supported languages. This example touches on the basics of our API’s, including the process of creating a model, adding decision variables, adding constraints, setting the objective function, etc. We also include a number of functional examples that cover the use of more advanced features in our product.
A large part of the power of LP and MIP is that they provide a declarative approach to solving a problem. It is your job to state, or declare, your problem (the decision variables, constraints, and objective), and it is our job to find an optimal solution. The solver employs a number of very sophisticated algorithms for both LP and MIP problem types (and a number of parameters that optionally give you control over the behavior of these algorithms), but you generally don’t need to understand how these algorithms works to obtain a solution to your problem.
Your next step in building an optimization model will depend on how hands-on you’d like to be. As we noted above, if you are interested in further details about different aspects of math programming, you can refer to our Python basics discussion for more information on building a model, or our LP basics and MIP basics pages for more information on the underlying solution algorithms. You also browse our examples or our case studies.
If you are a commercial user who would like to discuss your problem with an expert, you can contact Gurobi directly. As Gurobi is free for qualified academic users, we provide direct support for installation and licensing questions and a monitored Gurobi Community Discussion Forum for other questions.
We also have a list of consulting firms who can help you to scope your problem and build a solution.
Of course, the best next step is to try Gurobi for yourself:
GUROBI NEWSLETTER
Latest news and releases
Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.
Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.
Cookie | Duration | Description |
---|---|---|
_biz_flagsA | 1 year | A Cloudflare cookie set to record users’ settings as well as for authentication and analytics. |
_biz_pendingA | 1 year | A Cloudflare cookie set to record users’ settings as well as for authentication and analytics. |
_biz_sid | 30 minutes | This cookie is set by Bizible, to store the user's session id. |
ARRAffinity | session | ARRAffinity cookie is set by Azure app service, and allows the service to choose the right instance established by a user to deliver subsequent requests made by that user. |
ARRAffinitySameSite | session | This cookie is set by Windows Azure cloud, and is used for load balancing to make sure the visitor page requests are routed to the same server in any browsing session. |
BIGipServersj02web-nginx-app_https | session | NGINX cookie |
cookielawinfo-checkbox-advertisement | 1 year | Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Advertisement" category . |
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
CookieLawInfoConsent | 1 year | Records the default button state of the corresponding category & the status of CCPA. It works only in coordination with the primary cookie. |
elementor | never | This cookie is used by the website's WordPress theme. It allows the website owner to implement or change the website's content in real-time. |
JSESSIONID | session | New Relic uses this cookie to store a session identifier so that New Relic can monitor session counts for an application. |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Cookie | Duration | Description |
---|---|---|
__cf_bm | 30 minutes | This cookie, set by Cloudflare, is used to support Cloudflare Bot Management. |
_biz_nA | 1 year | Bizible sets this cookie to remember users’ settings as well as for authentication and analytics. |
_biz_uid | 1 year | This cookie is set by Bizible, to store user id on the current domain. |
_hjAbsoluteSessionInProgress | 30 minutes | Hotjar sets this cookie to detect a user's first pageview session, which is a True/False flag set by the cookie. |
_mkto_trk | 2 years | This cookie is set by Marketo. This allows a website to track visitor behavior on the sites on which the cookie is installed and to link a visitor to the recipient of an email marketing campaign, to measure campaign effectiveness. Tracking is performed anonymously until a user self-identifies by submitting a form. |
bcookie | 1 year | LinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser ID. |
bscookie | 1 year | LinkedIn sets this cookie to store performed actions on the website. |
doc_langsBB | 1 year | Documentation system cookie |
doc_version | 1 year | Documentation system cookie |
lang | session | LinkedIn sets this cookie to remember a user's language setting. |
lidc | 1 day | LinkedIn sets the lidc cookie to facilitate data center selection. |
UserMatchHistory | 1 month | LinkedIn sets this cookie for LinkedIn Ads ID syncing. |
whova_client_id | 10 years | Event agenda system cookie |
Cookie | Duration | Description |
---|---|---|
_gat_UA-5909815-1 | 1 minute | A variation of the _gat cookie set by Google Analytics and Google Tag Manager to allow website owners to track visitor behaviour and measure site performance. The pattern element in the name contains the unique identity number of the account or website it relates to. |
Cookie | Duration | Description |
---|---|---|
_an_uid | 7 days | 6Sense Cookie |
_BUID | 1 year | This cookie, set by Bizible, is a universal user id to identify the same user across multiple clients’ domains. |
_ga | 2 years | The _ga cookie, installed by Google Analytics, calculates visitor, session and campaign data and also keeps track of site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognize unique visitors. |
_ga_* | 1 year 1 month 4 days | Google Analytics sets this cookie to store and count page views. |
_gat_UA-* | 1 minute | Google Analytics sets this cookie for user behaviour tracking. |
_gcl_au | 3 months | Provided by Google Tag Manager to experiment advertisement efficiency of websites using their services. |
_gd_session | 4 hours | This cookie is used for collecting information on users visit to the website. It collects data such as total number of visits, average time spent on the website and the pages loaded. |
_gd_visitor | 2 years | This cookie is used for collecting information on the users visit such as number of visits, average time spent on the website and the pages loaded for displaying targeted ads. |
_gid | 1 day | Installed by Google Analytics, _gid cookie stores information on how visitors use a website, while also creating an analytics report of the website's performance. Some of the data that are collected include the number of visitors, their source, and the pages they visit anonymously. |
_hjFirstSeen | 30 minutes | Hotjar sets this cookie to identify a new user’s first session. It stores the true/false value, indicating whether it was the first time Hotjar saw this user. |
_hjIncludedInSessionSample_* | 2 minutes | Hotjar cookie that is set to determine if a user is included in the data sampling defined by a site's daily session limit. |
_hjRecordingEnabled | never | Hotjar sets this cookie when a Recording starts and is read when the recording module is initialized, to see if the user is already in a recording in a particular session. |
_hjRecordingLastActivity | never | Hotjar sets this cookie when a user recording starts and when data is sent through the WebSocket. |
_hjSession_* | 30 minutes | Hotjar cookie that is set when a user first lands on a page with the Hotjar script. It is used to persist the Hotjar User ID, unique to that site on the browser. This ensures that behavior in subsequent visits to the same site will be attributed to the same user ID. |
_hjSessionUser_* | 1 year | Hotjar cookie that is set when a user first lands on a page with the Hotjar script. It is used to persist the Hotjar User ID, unique to that site on the browser. This ensures that behavior in subsequent visits to the same site will be attributed to the same user ID. |
_hjTLDTest | session | To determine the most generic cookie path that has to be used instead of the page hostname, Hotjar sets the _hjTLDTest cookie to store different URL substring alternatives until it fails. |
6suuid | 2 years | 6Sense Cookie |
AnalyticsSyncHistory | 1 month | LinkedIn cookie |
BE_CLA3 | 1 year 1 month 4 days | BrightEdge sets this cookie to enable data aggregation, analysis and report creation to assess marketing effectiveness and provide solutions for SEO, SEM and website performance. |
CONSENT | 2 years | YouTube sets this cookie via embedded youtube-videos and registers anonymous statistical data. |
dj | 10 years | DemandJump cookie |
djaimid.a28e | 2 years | DemandJump cookiean |
djaimses.a28e | 30 minutes | DemandJump cookie |
li_gc | 5 months 27 days | LinkedIn Cookie |
ln_or | 1 day | LinkedIn Cookie |
vuid | 2 years | Vimeo installs this cookie to collect tracking information by setting a unique ID to embed videos to the website. |
Cookie | Duration | Description |
---|---|---|
__adroll | 1 year 1 month | This cookie is set by AdRoll to identify users across visits and devices. It is used by real-time bidding for advertisers to display relevant advertisements. |
__adroll_fpc | 1 year | AdRoll sets this cookie to target users with advertisements based on their browsing behaviour. |
__adroll_shared | 1 year 1 month | Adroll sets this cookie to collect information on users across different websites for relevant advertising. |
__ar_v4 | 1 year | This cookie is set under the domain DoubleClick, to place ads that point to the website in Google search results and to track conversion rates for these ads. |
_fbp | 3 months | This cookie is set by Facebook to display advertisements when either on Facebook or on a digital platform powered by Facebook advertising, after visiting the website. |
_te_ | session | Adroll cookie |
fr | 3 months | Facebook sets this cookie to show relevant advertisements to users by tracking user behaviour across the web, on sites that have Facebook pixel or Facebook social plugin. |
IDE | 1 year 24 days | Google DoubleClick IDE cookies are used to store information about how the user uses the website to present them with relevant ads and according to the user profile. |
li_sugr | 3 months | LinkedIn sets this cookie to collect user behaviour data to optimise the website and make advertisements on the website more relevant. |
test_cookie | 15 minutes | The test_cookie is set by doubleclick.net and is used to determine if the user's browser supports cookies. |
VISITOR_INFO1_LIVE | 5 months 27 days | A cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface. |
YSC | session | YSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages. |
yt-remote-connected-devices | never | YouTube sets this cookie to store the video preferences of the user using embedded YouTube video. |
yt-remote-device-id | never | YouTube sets this cookie to store the video preferences of the user using embedded YouTube video. |
yt.innertube::nextId | never | This cookie, set by YouTube, registers a unique ID to store data on what videos from YouTube the user has seen. |
yt.innertube::requests | never | This cookie, set by YouTube, registers a unique ID to store data on what videos from YouTube the user has seen. |