An output item is a list of strings, and basically it's going to take that list of

strings, concatenate them all together, and send them to the output.

There can be at most one output segment in the model.

And if there's no output segment, then all the declared variables in the model

that aren't equated to a right-hand side expression will be output as assignments.

So what's that mean?

Let's have a look at this model.

We've got three decision variables x, y and z.

But y was equated to a value when we declared it.

So the output will only include the values for x is 3 and z is 1.

So that's the solution for these constraints.

And notice the output is basically uniform,

which could be used as a MiniZinc dataform.

So we can do more complicated outputs.

So for example,

if you want to output a multi-dimensional array like this one here, a.

We'd like to show it in two dimensions, so we might use show_int 2 to make sure

that the sizes of each of these numbers are the same.

And we're going to do this extra thing, because when j is 3, so

when we get to the end of each row, we're going to add a new line.

Otherwise, we're going to have a space.

So basically, we're going to add the space between each two elements in the row,

and add a newline at the end.

And if you think about what this whole thing, this creates, is this.

So we've got space 5, which is showing the 5.

And then a space added by this if then else endif statement.

Then space 3, which is the result of this, and

the space added by this statement here.

Then 12, which is the show_int of 12.

And then a new line added by this statement.

And then some more space, 6, space, there's 2, space, there's 0, new line.

It's just going to print out like that, a nice aligned array.

So in output statements, every expression which isn't wrapped in show or

one of its variants, which is like show_int, show_float,

interpolated strings, has to be fixed.

So basically, once we get to the output, the solver needs to have already run,

we can't have any variables which aren't known to be fixed.

So we can ensure the variable's fixed using this fix built-in function.

So fix takes an expression, and it aborts if the expression does not have a fixed

value, and otherwise returns the fixed value.

So basically, this is mainly useful in output.

You can use it in general in models otherwise, but

usually it's either always going to abort or do something unuseful.

So if we look at this model here, we've got two variables, x and y,

which we're using.

So we're only showing this i, which is a parameter anyway, so

there's no problem there.

But we're using x and y here, and these are variables.

So basically, we're testing against the variable.

So in order for the output to be satisfied to know that it won't need to ask

the solver anything about this expression, we need to make sure that we actually wrap

these uses of variables by this fix x and fix y.

And of course, by the time we hit here, the solver has run, and

x should have a fixed value and y should have a fixed value in all cases.

And so this will always pass.

So basically, this fixes telling the output statement, or

MiniZinc that the output statement, that these values will be used in a fixed way.

We can take a little bit more complicated examples of output.

So imagine we had some tasks, and we had some starts and duration.

And presumably,

one of these would have been presumably a variable that's been solved by the solver.

We want print out a sort of, showing a graphical example of our output.

So we can print out the name and colon, and

then we could print out a number of spaces to get us to the column of the start time.