This commit is contained in:
Vitor Santos Costa
2017-03-02 22:01:32 +00:00
parent f3b0e962a7
commit f7efff157b
14 changed files with 75 additions and 1372 deletions

View File

@@ -6,12 +6,12 @@
// under the terms of the GNU Lesser General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//=============================================================================
@@ -82,7 +82,7 @@ namespace generic_gecode
struct GenericRestartDFS: GenericEngine
{
RBS<DFS,GenericSpace> engine;
RBS<GenericSpace,DFS> engine;
GenericRestartDFS(GenericSpace* s,Search::Options& opt) : engine(s,opt) {}
virtual GenericSpace* next(void) { return engine.next(); }
};
@@ -96,7 +96,7 @@ namespace generic_gecode
struct GenericRestartBAB: GenericEngine
{
RBS<BAB,GenericSpace> engine;
RBS<GenericSpace,BAB> engine;
GenericRestartBAB(GenericSpace* s,Search::Options& opt) : engine(s,opt) {}
virtual GenericSpace* next(void) { return engine.next(); }
};

View File

@@ -6,17 +6,17 @@
// under the terms of the GNU Lesser General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//=============================================================================
#include "gecode4-common.icc"
#include "gecode5-common.icc"
#include <iostream>
using namespace std;
using namespace generic_gecode;
@@ -25,7 +25,7 @@ using namespace Gecode;
extern "C"
{
void gecode_init(void);
#include "config.h"
}
@@ -327,7 +327,7 @@ extern "C"
static YAP_Term gecode_FLOAT_VAR_SIZE_MAX;
static YAP_Term gecode_FLOAT_VAR_DEGREE_SIZE_MIN;
static YAP_Term gecode_FLOAT_VAR_DEGREE_SIZE_MAX;
static inline FloatVarBranch
gecode_FloatVarBranch_from_term(YAP_Term t)
{
@@ -495,7 +495,7 @@ extern "C"
YAP_Term t_a;
if (YAP_ArityOfFunctor(YAP_FunctorOfTerm(t)) == 1 &&
YAP_IsIntTerm(t_a = YAP_ArgOfTerm(1,t))) {
unsigned long int a = YAP_IntOfTerm(t_a);
unsigned long int a = YAP_IntOfTerm(t_a);
cutoff = Search::Cutoff::constant(a);
} else {
cerr << "bad parameter for constant" << endl; exit(1);
@@ -505,8 +505,8 @@ extern "C"
if (YAP_ArityOfFunctor(YAP_FunctorOfTerm(t)) == 2 &&
YAP_IsIntTerm(t_s = YAP_ArgOfTerm(1,t)) &&
YAP_IsIntTerm(t_b = YAP_ArgOfTerm(2,t))) {
unsigned long int s = YAP_IntOfTerm(t_s);
unsigned long int b = YAP_IntOfTerm(t_b);
unsigned long int s = YAP_IntOfTerm(t_s);
unsigned long int b = YAP_IntOfTerm(t_b);
cutoff = Search::Cutoff::geometric(s,b);
} else {
cerr << "bad parameter for geometric" << endl; exit(1);
@@ -515,7 +515,7 @@ extern "C"
case RM_LUBY:
if (YAP_ArityOfFunctor(YAP_FunctorOfTerm(t)) == 1 &&
YAP_IsIntTerm(t_s = YAP_ArgOfTerm(1,t))) {
unsigned long int s = YAP_IntOfTerm(t_s);
unsigned long int s = YAP_IntOfTerm(t_s);
cutoff = Search::Cutoff::luby(s);
} else {
cerr << "bad parameter for luby" << endl; exit(1);
@@ -524,7 +524,7 @@ extern "C"
case RM_LINEAR:
if (YAP_ArityOfFunctor(YAP_FunctorOfTerm(t)) == 1 &&
YAP_IsIntTerm(t_s = YAP_ArgOfTerm(1,t))) {
unsigned long int s = YAP_IntOfTerm(t_s);
unsigned long int s = YAP_IntOfTerm(t_s);
cutoff = Search::Cutoff::linear(s);
} else {
cerr << "bad parameter for linear" << endl; exit(1);

View File

@@ -1,21 +0,0 @@
:- use_module( library(python) ).
:- := import( collections ).
:- := import( yap ).
:- e := yap.'YAPEngine'().
main :-
system_predicate(N/A),
args(0,A,L),
N := namedtuple( N, L),
fail.
main :-
:= e.call( writeln( 1 ) ).
args(N, N, []) :- !.
args(I0,IF,[AI|Ais]) :-
I is I0+1,
number_string(I, IS),
string_concat("A", IS, AI),
args(I, IF, Ais).

View File

@@ -53,7 +53,7 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
*/
} else
{
PyObject *o = PythonLookupSpecial(s);
o = PythonLookupSpecial(s);
}
if (o) {
Py_INCREF( o );

File diff suppressed because it is too large Load Diff

View File

@@ -115,8 +115,6 @@ PyObject *PythonLookup(const char *s, PyObject *oo) {
PyObject *find_obj(PyObject *ob, term_t l, bool eval) {
YAP_Term hd, yt;
bool may_be_package = true;
py_Context = NULL;
yt = YAP_GetFromSlot(l);
@@ -582,7 +580,7 @@ static long get_len_of_range(long lo, long hi, long step) {
return n;
}
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3 && defined(USE_NAMEDTUPLES)
static PyStructSequence_Field pnull[] = {
{"A1", NULL}, {"A2", NULL}, {"A3", NULL}, {"A4", NULL},
{"A5", NULL}, {"A6", NULL}, {"A7", NULL}, {"A8", NULL},

View File

@@ -77,7 +77,8 @@ static void install_py_constants(void) {
Py_INCREF(py_Builtin);
py_ModDict = PyObject_GetAttrString(py_Sys, "modules");
py_Yapex = PyImport_ImportModule("yapex");
PyObject *py_Yap = PyImport_ImportModule("yap");
// PyObject *py_Yap =
PyImport_ImportModule("yap");
Py_INCREF(py_Yapex);
//py_F2P = PyObject_GetAttrString(py_Yap, "globals");
py_F2P = NULL;

View File

@@ -1,44 +0,0 @@
import json
import os
import sys
try:
from jupyter_client.kernelspec import install_kernel_spec
except ImportError:
from IPython.kernel.kernelspec import install_kernel_spec
from IPython.utils.tempdir import TemporaryDirectory
kernel_json = {
"argv": [sys.executable,
"-m", "yap_kernel",
"-f", "{connection_file}"],
"display_name": "yap",
"mimetype": "text/x-prolog",
"language": "prolog",
"name": "yap",
}
def install_my_kernel_spec(user=False):
with TemporaryDirectory() as td:
os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
# TODO: Copy resources once they're specified
print('Installing IPython kernel spec')
install_kernel_spec(td, 'yap', user=False, replace=True)
def _is_root():
return True
try:
return os.geteuid() == 0
except AttributeError:
return False # assume not an admin on non-Unix platforms
def main(argv=[]):
user = '--user' in argv or not _is_root()
install_my_kernel_spec(user=user)
if __name__ == '__main__':
main(argv=sys.argv)