![](images/codefold.png) Xpress BCL library examples![](images/codefold.png) Examples in C Chess - Composing constraints and solvingSimple LP problem, termwise constraint definition, LP solving Workshop - Displaying solution informationRetrieving and displaying solution values and ranging information; real value printing format, number output format Contract - Semi-continuous variables, predefined constraint functions, combine BCL with Xpress OptimizerDefining semi-continuous variables, MIP solving Chgprobs - Working with multiple problemsHandling multiple problems Setops - Index setsUsing index sets, set operations Burglar - Use of index sets, formulating logical constraintsIndex an array of variables by an index set, defining indicator constraints Coco - A full production planning exampleData input from text files Delivery - Data input from file; infeasibility analysisLP model, data input from file, retrieving IIS Purchase - Definition of SOS-2Data input from file, using SOS-2 Portfolio - Quadratic Programming with discrete variablesQuadratic objective function Catenary - Solving a QCQPStating quadratic constraints Cutstk - Column generation for a cutting stock problemWorking with subproblems, modifying constraints Els - An economic lot-sizing problem solved by cut-and-branch and branch-and-cut heuristicsLooping of optimization, using the cut manager Fixbv - A binary fixing heuristicChanging bounds, saving and loading bases, saving and loading start solutions Recurse - A successive linear programming modelIterative solving, modify constraint definitions MT2 - Solving two problems in parallel in a thread-safe environmentParallel computing GoalObj - Archimedian and pre-emptive goal programming using objective functionsMulticriteria optimization, multi-objective decision making Wagon - MIP start solution heuristicLoading MIP start solution, 'solnotify' callback UG - Examples from 'BCL Reference Manual'MIP modeling, error handling, using Xpress Optimizer with BCL Folio - Examples from 'Getting Started'MIP modeling, quadratic constraints, infeasibility handling, solution enumeration
![](images/codefold.png) Examples in C++ Chess - Composing constraints and solvingSimple LP problem, termwise constraint definition, LP solving Workshop - Displaying solution informationRetrieving and displaying solution values and ranging information; real value printing format, number output format Contract - Semi-continuous variables, predefined constraint functions, combine BCL with Xpress OptimizerDefining semi-continuous variables, MIP solving Chgprobs - Working with multiple problemsHandling multiple problems Setops - Index setsUsing index sets, set operations Burglar - Use of index sets, formulating logical constraintsIndex an array of variables by an index set, defining indicator constraints Coco - A full production planning exampleData input from text files Delivery - Data input from file; infeasibility analysisLP model, data input from file, retrieving IIS Purchase - Definition of SOS-2Data input from file, using SOS-2 Portfolio - Quadratic Programming with discrete variablesQuadratic objective function Catenary - Solving a QCQPStating quadratic constraints Cutstk - Column generation for a cutting stock problemWorking with subproblems, modifying constraints Els - An economic lot-sizing problem solved by cut-and-branch and branch-and-cut heuristicsLooping of optimization, using the cut manager Fixbv - A binary fixing heuristicChanging bounds, saving and loading bases, saving and loading start solutions Recurse - A successive linear programming modelIterative solving, modify constraint definitions GoalObj - Archimedian and pre-emptive goal programming using objective functionsMulticriteria optimization, multi-objective decision making Wagon - MIP start solution heuristicLoading MIP start solution, 'solnotify' callback UG - Examples from 'BCL Reference Manual'MIP modeling, error handling, using Xpress Optimizer with BCL Folio - Examples from 'Getting Started'MIP modeling, quadratic constraints, infeasibility handling, solution enumeration Folio - Examples from 'Getting started'LP, MIP and QP models, explicit initialization, index sets, heuristic solution
![](images/codefold.png) Examples in C# Chess - Composing constraints and solvingSimple LP problem, termwise constraint definition, LP solving Workshop - Displaying solution informationRetrieving and displaying solution values and ranging information; real value printing format, number output format Contract - Semi-continuous variables, predefined constraint functions, combine BCL with Xpress OptimizerDefining semi-continuous variables, MIP solving Chgprobs - Working with multiple problemsHandling multiple problems Setops - Index setsUsing index sets, set operations Burglar - Use of index sets, formulating logical constraintsIndex an array of variables by an index set, defining indicator constraints Coco - A full production planning exampleData input from text files Delivery - Data input from file; infeasibility analysisLP model, data input from file, retrieving IIS Purchase - Definition of SOS-2Data input from file, using SOS-2 Portfolio - Quadratic Programming with discrete variablesQuadratic objective function Catenary - Solving a QCQPStating quadratic constraints Cutstk - Column generation for a cutting stock problemWorking with subproblems, modifying constraints Els - An economic lot-sizing problem solved by cut-and-branch and branch-and-cut heuristicsLooping of optimization, using the cut manager Fixbv - A binary fixing heuristicChanging bounds, saving and loading bases, saving and loading start solutions Recurse - A successive linear programming modelIterative solving, modify constraint definitions GoalObj - Archimedian and pre-emptive goal programming using objective functionsMulticriteria optimization, multi-objective decision making Wagon - MIP start solution heuristicLoading MIP start solution, 'solnotify' callback UG - Examples from 'BCL Reference Manual'MIP modeling, error handling, using Xpress Optimizer with BCL Folio - Examples from 'Getting Started'MIP modeling, quadratic constraints, infeasibility handling, solution enumeration
![](images/codefold.png) Examples in Java Chess - Composing constraints and solvingSimple LP problem, termwise constraint definition, LP solving Workshop - Displaying solution informationRetrieving and displaying solution values and ranging information; real value printing format, number output format Contract - Semi-continuous variables, predefined constraint functions, combine BCL with Xpress OptimizerDefining semi-continuous variables, MIP solving Chgprobs - Working with multiple problemsHandling multiple problems Setops - Index setsUsing index sets, set operations Burglar - Use of index sets, formulating logical constraintsIndex an array of variables by an index set, defining indicator constraints Coco - A full production planning exampleData input from text files Delivery - Data input from file; infeasibility analysisLP model, data input from file, retrieving IIS Purchase - Definition of SOS-2Data input from file, using SOS-2 Portfolio - Quadratic Programming with discrete variablesQuadratic objective function Catenary - Solving a QCQPStating quadratic constraints Cutstk - Column generation for a cutting stock problemWorking with subproblems, modifying constraints Els - An economic lot-sizing problem solved by cut-and-branch and branch-and-cut heuristicsLooping of optimization, using the cut manager Fixbv - A binary fixing heuristicChanging bounds, saving and loading bases, saving and loading start solutions Recurse - A successive linear programming modelIterative solving, modify constraint definitions GoalObj - Archimedian and pre-emptive goal programming using objective functionsMulticriteria optimization, multi-objective decision making Wagon - MIP start solution heuristicLoading MIP start solution, 'solnotify' callback UG - Examples from 'BCL Reference Manual'MIP modeling, error handling, using Xpress Optimizer with BCL Folio - Examples from 'Getting Started'MIP modeling, quadratic constraints, infeasibility handling, solution enumeration
![](images/codefold.png) Xpress Mosel examples![](images/codefold.png) Models by problem type / modeling tasks Folio - Modelling examples from 'Getting started'LP, MIP and QP models, data input/output, user graphs, heuristics Folio - Advanced modelling and solving tasksMultiple MIP solutions, infeasibility handling, data transfer in memory, remote execution, XML and JSON data formats, solver tuning Linearizations and approximations via SOS1 and SOS2Piecewise linear, approximation General constraints and Boolean variablesgeneral constraints, boolvar, logctr, Boolean variables, logical expressions Indicator and logic constraintsindicator constraints, logic constraints, logctr, advmod Assignmentsimple LP problem, graphical representation of results Bin packingsimple MIP problem, random generation of data,
use of model parameters, setting Optimizer controls Blending oressimple LP problem, formulation of blending constraints Capital budgetingsimple MIP problem Contract allocationsimple MIP problem, semi-continuous variables,
graphical representation of results Cutting stockMIP problem solved by column generation,
working with multiple problems, using 'sethidden',
setting Optimizer and Mosel control parameters Lot sizingMIP problem, implementation of Branch-and-Cut and
Cut-and-Branch algorithms, definition of Optimizer callbacks,
Optimizer and Mosel parameter settings, 'case', 'procedure',
'function', time measurement Facility locationMIP problem, graphical solution representation,
re-solving with modified bounds, data input from file,
dynamic arrays for data and decision variables, use of
'exists', model cuts Knapsacksimple IP problem, formulation of knapsack constraints,
model parameters, function 'random' Multi-period, multi-site production planningLP or MIP problem, formulation of resource constraints and
material balance constraints, formatted solution printing, if-then-else, if-then-elif statements Project planning with resource constraintsMIP problem, alternative formulation with SOS-1,
tricky formulation of resource use profiles and
calculation of benefits, graphical solution representation Purchasing with price breaksMIP problem, modeling a piecewise linear function with SOS-2,
graphical representation of data Transportsimple LP problem, using dynamic arrays for data and
decision variables, formatted output printing, inline 'if',
format of data files TSPMIP problem, loop over problem solving, TSP subtour
elimination algorithm;
procedure for generating additional constraints, recursive
subroutine calls, working with sets, 'forall-do',
'repeat-until', 'getsize', 'not', graphical representation
of solutions Set coveringMIP problem, modeling an equivalence; sparse data format,
graphical output representation, 'if-then-else' Single period product mixSimple LP problem, single period production planning Personnel requirement planningsimple MIP problem, formulation of balance constraints
using inline 'if' Matching flight crews2 MIP problems with different objectives, data preprocessing,
incremental definition of data array, encoding of arcs,
logical 'or' (cumulative version) and 'and', 'procedure'
for printing solution, 'forall-do', 'max', 'finalize',
graphical representation of results, 'sin', 'cos' Maximum flow in a telecom networkMIP problem, encoding of arcs, 'range', 'exists', 'create',
algorithm for printing paths, 'forall-do', 'while-do',
'round', graphical representation of results Multi-commodity network flowMIP problem, encoding of paths, 'finalize', 'getsize' Vehicle routingMIP problem, formulation of constraints to eliminate
inadmissible subtours, definition of model cuts,
selection with '|', algorithm for printing the tours,
graphical solution representation Minimum cost flowMIP problem, formulation with extra nodes for modes of
transport; encoding of arcs, 'finalize', union of sets,
nodes labeled with strings, graphical solution representation Line balancingMIP problem, encoding of arcs, 'range', formulation of
sequencing constraints Minimum weight spanning treeMIP problem, formulation of constraints to exclude subcycles,
graphical representation of results Flow-shop schedulingMIP problem, alternative formulation using SOS1,
graphical solution representation Job shop schedulingMIP problem, formulating disjunctions (BigM);
'dynamic array', 'range', 'exists', 'forall-do',
graphical solution representation Transshipment formulation of multi-period production planningMIP problem, representation of multi-period production
as flow; encoding of arcs, 'exists', 'create', 'isodd',
'getlast', inline 'if' Set partitioningMIP problem, algorithm for data preprocessing; file
inclusion, 3 nested/recursive procedures, working with
sets, 'if-then', 'forall-do', 'exists', 'finalize' Open shop schedulingMIP problem, data preprocessing, algorithm for preemptive
scheduling that involves looping over optimization,
''Gantt chart'' printing and drawing Sequencing jobs on a single machineMIP problem with 3 different objectives; 'procedure'
for solution printing, 'if-then' Timetable for courses and teachersMIP problem, many specific constraints, tricky (pseudo-)
objective function, 'finalize' Basic LP tasks: problem statement and solving; solution analysisLP solving, solution printout, array and set data structures Basic MIP tasks: binary variables; logic constraintsMIP solving, binary variables, index set types, logic constraints LCSP: Labour constrained scheduling problemDynamic creation of variables, formulation of resource constraints Transportation problem with piecewise linear cost expressionsMIP problem Approximating nonlinear univariate functions via piecewise linear constraintsMIP problem MAXSAT solving via MIPMAXSAT model Conditional creation of decision variablesuse of 'exists', finalization of index sets Delivery: Infeasibility analysis with IISRetrieving and displaying IIS Overview of Mosel examples for 'Business Optimization' bookLP, MIP, NLP problem formulations, solution reporting, graphical display, multiple problems, iterative solution algorithms
![](images/codefold.png) Models by application area Introductory examples Mining and process industries Scheduling problems Planning problems Loading and cutting problems Ground transport Air transport Telecommunication problems Economics and finance Timetabling and personnel planning Local authorities and public services
![](images/codefold.png) Programming with Mosel Dynamic package loadingdynamic package loading, model compilation, BIM file Recursive remote filesAccess to files on remote (parent or
child) nodes Basic set operationsInitializing sets, set operations, set comparison Using moseldocGenerating online documentation for Mosel models and packages Largest common divisorRecursive function calls; using 'readln' Smallest and largest value in a setThe 'if-then-elif-then' selection statement Perfect numbersUsing the 'forall' loop Prime numbers using the Sieve of EratosthenesNested loops: repeat-until, while, while-do Read two tables and a set from a text data fileFile access, using 'readln', 'fskipline' Parsing a CSV-format data fileText parsing functionality Sort an array of numbers using Shell's methodNested loops: repeat-until, forall-do, while-do Sort an array of numbers using QuicksortRecursive subroutine calls, overloading of subroutines Defining a package to handle binary treesDefinition of subroutines, data structures list and record, type definition Encapsulate binary file into a BIMSubmodel included in model source, datablock, deployment as executable Generate an executable from a Mosel source filedeployment as executable, deployment via scripts Using the automatic translation systemUsing xprnls, generating dictionary files Debugging models via the Remote Invocation ProtocolRemote model execution in debugging mode, implementation of a debugger Profiling and code coverage via the Remote Invocation ProtocolRemote model execution in profiling mode, decoding of profiling and coverage results Creating and saving XML documentsSimple access routines - adding nodes, recursive display of subtrees Using XML-format files as databasesRetrieving XML nodes using xpath search expressions; modifying and formatting XML files Parsing XML and JSON documentsParsing documents with unknown structure Converting WCNF to Mosel formatProcessing a text file into a different text format, generating Mosel code, deployment as executable Defining a package to read JSON documents of unknown structureDefinition of subroutines, data structures of union types, type definition, JSON parsing Error handlinghandling I/O errors during data input Using countersUsing and combining 'count' and 'as counter' Using countersLocal declaration of entities, array aliasing Working with arraysarray initialization, indexation, sparse array, array dimensions, array size Working with listsLists: initialization, enumeration, operators, access functions Eulerian circuit - working with listslist operators, list handling routines Working with recordsDefining and initializing records Definition of a networkWorking with record data structures User type definitionDefining a user type with a record Working with unionsdefining unions, type any, specifying union type, initialization of unions from/to text format files, reference to operator SubroutinesSubroutine definition, overloading, recursive function calls, function return values, variable number of arguments, subroutine references, mmreflect Output formattingreal number format, text formatting Using the debugger and profilerDebugging and profiling commands, parallel debugging Checking memory usageUsing sparse arrays, dynamic array, ahsmap array Writing packages: definition of constant symbols, subroutines, types, and parametersImplementing subroutines, overloading, using packages Namespace definitionImplementing packages, defining namespaces, namespace search, namespace groups Package version managementImplementing packages, version management, deprecation, annotations Text handling and regular expressionsTypes 'text', 'textarea', 'parsectx'; text parsing Defining and retrieving annotationsAccessing annotations from a model or host application Using documentation annotationsUsing documentation annotations, moseldoc tool Using 'exists' for loops over sparse arraysEnumeration of sparse data, exists Parameters: tolerancesComparison tolerance Using the model return value for error handlingModel exit code Preprocessing Mosel codePreprocessing source code, preprocessor symbol, positioning markers
![](images/codefold.png) Solving techniques Using the AEC2 package with mmjobsFind or start AEC2 instance, start Mosel, model execution Column generation for a cutting stock problemVariable creation, using 'sethidden', working with multiple problems Cut generation for an economic lot-sizing (ELS) problemAdding constraints and cuts, using the cut manager, run-time parameters Binary fixing heuristic for the Coco problemWorking with bases, saving and loading MIP solutions Branch-and-Price for the Generalized Assignment ProblemWorking with submodels, record data structures Pre-emptive and Archimedian goal programmingChanging constraint type, redefining the objective Using multi-objective solvingMultiple objectives, configuration of objectives Successive linear programming (SLP) model for a financial planning problemRedefinition of constraints Output formatting for a transportation modelDynamic arrays for data and decision variables, formatting output Solving an optimization problem via nlsolvUsing module nlsolv Cut-and-branch and branch-and-cutUsing the optnode callback or the cut manager callback, addcuts, storecuts and loadcuts, subroutine reference Hybrid MIP-CP problem solving: sequential solvingSolving a sequence of CP subproblems, in-memory data exchange Hybrid MIP-CP problem solving: concurrent solvingParallel and sequential solving of subproblems MIP start solutions and subtour elimination algorithm for the traveling salesman problem (TSP)CP target values, MIP start solution, MIP callbacks, cutting plane algorithm Working with multiple models: submodels, coordination, communication, and parallelizationParallel computing, distributed computing, distributed architecture, in-memory data exchange, shmem, job queue, events, detach submodel, clone submodel Dantzig-Wolfe decomposition: combining sequential and parallel solvingConcurrent subproblem solving, coordination via events, in-memory data exchange, mempipe, mempipe notifications, remote mempipe Benders decomposition: sequential solving of several different submodelsMultiple concurrent submodels, events, in-memory data exchange Jobshop scheduling - Generating start solutions via parallel computationSequential and parallel submodel execution, loading partial MIP start solutions, model cloning, shared data Outer approximation for quadratic facility location: solving different problem types in sequenceIterative sequential submodel solving, nonlinear subproblem, MIQP formulation Solving the TSP problem by a series of optimization subproblemsSolution heuristic, parallel submodel execution Looping over optimization runs (within a model, batch executions, and multiple models/submodel)Multiple problem runs, submodel Names handling for decision variables and constraintsNames generation, variable name, constraint name, location information, compilation options, loading names, public declaration Using Optimizer Console for running matrices within Moselmmxprs command, Xpress Solver command line, running matrix file Evolutionary algorithm for supply managementEvolutionary algorithm, iterative LP solving Lagrangian Relaxation for a Generalized Assignment ProblemWorking with subproblems, iterative LP solving News Vendor Problem2-stage stochastic program, scenario-based robust optimization Multi-stage stochastic portfolio investmentIterative submodel runs, in-memory data exchange Sludge production planning solved by recursionIterative solving, recursion, SLP
![](images/codefold.png) Nonlinear optimization with Mosel Locate airport while minimizing average distancequadratic constraints and objective Maximise discount at a bookstoreDiscrete variables Nonlinear objective with integer decision variablesDiscrete variables Determine chain shapeQuadratic constraints Facility locationNonlinear objective Approximation of a functionApproximation of a function Maximal inscribing squareTrigonometric functions Static load balancing in a computer networkNonlinear objective Minimum surface between boundariesNonlinear constraints and objective Moon landingNonlinear objective and constraints Polygon construction under constraintsTrigonometric constraints and objective Portfolio optimizationQuadratic constraints and quadratic objective Locating electrons on a conducting sphereNonlinear constraint and objective, alternative objective functions Find the shape of a chain of springsQuadratic constraints Steiner tree problemQuadratic constraints Trafic equilibriumNonlinear objective Modeling hang glider trajectoryNonlinear constraints, trapezoidal discretization Force required to lift an objectSOCP formulation Convex hull of two trianglesTrigonometric constraints, graphical representation Optimal number and distribution of grid points for a nonlinear functionDiscretization, GNUPlot graphic, subroutine references Nonlinear trimloss problemNLP, alternative solvers
![](images/codefold.png) Robust optimization with Mosel Introductory examplesDefining robust constraints, uncertainty sets, nominal values Robust formulations of the single knapsack problemTypes of uncertainty sets Robust portfolio optimization'ellipsoid' uncertainty set, retrieving the worst value of an uncertain Security constrained robust unit commitment'scenario' and 'cardinality' uncertainty sets Production planning under demand uncertainty'scenario' and polyhedral uncertainty sets Production planning under energy supply uncertaintypolyhedral uncertainty set Robust shortest path'cardinality' uncertainty set Robust network optimization for VPN designpolyhedral uncertainty set
![](images/codefold.png) Data handling ( ODBC/SQL, sparse data, I/O drivers, Spreadsheets ) Energyforecast - regression analysis with RRegression analysis, data exchange with R, evaluating R functions from Mosel Logistic regression on flight delay data using RLogistic regression, data exchange with R, evaluating R functions from Mosel, graph drawing with R Blend - data input from external sourcesAccessing data sources (text, spreadsheets, databases) Output of expressionsUsing 'initializations to' with 'evaluation of' Transport - data formats for online useXML and JSON data formats, generation of HTML Reading sparse data from text files, spreadsheets and databases, and from memoryData input, initializations from, SQL, ODBC, spreadsheet, CSV Data output to text files, spreadsheets and databases, and to memoryData output, initializations to, SQL, ODBC, spreadsheets, CSV Dataframe formatsdataframe, union types, CSV format Dense vs. sparse data formatarray types, noindex Auto-indexation for single-dimensional arraysauto-indexation Writing out solution values to text files, spreadsheets or databasessolution data output, 'evaluation of' Spreadsheets and databases: working with multiple data tables and arraysdata input/output, multiple tables, multiple data arrays Formulation of SQL (selection) statementsAdvanced SQL functionality, retrieve database and table structure Reading and writing records and listsrecord data structure, list data structure Reading and writing union typesTypes any, date, time; data input/output Reading and writing dates and timesdata types date, time, datetime Reading 3-dimensional arraysMultidimensional array input, option partndx Burglar - Data source access from Mosel models'mmodbc.odbc', 'mmsheet.excel', 'mmetc.diskdata' I/O drivers, SQL, XML, JSON Burglar - In-memory data exchange between Mosel models'bin', 'shmem', 'raw', 'text', 'tmp', 'rmt' I/O drivers
![](images/codefold.png) Graphing examples MandelbrotQueued execution of remote models with result
graphic Drawing results of multiple optimization runsIterating over MIP solves, graphical representation of solution values Drawing line fractalsLines with simple styling, recursive subroutine calls Drawing line plotsPoints and polylines with various styling options Drawing a bar chartGraphical objects rectangle and text, simple styling Drawing a pie chartGraphical objects pie and text, simple styling Drawing a Gantt chartGraphical objects rectangle and text, simple styling, reading free-format input text data file, animation Iterative display of toursPoints and polylines, pausing display, intercepting window closing, animation, image inclusion Display matrix scaling informationRetrieving matrix coefficient ranging information, getscale, SVG graph drawing
![](images/codefold.png) Distributed calculation and remote invocation Using the AEC2 package with XPRDFind or start AEC2 instance, start Mosel, model execution Reading and writing data using the 'bin:' formatBinary data format Implementing a file managerRemote model execution, file manager, events Approximating PI numberRemote execution of multiple Mosel models Runprime - Remote model executionRemote model execution, data exchange between remote nodes Basic tasks: remote connection, coordination, communication, and parallelizationDistributed computing, concurrent submodel execution, job queue, events ELS - Solving several model instances in parallelParallel execution of submodels, parallel execution of submodels, stopping submodels Mandelbrot - Java GUI for distributed computation with MoselParallel execution of submodels, Java solution graph Folio - remote execution of optimization modelsSubmodel execution, events, bindrv binary format, in-memory data I/O
![](images/codefold.png) C Library examples Folio - Embedding examples from 'Getting started'Model compilation, parameterized model execution, matrix output, accessing results Compiling a model file into a BIM fileModel compilation Retrieving data from a Mosel modelAccessing sets, arrays, lists, records; retrieving solution information Working with models and accessing dynamic libraries in MoselDisplay information and contents of models and libraries Interrupting a running model using Ctrl-CStopping a model run Data input/output via I/O driversCompilation to/from memory; data input/output in memory; redirect output using the 'cb' driver Implementing a source coverage testing toolUsing the debugger interface Basic embedding tasksCompile/load/run models, retrieve information about model objects, redirect model output In-memory data exchangeData exchange during model execution Switching to solving with Xpress OptimizerUsing the Xpress Optimizer library with Mosel Compilation to/from memoryUsing the 'mem' I/O driver Burglar - Exchange of information with embedded models'cb', 'bin', 'mem', 'raw', 'sysfd' I/O drivers
![](images/codefold.png) Java Library examples Folio - Embedding examples from 'Getting started'Model compilation, parameterized model execution, matrix output, accessing results Retrieving data from a Mosel modelAccessing sets, arrays, lists, records; retrieving solution information Working with models and accessing dynamic libraries in MoselDisplay information and contents of models and libraries Data input/output via I/O driversCompilation to/from memory; data input/output in memory; redirect output using the 'java' driver Implementing a source coverage testing toolUsing the debugger interface Basic embedding tasksCompile/load/run models, retrieve information about model objects, redirect model output In-memory data exchangeData exchange during model execution Compilation to/from memoryUsing the 'java' I/O driver
![](images/codefold.png) VBA Library examples Folio - Embedding examples from 'Getting started'Model compilation, parameterized model execution Folio - Embedding examples from 'Getting started'Parameterized model execution, data exchange in memory Launching Mosel from Excel using VBALP solving, start Mosel from a VBA script in Excel, data input from Excel Start/stopping Mosel from Excel and capturing outputMIP solving, start and interrupt Mosel from a VBA script in Excel, Mosel output to Excel Basic embedding tasksCompile/load/run models, redirect model output
![](images/codefold.png) C#.NET Library examples Folio - Embedding examples from 'Getting started'Model compilation, parameterized model execution, matrix output, accessing results Retrieving data from a Mosel modelAccessing sets, arrays, lists, records; retrieving solution information Working with models and accessing dynamic libraries in MoselDisplay information and contents of models and libraries Data input/output via I/O driversCompilation to/from memory; data input/output in memory Basic embedding tasksCompile/load/run models, retrieve information about model objects, redirect model output In-memory data exchangeData exchange during model execution Compilation to/from memoryUsing C#
![](images/codefold.png) VB.NET Library examples Working with models, data and dynamic libraries in MoselAccessing sets and arrays; retrieving solution information; displaying information and contents of models and libraries; Compilation to/from memory; data input/output in memory
![](images/codefold.png) Writing Mosel modules Definition of constants of different typesDefining integer, real, string, boolean constants Definition of a procedure for getting solution values into an arrayImplementing a subroutine Definition of complex numbers and operators to work with themDefining an external type with operators Definition of type 'task' and subroutines for accessing itDefining an external type with operators and access routines; defining module parameters and services Definition of type 'date' and subroutines for accessing itDefining an external type with operators and access routines; defining module parameters and services Definition of three new types and operators to work with themDefining external types with operators Basic LP/MIP solver interface for Xpress OptimizerUsing the NI matrix handling functionality, extending a type, defining parameters and subroutines, defining a callback function Basic QCQP solver interface for Xpress OptimizerUsing the mmnl matrix handling functionality, extending a type, defining parameters and subroutines, defining a callback function Declaring a static moduleModule embedded in a C program Using the 'zlib' library to provide IO driver 'compress' functionalityDefining I/O drivers Module implementing driver 'toC' to save the compilation result to a C fileDefining an I/O driver How best to debug a moduleCreating a static module
![](images/codefold.png) Calling static Java methods from Mosel Passing single values from a Mosel model to a Java method Passing an array from a Mosel model to a Java method Returning an object from a Java method Handling exceptions thrown by a Java method called from a Mosel model
![](images/codefold.png) Calling Python 3 from Mosel Portfolio optimization using pandas to calculate covariance Invert a Mosel matrix with NumPy Python I/O driver example
![](images/codefold.png) Puzzles and Recreational Mathematics Sudoku (CP and MIP models)Using 'all_different', enumerating all feasible solutions, SVG graphs showing progress of solving Futoshiki (CP and MIP models)Using 'all_different', formatted solution printout Fantasy OR: Sangraal (CP and MIP models)Formulation of a scheduling problem with MIP and CP Fiveleaper (MIP model and graphics)Subtour elimination algorithm Puzzles and pastimes from the book `Programmation Lineaire'MIP and CP formulations for discrete feasibility problems
![](images/codefold.png) Xpress Optimizer examples![](images/codefold.png) Calling the Optimizer library from C Folio - Introductory examples from 'Getting Started'LP, MIP and QP models, explicit initialization, index sets, heuristic solution The travelling salesman problemUsing Xpress callbacks Branching rule branching on the most violated Integer/BinaryUsing the change branch callbacks Apply a binary fixing heuristic to an unpresolved MIP problemChanging bounds, accessing solver controls Perform objective function parametrics on a MIP problemSaving/loading bases, changing objective coefficients Perform RHS parametrics on a MIP problemChanging RHS coefficients, working with bases Apply a primal heuristic to a knapsack problemUsing the MIP log callback Apply an integer fixing heuristic to a MIP problemChanging bounds Load an LP and modify it by adding an extra constraintLoad LP problem, adding a constraint Save/access a postsolved solution in memoryRetrieving solution values and tree search information Adding MIP solutions to the OptimizerUsing the optnode callback, saving/loading bases, changing bounds Solve LP, displaying the initial and optimal tableauRetrieve basic variables and their names, btran Modify problem: add an extra variable within an additional constraintAdding rows and columns, branching directives 10 best solutions with the MIP solution enumeratorUsing the solution enumerator and MIP solution pool Collecting all solutions with the MIP solution poolUsing the solution enumerator and MIP solution pool Repairing infeasibilityUsing repairinfeas Goal programmingLexicographic goal programming using the Xpress multi-objective API
![](images/codefold.png) Calling the Optimizer library from Java Folio - Advanced modeling and solving tasks from 'Getting Started'Using the solution enumerator and solution pool Adding the message callback in JavaUsing the message callback Irreducible Infeasible Set SearchUsing IIS 10 best solutions with the MIP solution enumeratorUsing the solution enumerator and MIP solution pool Collecting all solutions with the MIP solution poolUsing the solution enumerator and MIP solution pool Collecting all solutions with the MIP solution poolModify a problem by adding extra rows and columns Goal programmingLexicographic goal programming using the Xpress multi-objective API The travelling salesman problemUsing Xpress callbacks Apply a binary fixing heuristic to an unpresolved MIP problemChanging bounds, accessing solver controls Apply a primal heuristic to a knapsack problemUsing the MIP log callback Load an LP and modify it by adding an extra constraintLoad LP problem, adding a constraint Save/access a postsolved solution in memoryRetrieving solution values and tree search information Adding MIP solutions to the OptimizerUsing the optnode callback, saving/loading bases, changing bounds Solve LP, displaying the initial and optimal tableauRetrieve basic variables and their names, btran Branching rule branching on the most violated Integer/BinaryUsing the change branch callbacks Repairing infeasibilityUsing repairinfeas Apply an integer fixing heuristic to a MIP problemChanging bounds Perform objective function parametrics on a MIP problemSaving/loading bases, changing the objective Perform RHS parametrics on a MIP problemSaving/loading bases, changing right-hand side values
![](images/codefold.png) Calling the Optimizer library from C#.NET The travelling salesman problemUsing Xpress callbacks Apply a binary fixing heuristic to an unpresolved MIP problemChanging bounds, accessing solver controls Irreducible Infeasible Set SearchUsing IIS Apply a primal heuristic to a knapsack problemUsing the MIP log callback Load an LP and modify it by adding an extra constraintLoad LP problem, adding a constraint 10 best solutions with the MIP solution enumeratorUsing the solution enumerator and MIP solution pool Collecting all solutions with the MIP solution poolUsing the solution enumerator and MIP solution pool Save/access a postsolved solution in memoryRetrieving solution values and tree search information Goal programmingLexicographic goal programming using the Xpress multi-objective API
![](images/codefold.png) Calling the Optimizer library from VB.NET Apply a binary fixing heuristic to an unpresolved MIP problemChanging bounds, accessing solver controls Irreducible Infeasible Set SearchUsing IIS Apply a primal heuristic to a knapsack problemUsing the MIP log callback Load an LP and modify it by adding an extra constraintLoad LP problem, adding a constraint 10 best solutions with the MIP solution enumeratorUsing the solution enumerator and MIP solution pool Collecting all solutions with the MIP solution poolUsing the solution enumerator and MIP solution pool Save/access a postsolved solution in memoryRetrieving solution values and tree search information
![](images/codefold.png) Xpress NonLinear examples![](images/codefold.png) Nonlinear C library examples Maximizing the area of a polygon using tokens based inputUsing token lists to express nonlinear formulas Maximizing the area of a polygon using string based inputUsing string based formulas to express nonlinear formulas Providing initial valuesProviding initial values to nonlinear variables Implementing user functions returning their own derivativesImplementing complex user functions returning their own derivatives Implementing the polygon examples as a black box functionImplementing user functions Maximizing the area of a polygon using tokens based input - using a 'map' userfunctionUsing strings to express nonlinear formulas, including a 'map' userfunction Maximizing the area of a polygon using tokens based input - using a 'vecmap' userfunctionUsing strings to express nonlinear formulas, including a 'vecmap' userfunction Maximizing the area of a polygon using tokens based input - using a 'multimap' userfunctionUsing strings to express nonlinear formulas, including a 'multimap' userfunction Maximizing the area of a polygon using tokens based input - using a 'mapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'mapdelta' userfunction Maximizing the area of a polygon using tokens based input - using a 'vecmapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'vecmapdelta' userfunction Maximizing the area of a polygon using tokens based input - using a 'multimapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'multimapdelta' userfunction
![](images/codefold.png) Calling the Nonlinear library from C#.NET Maximizing the area of a polygonUsing strings to express nonlinear formulas Maximizing the area of a polygon using a 'map' userfunctionUsing strings to express nonlinear formulas, including a 'map' userfunction Maximizing the area of a polygon using a 'vecmap' userfunctionUsing strings to express nonlinear formulas, including a 'vecmap' userfunction Maximizing the area of a polygon using a 'vecmapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'vecmapdelta' userfunction Maximizing the area of a polygon using a 'mapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'mapdelta' userfunction Maximizing the area of a polygon using a 'multimap' userfunctionUsing strings to express nonlinear formulas, including a 'multimap' userfunction Maximizing the area of a polygon using a 'multimapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'multimapdelta' userfunction
![](images/codefold.png) Calling the Nonlinear library from Java Maximizing the area of a polygonUsing strings to express nonlinear formulas Maximizing the area of a polygon using a 'map' userfunctionUsing strings to express nonlinear formulas, including a 'map' userfunction Maximizing the area of a polygon using a 'vecmap' userfunctionUsing strings to express nonlinear formulas, including a 'vecmap' userfunction Maximizing the area of a polygon using a 'vecmapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'vecmapdelta' userfunction Maximizing the area of a polygon using a 'mapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'mapdelta' userfunction Maximizing the area of a polygon using a 'multimap' userfunctionUsing strings to express nonlinear formulas, including a 'multimap' userfunction Maximizing the area of a polygon using a 'multimapdelta' userfunctionUsing strings to express nonlinear formulas, including a 'multimapdelta' userfunction
![](images/codefold.png) Mosel examples of the Xpress NonLinear manual Effects of convexityConvexity Partial derivativesNumerical differentiaton Local solutionsLocal optimality Dual multipliersDual multipliers Non-connected feasible regionNon-connected feasible regions Feasiblity breakers \ penalty error vectorsFeasiblity breakers Error costs and penalty multipliersPenalty multipliers Solution support setsSupport sets Step boundingStep bounding Zero placeholdersZero placeholders
![](images/codefold.png) Xpress Python examples![](images/codefold.png) Python examples solving problems using the Xpress Optimizer Using NumPy arrays to create variablesUsing NumPy arrays Visualize the BB treeUsing the newnode callback Irreducible Infeasible SetsUsing Irreducible Infeasible Sets Loading a problemLoading a problem directly Using Python model objects to build a problemModelling using Python objects Using Python model objects to build a problemModelling using Python objects Changing the optimization problemChanges to a problem Extending a problemExtending a problem Using NumPy and XpressUsing NumPy and Xpress Finding an LP subsystem with as many constraints as possible Basis and StabilityBasis handling and sensitivity methods Solving a quadratically constrained problemBuilding quadratic expressions Solving a nonconvex quadratic problemBuilding quadratic expressions Solving a quadratically problemBuilding quadratic expressions Repeatedly solving a problemSolving a problem multiple times Using indicatorsModel with indicators The travelling salesman problemUsing Xpress callbacks Solving a TSP using NumPyUsing Xpress callbacks Writing and reading problem filesWriting and reading a problem to disk The feasiblity pumpWriting and reading a problem to disk Knapsack problemMIP problem with binary variables The n-queens problemPuzzle modeling Min-cost-flow problemModelling a graph problem Solving SudokuPuzzle modeling Comparing MatricesCompare two optimization problems Multicommodity flow problemSolve a multicommodity flow minimum cost optimization problem on a randomly created graph Find largest-area inscribed polygon Read problem data into matrix and vectors Solve a nonconvex MIQCQP problem Solve a simple MIP using Benders decomposition Create a problem with piecewise linear functions Use the API to create a model with piecewise linear functions Create a problem with general constraints that use operator abs Create a problem with general constraints with the operator abs by using the API Create a problem with general constraints that use operator max Create a problem with general constraints with operator max by using the API Create a problem with logical constraints Create a problem with general constraints with logic operators by using the API Create an iterative algorithm cutting stock problem Maximize the sum of logistic curves subject to linear and piecewise linear constraints Transportation problem with piecewise-linear costs Modeling Satisfiability (SAT) problems with MIP Modeling PseudoBoolean Optimization problems with MIP Re-solving problem using the Barrier method's warm start Using the tuner functions in the Python interface Multi-objective knapsack problemMulti-objective MIP problem with binary variables Goal programmingLexicographic goal programming using the Xpress multi-objective API Markowitz portfolio optimizationMulti-objective quadratic optimization Basic LP tasks: problem statement and solving; solution analysisLP solving, modeling variables and constraints, printing the solution Network problem: transport from depots to customersLP solving, modeling variables and constraints Blend: A model for mineral blendingsimple LP problem, formulation of blending constraints Basic MIP tasks: binary variables; logic constraintsMIP solving, binary variables, index set types, logic constraints Coco: The Coco productional planning problemLP problem, formulation of resource constraints and
material balance constraints, formatted solution printing Catenary: Determine chain shapeQCQP problem Pplan: A project planning problemFormulation of resource use profiles
![](images/codefold.png) Python examples solving problems using Xpress NonLinear Modeling with user functionsModeling with user functions Solving a quadratically constrained problemSolve a nonlinear problem Solve a polynomial optimization problemModeling a polynomial optimization problem
![](images/codefold.png) Xpress R Interface examples![](images/codefold.png) R examples solving problems using the Xpress Optimizer Load and solve a simple 2x2 linear programxprs_loadproblemdata, displaying a solution as a data frame, a simple pipe workflow Formulate and solve a Facility Location Problemxprs_loadproblemdata, writeprob, setoutput, xprs_optimize, xprs_getsolution Solve an LP and a MIP using Xpress-Rxprs_loadproblemdata, getintattrib, getdblattrib, readprob, getmipsol, xprs_getsolution Read and write problems to and from standard formats MPS and LPreadprob, setintcontrol, writeprob Set controls of Xpressreadprob, setintcontrol, setdefaultcontrol, getintattrib, getdblattrib, setdefaults, dumpcontrols Query Attributes of Xpresscreateprob, readprob, printing, getintattrib Add indicator constraintscreateprob, readprob, mipoptimize, xprs_getsolution, addrows, setindicator Register an R function as callback into Xpressreadprob, getintattrib, addcboptnode, addcbintnode, getdblattrib Formulate a quadratic optimization problem in Xpressxprs_loadproblemdata, writeprob, xprs_optimize Solving different types of Sudokus with the FICO Xpress Optimizerxprs_loadproblemdata, addrows, getmipsol, mipoptimize Modeling Sudokus creating columns and rows incrementally using xprs_newcol and xprs_addrowcreateprob, setprobname, chgbounds, xprs_newcol, xprs_addrow, xprs_newrow, setoutput, getmipsol, mipoptimize Solve Traveling Salesperson Problems using callbacks or delayed rowsxprs_loadproblemdata, addrows, addcuts, addcboptnode, addcbpreintsol, getlpsol, loaddelayedrows Solve a maximum flow problem and visualize the resultcreateprob, chgobjsense, setprobname, xprs_newcol, chgobj, xprs_addrow, xprs_getsolution Solve a modified bin packing problem with the addition of a simple greedy heuristicaddmipsol, createprob, xprs_newcol, xprs_newrow, xprs_getsolution Solve a routing problem using an arc-paths formulation for a telecommunication networkcreateprob, chgobjsense, xprs_newcol, xprs_addrow, xprs_getsolution Solve a production planning problemcreateprob, chgbounds, xprs_newcol, xprs_newrow, xprs_getsolution Model a piecewise linear function using binary variablescreateprob, chgbounds, xprs_newcol, xprs_addrow, xprs_getsolution Optimize a composition of investment portfolios using semi-continuous variablescreateprob, chgcoltype, chgglblimit, chgrhs, chgobjsense, xprs_newcol, xprs_newrow, xprs_getsolution Find an optimal schedule of jobs on different machines and visualize the result in ggplot2createprob, setprobname, xprs_newcol, xprs_newrow, xprs_addrow, setoutput, getdblattrib, xprs_getsolution Solve two related problems assigning pilots to crews under different constraintscreateprob, chgobjsense, chgobj, setprobname, xprs_newcol, xprs_addrow, setoutput, xprs_getsolution Solve a timetabling problem for college courses under various constraintscreateprob, chgbounds, chgobj, setprobname, xprs_newcol, xprs_newrow, setoutput, xprs_getsolution Solve a small production problem with 2 products and 2 resource constraintscreateprob, chgobjsense, setprobname, xprs_newcol, xprs_addrow, setoutput, xprs_getsolution Solve a minimum cost flow problem in a bipartite graphcreateprob, setprobname, xprs_newcol, xprs_addrow, setoutput, xprs_getsolution Modeling a piecewise linear objective function using SOS2 constraintscreateprob, setprobname, addsets, getdblattrib, xprs_newcol, xprs_addrow, setoutput, xprs_getsolution Infeasibility and IIS Detectioncreateprob, getiisdata, getintattrib, iisall, iisstatus, iisisolations, xprs_newcol, xprs_newrow, xprs_optimize Basis and Stabilitybndsa, createprob, getbasis, getnamelist, loadbasis, objsa, rhssa, writebasis, writeslxsol, xprs_getsolution, xprs_newcol, xprs_newrow, xprs_optimize Using the Tunercreateprob, setoutput, readprob, setintcontrol, tune, tunerreadmethod, tunerwritemethod, xprs_optimize Goal programmingcreateprob, setoutput, xprs_newcol, xprs_addrow, chgobj, chgobjn, setobjintcontrol, setobjdblcontrol, xprs_optimize, getintattrib, getmipsol
![](images/codefold.png) Xpress Kalis examples![](images/codefold.png) Xpress Kalis Mosel features Generic binary and n-ary constraintsMosel subroutine implementing a constraint relation Table constraint: solving a binpacking problemConstraint definition via value tuples, optimization All-different constraint: solving an assignment problemConstraint definition, check for feasible solution 'abs' and 'distance' constraintsConstraint definition 'distribute' and 'occurrence' constraintsConstraint definition, check for feasible solution, cardinality constraint One- and two-dimensional 'element' constraintsConstraint definition Implication and equivalence constraintsConstraint definition Conjunctions and disjunctions (logical 'and' and 'or')Constraint definition 'cycle' constraint: formulating a TSP problemConstraint definition, solution callback, branching strategy 'cumulative' and 'disjunctive' constraints for scheduling and planning problemsScheduling with resource constraints 'producer_consumer' constraints: solving a resource-constrained project scheduling problemConfiguring resource and task objects, scheduling solver Resource profilesAlternative resources, non-constant resource usage profiles Minimum and maximum constraintsConstraint definition, constraint posting, cpvarlist Defining, posting and propagating linear constraintsAutomated propagation, automated post, explicit post, scalar product, dot product Non-linear constraints over real-valued decision variablesBranching strategy for cpfloatvar Branching strategiesBranching schemes, enumeration for discrete or continuous variables, tasks, disjunctive constraints Use of callbacks to output the search treeDefinition of branching callbacks Working with 'reversible' objectsSetting and retrieving reversible values, behaviour on backtracking Defining a linear relaxationLP or MIP solving within a CP problem
![](images/codefold.png) Xpress Kalis Mosel User Guide examples Introductory example: constraint handlingAutomated and explicit constraint posting Basic modeling tasks: data input, optimization, enumerationData input from file, solving, branching strategy Production of cane sugarLinear, 'ocurrence', and 'element' constraints Sequencing jobs on a bottleneck machineLinear, 'element', 'disjunctive' constraints Planning of paint productionLinear, 'element', 'implies', and 'all-different', 'element' ,'cycle' constraints Euler knight tour problem'all-different', generic binary, 'cycle' constraints Frequency assignment problem'abs', 'distance', and 'all-different' constraints; branching strategy, solution callback Choice of locations for income tax officesLinear, 'element', 'occurrence', 'equiv' constraints; search strategy Non-linear constraintsDefault bounds, cpfloatvar Personnel planning problem'all_different', 'implies', 'occurrence', and 'distribute' constraints Sudoku puzzle: retrieving status information through parameters'all-different' constraints, propagation algorithm, infeasibility conflict analysis Assigning workers to machines: heuristics and user-defined searchLinear, 'all-different', and 'element' constraints, solution heuristic Working with reversible numbersBranching strategy, reversible numbers, branching callbacks Scenes allocation problem: symmetry breaking'implies', 'distribute', 'maximum' constraints, symmetry breaking Construction of a stadium: project planningScheduling with precedence constraints, task objects Backing up files: scheduling with cumulative resource constraintsCumulative scheduling, task and resource objects Job-shop schedulingTask and resource objects, user search strategy Renewable and non-renewable resourcesProvision/requirement of resource, production/consumption of resource Resource usage profilesResource idle times, 'resusage', alternative resources Linear relaxationsalldifferent' constraint reformulated by linear relaxations, user-defined linear relaxations
![](images/codefold.png) Xpress Kalis Mosel application examples Project scheduling problem with disjunctive resource constraintsScheduling objects, branching strategy Solving the job-shop scheduling problemScheduling objects, solution callback Frequency assignment with polaritySubmodel execution, solution heuristic Resource-constrained project scheduling problemScheduling objects, resource consumption, task modes, RCPSP, MRCPSP, renewable resource, element constraint
![](images/codefold.png) Xpress MATLAB interface examples![](images/codefold.png) Mosel MATLAB interface examples Running Mosel models from MATLABCalling Mosel from MATLAB, data exchange in memory Folio - example from 'Getting started' executed in MATLABExchange model parameters and solution between MATLAB and Mosel Evaluating MATLAB functions from MoselUsing MATLAB functions in Mosel MATLAB using the Mosel Java interfaceCompile/load/run models from MATLAB
![](images/codefold.png) Xpress Cloud examples![](images/codefold.png) S3 Uploading a file to an S3 bucket Downloading a file from an S3 bucket List objects available in an S3 bucket Setting tags on an object in an S3 bucket Querying tags on an object in an S3 bucket
![](images/codefold.png) Xpress Executor Solving a Mosel model using a REST webservice, from Mosel Solving a Mosel model using a REST webservice, from NodeJS Solving an MPS problem using a REST webservice, from NodeJS Solving a non-fixed Mosel model using a REST webservice, from Mosel Solving a Mosel model using the 'executor' package, from Mosel
|