this repo has no description
1/* Python Interface for MiniZinc constraint modelling
2 * Author:
3 * Tai Tran <tai.tran@student.adelaide.edu.au>
4 * Supervisor:
5 * Guido Tack <guido.tack@monash.edu>
6 */
7
8#ifndef __SOLVER_H
9#define __SOLVER_H
10
11#include "global.h"
12
13struct PyMznSolver {
14 PyObject_HEAD MiniZinc::SolverInstanceBase* solver;
15 MiniZinc::Env* env;
16 MiniZinc::Model* _m;
17
18 PyObject* next();
19};
20
21static PyObject* PyMznSolver_new(PyTypeObject* type, PyObject* args, PyObject* kwds);
22static int PyMznSolver_init(PyMznSolver* self, PyObject* args);
23static void PyMznSolver_dealloc(PyMznSolver* self);
24
25// Ask the solver to give the next available solution
26// Return Py_None if no error
27// Return a string with "Unsatisfied" or "Reached last solution" if error
28static PyObject* PyMznSolver_next(PyMznSolver* self);
29
30static PyObject* PyMznSolver_get_value_helper(PyMznSolver* self, PyObject* args);
31// get_value accepts 1 string or a list of strings,
32// which are the name of values to be retrieved.
33// returns a value or a tuple of value depending on which type argument was parsed.
34static PyObject* PyMznSolver_get_value(PyMznSolver* self, PyObject* args);
35
36static PyMemberDef PyMznSolver_members[] = {
37 {NULL} /* Sentinel */
38};
39
40// static PyMethodDef PyMznSolver_methods[3];
41
42static PyMethodDef PyMznSolver_methods[] = {
43 {"next", (PyCFunction)PyMznSolver_next, METH_NOARGS, "Next Solution"},
44 {"get_value", (PyCFunction)PyMznSolver_get_value, METH_VARARGS, "Get value of a variable"},
45 {NULL} /* Sentinel */
46};
47
48static PyTypeObject PyMznSolver_Type = {
49 PyVarObject_HEAD_INIT(NULL, 0) "minizinc_internal.solver", /* tp_name */
50 sizeof(PyMznSolver), /* tp_basicsize */
51 0, /* tp_itemsize */
52 (destructor)PyMznSolver_dealloc, /* tp_dealloc */
53 0, /* tp_print */
54 0, /* tp_getattr */
55 0, /* tp_setattr */
56 0, /* tp_reserved */
57 0, /* tp_repr */
58 0, /* tp_as_number */
59 0, /* tp_as_sequence */
60 0, /* tp_as_mapping */
61 0, /* tp_hash */
62 0, /* tp_call */
63 0, /* tp_str */
64 0, /* tp_getattro */
65 0, /* tp_setattro */
66 0, /* tp_as_buffer */
67 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
68 "Minizinc Solver", /* tp_doc */
69 0, /* tp_traverse */
70 0, /* tp_clear */
71 0, /* tp_richcompare */
72 0, /* tp_weaklistoffset */
73 0, /* tp_iter */
74 0, /* tp_iternext */
75 PyMznSolver_methods, /* tp_methods */
76 PyMznSolver_members, /* tp_members */
77 0, /* tp_getset */
78 0, /* tp_base */
79 0, /* tp_dict */
80 0, /* tp_descr_get */
81 0, /* tp_descr_set */
82 0, /* tp_dictoffset */
83 (initproc)PyMznSolver_init, /* tp_init */
84 0, /* tp_alloc */
85 PyMznSolver_new, /* tp_new */
86};
87
88#endif