Usage¶
The following flow solves the optimization problem. The number of flow corresponds the comment in the program example.
Define your
Algorithm
and/orSolver
Of course, classes that
py2dmat
defines are available
Prepare the input parameter,
info: py2dmat.Info
Make a dictionary as your favorite way
The below example uses a TOML formatted input file for generating a dictionary
Instantiate
solver: Solver
,runner: py2dmat.Runner
, andalgorithm: Algorithm
Invoke
algorithm.main()
Example
import sys
import tomli
import py2dmat
# (1)
class Solver(py2dmat.solver.SolverBase):
# Define your solver
...
class Algorithm(py2dmat.algorithm.AlgorithmBase):
# Define your algorithm
...
# (2)
with open(sys.argv[1]) as f:
inp = tomli.load(f)
info = py2dmat.Info(inp)
# (3)
solver = Solver(info)
runner = py2dmat.Runner(solver, info)
algorithm = Algorithm(info, runner)
# (4)
algorithm.main()