Welcome to the reference section on Command Line Interface. So, the course is designed to be undertaken using the IDE, but some people prefer to use the command-line interface. And, indeed, if you're going to solve real world problems using MiniZinc, you don't want to do that through the IDE, you want to be able to use IDE in your tool chain. So basically this is information about how to use MiniZinc in the command line. So before we go into how to use it, let's look inside the MiniZinc tool chain, a little bit to see what actually goes on inside MiniZinc. So we start with our model and some data. And there's also some global definitions, which How your solver handles the global. All those are taken by the translator, which translates from MiniZinc to FlatZinc, and outputs two things, a FlatZinc model, which is going to be sent to the solver. And a little model that basically reflects the output statement, which is going to be used to process the output later on. The flat seat model goes to the solver, and it returns a solution, and then that solution together with this [INAUDIBLE] file goes to another. Little executable solutions throughout, which just processes the solution and prints out the output in format, and that's what goes to standard out. But the way we typically use these things from the command line is basically you have a single executable which encapsulates all of this, and it's going to attach to a particular solver. So let's look at what executables come bundled with the MiniZincIDE. And there's plenty of other ways of running MiniZinc files without a solver. But these are the most obvious ones, and in particular we use within the course. So mzn-gecode is basically minizinc bundled with the Gecode solver, and this is default for the course and this is what we recommend you use. Because indeed, all the assessment of the assignments and model assessment will be done using Gecode. There is mzn-chuffed which is minizinc connected with chuffed which is a learning CP solver. This mzn-cbc which minizinc with COIN OR CBC solver, that's a free MIP solver. And there's also mzn-gurobi, which is minizinc that attached to Gurobi. This is a commercial MIP solver, but of course we can't give you a license for Gurobi, what you need to do use this is to install the dynamically vibrate of Gurobi result. And get an appropriate license to use it, but there are free academic licenses available for Gurobi. And there's other solvers, these are the older solvers, mzn-g12fd, this with a constraint or rather old one. Minizinc, the executable called minizinc is the same as this runs minizinc with g12fd, which is the original solver attached to minizinc. Then there's mzn-gl12lazy, which is minizinc with lazyfd, another learning CP solver, but older, not as good as chaff. And g12mip, which is with an older MIP solver. So these are the sort of the eight executables that you can use a command line to run minizinc models. So the usage is basically mzn-gecode, or use that for the examples, you can do some options, a model file, a single model file and one or more data files. So by default, if you run a command line this for a satisfaction problem, it'll search for a single solution. It'll stop and print out the first solution found. Otherwise it will print UNSATISFIABLE. For an optimization problem, it will search for the optimal solution, if it can prove optimally, it'll print out the authorization. If it finds no solution, it will print out UNSATISFIABLE. But we have to be careful because many problems that we'll see in the course and in the real world, it's very hard to prove optimality of a solution. So this can take a long time and do nothing because, remember it's only going to print anything if it proves that the solution is optimal. So one of the important flags that we want to use is the all-solutions flag, --all-solutions or -a. And this changes the behavior or MiniZinc. For satisfaction problems it does work as you'd expect. It prints out all of the solutions that are found, one after the other and puts this separator of ten dashes in between them. Otherwise, if there's no solution, it prints out UNSATISFIABLE as before, for optimization problems, it works slightly differently. What it does is prints all the solutions found on the way to the optimal solution. So the optimal solution basically will be the last one printed. Otherwise, if it finds no solutions, it prints UNSATISFIABLE. And but the important difference about using the -a flag is that in an optimization problem, you may well be finding solutions, you'll see them printed out. If you give up and can't afford enough time to prove optimality, you can just stop computation and look at the last solution you've found, and that's the best solution we've found so far. So often for optimization problems, we want to use MiniZinc with a -a flag, because often they'll not be able to prove optimality, in which case they'll just sit there and do nothing. Note that it's really only CP solvers that tend to support the all solution flag and the MIP solvers such as cdc, gurobi and g12mip basically only ever return one solution. So another important option is the statistics option -statistics, or -s. And that means the solver will print statistics about the solving process, typically at the end. And the statistics that are printed depend on which solver you are using. And so different solvers will print out different statistics but at least you can get some idea about what's going on with the solver and particularly, you could compare two different variations that are in model using the same solver to see differences. So things like runtime or solving time, the number of solutions found, the size of the problem, and statistics about search, like the number of nodes, or failures, or restarts are what's printed out by the statistics option. So another important option is this -D flag, so we put -D. And then in a string, some content, and basically that's just treated as part of the model. So we can basically add data from the command line. And this can be very useful if you want to run a model while you vary one of the two critical parameters. So if you've got some size parameter, and you want to run the different versions of the model in some script by changing the size parameter from 10 to 50 by a factor of 10 every time. Then that's very easy for you using this -D. You can change the output of MiniZinc, so if you put -o then the output's sent to the file. You can also change the strings that MiniZinc uses to print out things. So the solution separated string which is normally ten dashes, you could make it empty and that means that you can print out all your solutions without a line between them. And also you can change the completion message. So normally when MiniZinc says I've found all solutions or I've proved optimality, it prints out the search completion string, which is the ten equality sign, you can change that [INAUDIBLE]. Some other interesting options are the keep files or -k option that allow keeps the temporary files constructed. So this is useful for examining what flattening or debugging is doing and looking at some error messages. You can run -p or -parallel with a number of threads. And that's supported by, at least. Another interesting thing is if you want to pass an information to an underlying solver, you can use a minus minus epsilon end flags. Option, give those flags. An example of that is given here where we're passing in the time option to which is the actual decode solver. Requiring it to run with a 1,000 millisecond timeout. And you just stop and that [INAUDIBLE] do anything. So you can see with probably one of the minus a as well. So you see the answer [INAUDIBLE]. Although I think it'll print out the best answer it finds at the end of the time. So in summary, MiniZinc has a lot of command line options. Command line can be very useful for using MiniZinc within some other cool chains. We've covered the most important here, but there are plenty more, and you can look at this by basically going into minus. That'll give you a list of all of the [INAUDIBLE] options available.