Modeling
create_model
create_model(
entry_point: Union[QFunc, GenerativeQFunc],
constraints: Optional[Constraints] = None,
execution_preferences: Optional[
ExecutionPreferences
] = None,
preferences: Optional[Preferences] = None,
classical_execution_function: Optional[CFunc] = None,
out_file: Optional[str] = None,
) -> SerializedModel
Create a serialized model from a given Qmod entry function and additional parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point
|
Union[QFunc, GenerativeQFunc]
|
The entry point function for the model, which must be a QFunc named 'main'. |
required |
constraints
|
Optional[Constraints]
|
Constraints for the synthesis of the model. See Constraints (Optional). |
None
|
execution_preferences
|
Optional[ExecutionPreferences]
|
Preferences for the execution of the model. See ExecutionPreferences (Optional). |
None
|
preferences
|
Optional[Preferences]
|
Preferences for the synthesis of the model. See Preferences (Optional). |
None
|
classical_execution_function
|
Optional[CFunc]
|
A function for the classical execution logic, which must be a CFunc (Optional). |
None
|
out_file
|
Optional[str]
|
File path to write the Qmod model in native Qmod representation to (Optional). |
None
|
Returns:
Name | Type | Description |
---|---|---|
SerializedModel |
SerializedModel
|
A serialized model. |
Raises:
Type | Description |
---|---|
ClassiqError
|
If the entry point function is not named 'main'. |
write_qmod
write_qmod
write_qmod(
model: Union[SerializedModel, QFunc, GenerativeQFunc],
name: str,
directory: Optional[Path] = None,
decimal_precision: int = DEFAULT_DECIMAL_PRECISION,
) -> None
Creates a native Qmod file from a serialized model and outputs the synthesis options (Preferences and Constraints) to a file. The native Qmod file may be uploaded to the Classiq IDE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Union[SerializedModel, QFunc, GenerativeQFunc]
|
The entry point of the Qmod model - a qfunc named 'main' (or alternatively the output of 'create_model'). |
required |
name
|
str
|
The name to save the file by. |
required |
directory
|
Optional[Path]
|
The directory to save the files in. If None, the current working directory is used. |
None
|
decimal_precision
|
int
|
The number of decimal places to use for numbers, set to 4 by default. |
DEFAULT_DECIMAL_PRECISION
|
Returns:
Type | Description |
---|---|
None
|
None |