examples

Before you can try out the examples below, you must install xyzOPT on your computer: You need a computer with windows 11. Download the xyzOPT installation file from the download area of this website and run this file for installation.

Download the examples

xyzOPT V 1.0 – examples
xyzOPT V 1.0 – examples
Size: 13.4 KB
Published: May 13, 2025

Download the folder, copy to desktop and unzip. This folder contains two files (a .xls-file and a .xml-file) for each of the three examples described below.

Example 1: a machine scheduling problem

Problem description
Let's take a company that manufactures toilet paper. The company has a number of machines to produce the paper. Each machine can operate in one or more of the following modes: two-ply paper, three-ply paper, four-ply paper. If the mode of a machine is changed, a pause of one time step must be scheduled. The company now receives a certain demand for the different types of paper. The aim of the optimization is to produce the necessary quantity of paper as quickly as possible to meet the demand.
Example
The file machineschedulingproblem.xls can be opened in a table calculation program of your choice. The sheet schedules contains two tables (problem1 and problem2), in which the results of the calculations of xyzOPT shall be inserted later on. 


Problem1 is an instance of the machine scheduling problem, in which the company has three machines: machine1 can work in the modes two-ply or three-ply, machine2 can work in the modes three-ply or four-ply and machine3 can work in the mode three-ply.

Problem2 is another instance of the machine scheduling problem, in which the company has two machines: machine1 can work in the modes two-ply or four-ply, machine2 can work in the modes two-ply or three-ply or four-ply.

Now we want to use xyzOPT to calculate an optimal schedule for each of the two problems, that means to calculate a schedule which minimizes the timesteps needed to produce the given demands and fullfill the side conditions, that a machine can only work in one mode at a time and needs to pause for one timestep, in case the machine is switching to a new mode. For this purpos, first of all, please close the file machineschedulingproblem.xls. 

Calculate an optimal schedule for problem1 with xyzOPT (for beginners)
For this purpos please start xyzOPT and open the model machineschedulingproblem.xml.


The sheet with the name schedule links input data and results between the .xls-spreadsheet and xyzOPT. This link needs to be adjusted: double-click on schedule; a dialog opens; select folder and choose the path to the machineschedlungproblem.xls-file on your system and confirm.

For the given exmaple the problem structure as well as the input data is already configured for problem1: Within the model tree on the left hand side you can see the structure of the problem and by clicking the items in the grid, the data of the chosen item is displayed in the data box on the right hand side. For problem1 in particular, the demand for the different paper types is imported from the .xls file and for each mode of a machine the amount of paper produced per time step, in case the machine is operating in this mode, is configured.

Now please select problem1 within the selectionbox in the top of the application and press the run button next to the selectionbox: the optimization of problem1 is carried out by xyzOPT; the run-dialog opens and informs on the progress of the optimization. In case everything worked out fine, you should end up with the following result:


If you open the file machineschedulingprobelm.xls again, you should see a result.

Since the solution of the problem might not be unique, your solution might differ from the one given above.

Calculate an optimal schedule for problem2 with xyzOPT (for beginners)
Now, please open machineschedulingproblem.xml in xyzOPT, again and select problem2 in the model tree. 

As you can see from the model tree, problem2 still needs to be modelled. So, zoom into problem2 (by double clicking problem2 in the grid). Next please add the two machines machine1 and machine2 (by drag and drop) to the grid and adjust their names. Add the three demand-types somewhere next to the two machines in the grid and also adjust their names. Now zoom into machine1 and add the two modes of machine1 (adjust names) and finally zoom into machine2 and add the three modes of machine2 (adjust names). This should lead to a result like displayed here:

Please save the model before you continue.

It's still necessary to configure the input data of problem2 and to enter the information, where the results are to be written to.

So, first configure the input data of the demands per type of paper: For this purpos please choose the demand demandTwoPly in the model tree and have a look in the databox: The parameter demand needs to be specified, it is to be transferred from the table schedules of machineschedulingproblem.xls at position D5. Since the sheet schedule in xyzOPT points at the table schedules of machineschedulingproblem.xls, you enter schedule(D5) into the textfield of demand. In the field below (labeled by MODES), all modes of all machines, which produce twoPlyPaper, need to be entered by using the dropdownmenu.
In the same way you configure demandThreePly and demandFourPly. 
Please save the model before you continue.

