Xpress Optimization

Xpress R examples

Welcome to the FICO Xpress-R interface examples. Each example is a standalone R script. Some examples may require additional R packages that must be installed to successfully run the example. This can be done via the install.packages command within an interactive R session.

Each example is documented using Roxygen comments. Some of the explanations contain mathematical notation in LaTeX markup. To render a script as standalone HTML page that properly displays the mathematical content, please use the spin and knit commands of the knitr package, see the R Markdown Cookbook. For example, to render the standalone script "first_lp_problem.R" into an HTML page, you can use:

knitr::spin("first_lp_problem.R", format="Rmd")
knitr::knit("first_lp_problem.Rmd", output = "first_lp_problem.html")
or simply press CTRL/CMD+SHIFT+K from inside R studio, which executes both of the above steps with one command.



Load and solve a simple 2x2 linear program: xprs_loadproblemdata, displaying a solution as a data frame, a simple pipe workflow
 
Formulate and solve a Facility Location Problem: xprs_loadproblemdata, writeprob, setoutput, xprs_optimize, getsolution
 
Solve an LP and a MIP using Xpress-R: xprs_loadproblemdata, getintattrib, getdblattrib, readprob, getmipsol, getsolution
 
Read and write problems to and from standard formats MPS and LP: readprob, setintcontrol, writeprob
 
Set controls of Xpress: readprob, setintcontrol, setdefaultcontrol, getintattrib, getdblattrib, setdefaults, dumpcontrols
 
Query Attributes of Xpress: createprob, readprob, printing, getintattrib
 
Add indicator constraints: createprob, readprob, mipoptimize, getsolution, addrows, setindicator
 
Register an R function as callback into Xpress: readprob, getintattrib, addcboptnode, addcbintnode, getdblattrib
 
Formulate a quadratic optimization problem in Xpress: xprs_loadproblemdata, writeprob, xprs_optimize
 
Solving different types of Sudokus with the FICO Xpress Optimizer: xprs_loadproblemdata, addrows, getmipsol, mipoptimize
 
Modeling Sudokus creating columns and rows incrementally using xprs_newcol and xprs_addrow: createprob, setprobname, chgbounds, xprs_newcol, xprs_addrow, xprs_newrow, setoutput, getmipsol, mipoptimize
 
Solve Traveling Salesperson Problems using callbacks or delayed rows: xprs_loadproblemdata, addrows, addcuts, addcboptnode, addcbpreintsol, getcallbacksolution, loaddelayedrows
 
Solve a maximum flow problem and visualize the result: createprob, chgobjsense, setprobname, xprs_newcol, chgobj, xprs_addrow, getsolution
 
Solve a modified bin packing problem with the addition of a simple greedy heuristic: addmipsol, createprob, xprs_newcol, xprs_newrow, getsolution
 
Solve a routing problem using an arc-paths formulation for a telecommunication network: createprob, chgobjsense, xprs_newcol, xprs_addrow, getsolution
 
Solve a production planning problem: createprob, chgbounds, xprs_newcol, xprs_newrow, getsolution
 
Model a piecewise linear function using binary variables: createprob, chgbounds, xprs_newcol, xprs_addrow, getsolution
 
Optimize a composition of investment portfolios using semi-continuous variables: createprob, chgcoltype, chgglblimit, chgrhs, chgobjsense, xprs_newcol, xprs_newrow, getsolution
 
Find an optimal schedule of jobs on different machines and visualize the result in ggplot2: createprob, setprobname, xprs_newcol, xprs_newrow, xprs_addrow, setoutput, getdblattrib, getsolution
 
Solve two related problems assigning pilots to crews under different constraints: createprob, chgobjsense, chgobj, setprobname, xprs_newcol, xprs_addrow, setoutput, getsolution
 
Solve a timetabling problem for college courses under various constraints: createprob, chgbounds, chgobj, setprobname, xprs_newcol, xprs_newrow, setoutput, getsolution
 
Solve a small production problem with 2 products and 2 resource constraints: createprob, chgobjsense, setprobname, xprs_newcol, xprs_addrow, setoutput, getsolution
 
Solve a minimum cost flow problem in a bipartite graph: createprob, setprobname, xprs_newcol, xprs_addrow, setoutput, getsolution
 
Modeling a piecewise linear objective function using SOS2 constraints: createprob, setprobname, addsets, getdblattrib, xprs_newcol, xprs_addrow, setoutput, getsolution
 
Infeasibility and IIS Detection: createprob, getiisdata, getintattrib, iisall, iisstatus, iisisolations, xprs_newcol, xprs_newrow, xprs_optimize
 
Basis and Stability: bndsa, createprob, getbasis, getnamelist, loadbasis, objsa, rhssa, writebasis, writeslxsol, getsolution, xprs_newcol, xprs_newrow, xprs_optimize
 
Using the Tuner: createprob, setoutput, readprob, setintcontrol, tune, tunerreadmethod, tunerwritemethod, xprs_optimize
 
Goal programming: createprob, setoutput, xprs_newcol, xprs_addrow, chgobj, chgobjn, setobjintcontrol, setobjdblcontrol, xprs_optimize, getintattrib, getmipsol
 

 

  Comments or suggestions about the examples? Please e-mail support@fico.com