#!/usr/bin/env python
__author__ = 'kostas'

from test_util import *
from cvl.compiler import CvlCompiler
from cvl.framework.query import Query

if __name__ == '__main__':
    compiler = CvlCompiler()

    QUERY_DICT = {
        'input': 'openflights_airports',
        'output': 'openfligts_airports_thinned',
        'subject_to': [('proximity', 15),('cellbound', 16)],
        'rank_by': 'num_routes',
        'zoomlevels': 18,
        'fid': 'airport_id',
        'geometry': 'wkb_geometry'
    }

    query = Query(**QUERY_DICT)
    print compiler.compile(
        query,
        solver='heuristic',
        target='postgres',
        log_file='/tmp/cvl.log',
        job_name='demo_airports',
        analytics=False
    )

#!/usr/bin/env python
__author__ = 'kostas'

from test_util import *
from cvl.compiler import CvlCompiler
from cvl.framework.query import Query

if __name__ == '__main__':
    compiler = CvlCompiler()

    for ds_name in ['usrivers', 'airports', 'tourism', 'dai']:
        dataset = DATASETS[ds_name]
        for cn_name in ['A', 'B']:
            constraint = CONSTRAINTS[cn_name]
            for solver in ['heuristic', 'lp']:
                    job_name = "basic_{0:s}_{1:d}_{2:s}_{3:s}".format(
                        ds_name,
                        dataset['size'],
                        '-'.join(map(lambda x: x[0], constraint)),
                        solver
                    )
                    QUERY_DICT['input'] = dataset['input'].format(dataset['size'])
                    QUERY_DICT['subject_to'] = constraint
                    QUERY_DICT['rank_by'] = dataset['rank_by']
                    query = Query(**QUERY_DICT)
                    print compiler.compile(
                        query,
                        solver=solver,
                        target='postgres',
                        log_file='/tmp/cvl.log',
                        job_name=job_name,
#!/usr/bin/env python
__author__ = "kostas"

from test_util import *
from cvl.compiler import CvlCompiler
from cvl.framework.query import Query

if __name__ == "__main__":
    compiler = CvlCompiler()

    dataset = DATASETS["airports"]
    solver = "heuristic"
    constraint = CONSTRAINTS["A"]

    job_name = "airports_visualize"
    QUERY_DICT["input"] = dataset["input"].format(dataset["size"])
    QUERY_DICT["subject_to"] = constraint
    QUERY_DICT["rank_by"] = dataset["rank_by"]
    query = Query(**QUERY_DICT)
    print compiler.compile(
        query, solver=SOLVERS[0], target="postgres", log_file="/tmp/cvl.log", job_name=job_name, analytics=False
    )
#!/usr/bin/env python
__author__ = "kostas"

from test_util import *
from cvl.compiler import CvlCompiler
from cvl.framework.query import Query

if __name__ == "__main__":
    compiler = CvlCompiler()

    QUERY_DICT = {
        "input": "openflights_airports",
        "output": "openflights_airports_thinned2",
        "subject_to": [("proximity", 10)],
        "rank_by": "num_routes",
        "zoomlevels": 18,
        "fid": "airport_id",
        "geometry": "wkb_geometry",
    }

    query = Query(**QUERY_DICT)
    print compiler.compile(
        query, solver="heuristic", target="postgres", log_file="/tmp/cvl.log", job_name="demo_airports", analytics=False
    )
#!/usr/bin/env python
__author__ = 'kostas'

from cvl.compiler import CvlCompiler
from cvl.framework.query import Query

if __name__ == '__main__':

	QUERY_DICT = {
		'input': 'openflights_airports',
		'output': 'openflights_airports_gen',
		'rank_by': 'num_routes',
		'zoomlevels': 18,
		'fid': 'ogc_fid',
		'geometry': 'wkb_geometry',
		'subject_to': [('visibility', 16), ('proximity', 5)]
	}

	query = Query(**QUERY_DICT)
	compiler = CvlCompiler()
	print compiler.compile(
		query,
		solver='sga',
		target='postgres'
	)