Second, the data of the different modes of the two machines need to be configured. Please choose modeTwoPly of machine1 from the model tree and have a look into the data box: enter the value 8.0 into the textfield of amountOfPaperProducedPerTimestep (which means in case the machine1 is running in modeTwoPly 8.0 pallets of paper are produced per timestep); the results of the problem need to be written to the table schedules of machineschedulingproblem.xls per mode and per timestep; for the modeTwoPly of machine1 this means, the result needs to be written to the positions B17, C17, ..., U17, which is shortly described by B17:U17. Since the sheet schedule in xyzOPT points to the table schedule in the .xls-file, enter schedule(B17:U17) into the textfield producedPaper[TIMESTEPS] of the data of the modeTwoPly of machine1.
In the same way you configure the other modes of the two machines. In my example, I have chosen the following values for the amountOfPaperProducedPerTimestep:
machine1.modeTwoPly    8.0
machine1.modeFourPly   6.3
machine2.modeTwoPly    8.2
machine2.modeThreePly  7.8
machine2.modeFourPly   6.1
Please save the model before you continue.

Now it should be possible to run the problem. For this purpos select problem2 within the selectionbox in the top of the application and press the run button next to the selectionbox: the optimization of problem2 is carried out by xyzOPT; in case everything worked out fine, the results should be written to machineschedulingproblem.xls; running problem2 on my computer led to the following result:

Example 2: a room assignement problem

Problem description
Suppose a school has a number of teachers, a number of courses to be taught by the teachers, and a number of rooms in which the courses are to be taught. It is already determined which teacher teaches which course, but each course must be assigned to a room. If a course comprises more than one lesson, each lesson of the course should be taught in the same room if possible.
Example
Let's assume that five teachers at a school teach a series of courses that are to be allocated to the rooms room1, room2 and the sportshall. The figure below illustrates the problem in xyzOPT.

Running exampleschool on my computer led to the following result:



Example with an additional rule: Certain courses require a projector in the room (for specialists in optimization theory)
Now look again at the example above and please open the model roomassignementproblem.xml within xyzOPT. Now assume that the french and poems courses require a projector and only room1 has a projector. The following instructions describe how to add this rule to the model in xyzOPT:

Step 1: add the information whether a room has a projector to the model
For this purpos please open the blockeditor for the block room (double click on the block room) and add the line
P: hasprojector = ...;
to the code and confirm with apply.

Now, if you choose room1 in the model tree, a new textfield (hasprojectbeamer) should be displayed in the databox. Please enter 1.0 (that means, the room has a projector). Continue and choose the rooms room2 and sportshall and enter 0.0 (which means, room2 and the sportshall don't have a projector).
Please save the model before continuing with step 2.
Step 2: add the information whether a course needs a projector
For this purpos please open the blockeditor for the block course (double click on the block course) and add the line
P: needsprojector = ...;
to the code and confirm with apply.

Now, if you choose french or poetry in the model tree, a new textfield (needsprojectbeamer) should be displayed in the databox. Please enter 1.0 for both of the courses (meaning they need a projector). The other courses (all sportscourses, the drawing courses an the spanish course) don't need a projector, so please enter 0.0 for each of these courses.
Please save the model before continuing with step 3.
Step 3: open the blockeditor for roomassignement and add the following line to the end of the code:
roomassc8: FORALL(c IN courses, r IN rooms, d IN days, h IN hours)DO c.needsprojector * xroomass[c,r,d,h] <= r.hasprojector * xroomass[c,r,d,h];
Please confirm with the apply-button.

Please save the model before continuing with step 4.
Step 4: run the problem
Please choose exampleschool and run the problem. The new reults should be written to roomassignement.xls. Running it on my computer led to the following result:

Example 3: choose a pokerhand

Problem description
Consider a classical poker game with 52 cards, in which each player gets a seven-card-stud from which he needs to choose the best five-cards-hand. The problem to choose the best five-cards out of seven cards, is modelled here.
Examples
Please have a look at the table data within pokerhand.xls:

In the cells B2:H2 you can enter the ranks of each of the seven cards and in the cells B3:H3 you can enter the suits. The result of the optimization is written to A1 and to B4:H4: A1 displays the value of the chosen combination according to the table in the bottom and B4:H4 shall contain five ones and two zeros; in case one of this cells (for example C4) contains a 1.0, this is interpreted such way, that this card is chosen (e.g. card2 is chosen), and it contains a 0.0 otherwise.

Now, please have a look at pokerhand.xml in xyzOPT:

The objective function is modelled within the block poker and ranks the switched-on combinations and additionally, if necessary according to the chosen combination, it's also decided on the best kickers.

You find each of the seven cards within the xyzOPT model and for each card the rank and the suit is imported from pokerhand.xls.

Each available combination is modelled by an item derived from a specfic block. Within these blocks the rules are modelled.

An optimal choice of five cards is calculated by choosing poker and transferred to pokerhand.xls.

Running poker on my computer led to the following result:

The 6.0 displayed in the cell A1 indicates, that a full house is chosen.

Now, we switch off the full house option by inserting the value 0.0 into the cell C13 and run the problem in xyzOPT again. This led me to the following result:

In this case, the combination full house is not available anymore, so the optimization leads to the next best combination, which is to choose the three kings (as three of a kind) and the ace and the jack as the two best possible kickers for this combination.