def test_script_pla(name, file, constants, propertyfile, samplesfile, threshold, tool, method): END_CRITERIA = "--area" END_CRITERIA_VALUE = 0.30 command = [ "--solver=z3", "--mc={}".format(tool), "load-problem", "--constants", constants, os.path.join(EXAMPLE_FOLDER, "{}/{}.pm".format(name, file)), os.path.join(EXAMPLE_FOLDER, "{}/{}.pctl".format(name, propertyfile)), "set-threshold", str(threshold), "set-parameter-space", "--epsilon", "0.001", "load-samples", os.path.join(EXAMPLE_FOLDER, "{}/{}.samples".format(name, samplesfile)), "parameter-space-partitioning", END_CRITERIA, str(END_CRITERIA_VALUE), "pla", method ] logger.debug("parameter_synthesis.py " + " ".join(command)) runner = click.testing.CliRunner() try: result = runner.invoke(parameter_synthesis.parameter_synthesis, command) except NotImplementedError: pytest.xfail() assert result.exit_code == 0, result.output pycarl.clear_variable_pool()
def test_script_sfsmt(name, benchmark, threshold, dir): command = [ "load-solution-function", os.path.join(EXAMPLE_FOLDER, "{}/{}.rat".format(name, benchmark)), "set-threshold", str(threshold), "find-feasible-instantiation", dir, "sfsmt" ] logger.debug("parameter_synthesis.py " + " ".join(command)) runner = click.testing.CliRunner() result = runner.invoke(parameter_synthesis.parameter_synthesis, command) assert result.exit_code == 0, result.output pycarl.clear_variable_pool()
def test_script_qcqp(name, benchmark, property, threshold, dir): command = [ "load-problem", os.path.join(EXAMPLE_FOLDER, "{}/{}.pm".format(name, benchmark)), os.path.join(EXAMPLE_FOLDER, "{}/{}.pctl".format(name, property)), "set-threshold", str(threshold), "find-feasible-instantiation", "--qcqp-incremental", "--qcqp-store-quadratic", "--qcqp-handle-violation", "minimisation", "--qcqp-mc", "full", "--precheck-welldefinedness", dir, "qcqp" ] logger.debug("parameter_synthesis.py " + " ".join(command)) runner = click.testing.CliRunner() result = runner.invoke(parameter_synthesis.parameter_synthesis, command) assert result.exit_code == 0, result.output pycarl.clear_variable_pool()
def test_script(name, file, constants, property, tool): command = ["--mc={}".format(tool), "load-problem", "--constants", constants, os.path.join(EXAMPLE_FOLDER, "{}/{}.pm".format(name, file)), os.path.join(EXAMPLE_FOLDER, "{}/{}.pctl".format(name, property)), "compute-solution-function", '--export', target_file ] runner = click.testing.CliRunner() logger.debug("parameter_synthesis.py " + " ".join(command)) result = runner.invoke(parameter_synthesis.parameter_synthesis, command) assert result.exit_code == 0, result.output assert os.path.isfile(target_file) os.remove(target_file) pycarl.clear_variable_pool()
def test_script(name, file, constants, property, threshold, tool): command = ["--mc={}".format(tool), "load-problem", "--constants", constants, os.path.join(EXAMPLE_FOLDER, "{}/{}.pm".format(name, file)), os.path.join(EXAMPLE_FOLDER, "{}/{}.pctl".format(name, property)), "set-threshold", str(threshold), "sample", "--samplingnr", str(SAMPLINGNR), "--iterations", str(ITERATIONS), '--export', target_file ] logger.debug("parameter_synthesis.py " + " ".join(command)) runner = click.testing.CliRunner() result = runner.invoke(parameter_synthesis.parameter_synthesis, command) assert result.exit_code == 0, result.output assert os.path.isfile(target_file) os.unlink(target_file) pycarl.clear_variable_pool()
def test_contains(): pycarl.clear_variable_pool() x = pc.Variable("x") p = Parameter(x, string_to_interval("(0,1)", int)) p_new = pickle.loads(pickle.dumps(p)) assert p == p_new