Use Solver Contexts
This tutorial obtains the default context, creates a context with different
resource settings, and activates each context for jcmsuite.info.
The default context must have access to a JCMsuite installation through
JCMROOT or its configured installation path.
Run the tutorial from the tutorial root:
python execution_runtime/contexts/run.py
Python File
import jcmsuite
# Get the default context that parses the JCMROOT environment variable
default_ctx = jcmsuite.context.get_default_context()
# Create a new context with 4 threads and a memory limit of 1024 MB
other_ctx = jcmsuite.context.create_context(
jcm_root=default_ctx.jcm_root,
num_threads=4,
memory_limit_mb=1024,
)
# Get the context information for the non default context
with other_ctx:
jcmsuite.info()
# Get the context information for the default context
jcmsuite.info()
# The context can also be provided through the context argument.
jcmsuite.info(context=other_ctx)
# Finally, we can also replace the default context with the new context.
jcmsuite.context.set_default_context(other_ctx)
jcmsuite.info()