コード例 #1
0
def test_run() -> None:
    assert Solver.run("1/2 + 3/4") == "1_1/4"
    assert Solver.run("1 + 0") == "1"
    assert Solver.run("3_1/2 * 3") == "10_1/2"
    assert Solver.run("2_4/5 - 11/10") == "1_7/10"
    assert Solver.run("10 / 2") == "5"
    assert Solver.run("13/2 / 3/2") == "4_1/3"
    assert Solver.run("-1_1/3 - 1/3") == "-1_2/3"
    assert Solver.run("-1/2 * 2") == "-1"
コード例 #2
0
def calculator() -> None:
    click.echo(
        click.style(
            ("Welcome, please enter an operation.\n"
             "E.g. 1 + 2, 1/2 - 3/4, 2_2/3 / -8_1/5\n"
             "Press Ctrl+C to exit."),
            fg="magenta",
        ))
    while True:
        input = click.prompt(click.style("?", fg="green"))
        try:
            click.echo(
                click.style("= ", fg="blue") +
                click.style(Solver.run(input), fg="yellow"))
        except ValueError as excinfo:
            click.echo(click.style(str(excinfo), fg="red"))
コード例 #3
0
ファイル: bayesit.py プロジェクト: glher/PHASED
 cnt = 0
 print("{:<20} {:<10}".format('PHM positions',
                              'Failure of critical function'))
 print("-------------        ----------------------------")
 for state in states:
     cnt += 1
     if select and cnt < number:
         continue
     if select and cnt > number:
         break
     model_description = model.load_phm(model_description, state)
     # Build the model
     bn = BayesianNetwork(model_description)
     bayesian_model = bn.build()
     solver = Solver(bayesian_model, display, evidence)
     e = solver.run(mapquery=False, printed=False)
     if e < failure:
         final_state = state
         failure = e
         print("{:<20} {:.4E} *".format(cnt, e))
     else:
         print("{:<20} {:.4E}".format(cnt, e))
 if details:
     print('\n=====================\n')
     model_description = model.load_phm(model_description, final_state)
     # Build the model
     bn = BayesianNetwork(model_description)
     bayesian_model = bn.build()
     solver = Solver(bayesian_model, display_final, evidence)
     e = solver.run(mapquery=False, printed=True)
     print('\n=====================\n')
コード例 #4
0
ファイル: main.py プロジェクト: FanQinFred/CGRA
from src.solver import Solver

for i in range(2, 42):
    runner = Solver()
    print("========================================================")
    print(i.__str__() + "begin  :: ")
    runner.run("../dataset/raw_datas/g" + i.__str__())
コード例 #5
0
ファイル: main.py プロジェクト: bshelkhonov/KissTask
def main():
    parser = setup_parser()
    args = parser.parse_args()
    solver = Solver(args.text_file)
    solver.run()