# SolversΒΆ

`Solver` ([globals_dir, support_mzn, ...]) |
Abstract solver class. |

`Gecode` ([mzn_path, fzn_path, globals_dir]) |
Interface to the Gecode solver. |

`Chuffed` ([mzn_path, fzn_path, globals_dir]) |
Interface to the Chuffed solver. |

`Optimathsat` ([path, globals_dir]) |
Interface to the Optimathsat solver. |

`Opturion` ([path, globals_dir]) |
Interface to the Opturion CPX solver. |

`MIPSolver` ([path, globals_dir]) |
Interface to the MIP solver. |

`Gurobi` ([path, globals_dir]) |
Interface to the Gurobi solver. |

`CBC` ([path, globals_dir]) |
Interface to the COIN-OR CBC solver. |

`G12Solver` ([mzn_path, fzn_path, globals_dir, ...]) |
Interface to a generic G12 solver. |

`G12Fd` ([mzn_path, fzn_path, globals_dir]) |
Interface to the G12Fd solver. |

`G12Lazy` ([mzn_path, fzn_path, globals_dir]) |
Interface to the G12Lazy solver. |

`G12MIP` ([mzn_path, fzn_path, globals_dir]) |
Interface to the G12MIP solver. |

`gecode` |
Default Gecode instance. |

`chuffed` |
Default Chuffed instance. |

`optimathsat` |
Default Optimathsat instance. |

`opturion` |
Default Opturion instance. |

`gurobi` |
Default Gurobi instance. |

`cbc` |
Default CBC instance. |

`g12fd` |
Default G12Fd instance. |

`g12lazy` |
Default G12Lazy instance. |

`g12mip` |
Default G12Lazy instance. |

Provides classes to interface solvers with PyMzn.

PyMzn interfaces with solvers through the `Solver`

base class. This class
includes the necessary infomation for PyMzn to setup the solver, together with
the `solve`

and `solve_start`

methods, which respectively take care of the
running or asynchronously starting a process that solves the MiniZinc/FlatZinc
model. PyMzn provides a number of solver implementations out-of-the-box.
PyMzn’s default solver is `pymzn.gecode`

, an instance of `pymzn.Gecode`

.

To use a solver that is not provided by PyMzn or to exend an existing one, one
has to subclass the `Solver`

class and implement the `args`

method, which
returns a list of command line arguments for executing the process. This is
generally enough for most solvers, but you can also directly reimplement the
`solve`

and `solve_start`

methods for extra flexibility.

For instance:

```
from pymzn import Solver
from pymzn.process import Process
class MySolver(Solver):
def __init__(self, path='path/to/solver', globals_dir='path/to/gobals'):
super().__init__(globals_dir)
self.cmd = path
def args(self, fzn_file, *args, arg1=val1, arg2=val2, **kwargs):
return [self.cmd, '-arg1', arg1, '-arg2', arg2, fzn_file]
```

Then it is possible to run the `minizinc`

function with the custom solver:

```
my_solver = MySolver()
pymzn.minizinc('test.mzn', solver=my_solver, arg1=val1, arg2=val2)
```