<jupyter_start><jupyter_text>Step 2: Build Model In this part, we build the Quadratic Unconstrained Binary Optimization (QUBO) model for molecular unfolding.First, we set the following parameters and initialize the QMUQUBO object. | Parameter | Description | Value ||--- |--- |--- ||A | penalty scalar |300||hubo_qubo_val | energy penalty of make_quadratic() |200||M | number of torsions for molecular unfolding| [1, max number of rotatable bonds] ||D| angle precision of rotation| 8||method| the method of building model| 'pre-calc': calculate the score in advance| We use the 'pre-calc' method to build the model. This molecule has 23 rotatable bonds and we only test 2 of them, so we set the **M** to 2. And we want the angle to become $45^o$, so we set the **D** to 8 (i.e., $8=360^o/45^o$). The **A** and **hubo_qubo_val** are test from experiments. **Notice**    Please refer to **Build Model(Technical Details)** for the definition of parameters**Warning**You may have long run time for large **M** or **D**. Please refer to **Batch Evaluation** before adjusting parameters<jupyter_code>from utility.MoleculeParser import MoleculeData
from utility.QMUQUBO import QMUQUBO
from utility.AnnealerOptimizer import Annealer
from utility.ResultProcess import ResultParser
import time

timestamp = time.strftime("%Y%m%d-%H")
# initial the QMUQUBO object
init_param = {}
method = ['pre-calc']

for mt in method:
    if mt == 'pre-calc':
        init_param[mt] = {}
        init_param[mt]['param'] = ['M', 'D', 'A', 'hubo_qubo_val']
    
qmu_qubo = QMUQUBO(mol_data, method, **init_param)
# set the parameters for model
model_param = {}
# parameters
num_rotation_bond = mol_data.bond_graph.rb_num

method = 'pre-calc'
model_param[method] = {}
# model_param[method]['M'] = range(1, num_rotation_bond+1)
model_param[method]['M'] = [2]
model_param[method]['D'] = [8]
model_param[method]['A'] = [300]
model_param[method]['hubo_qubo_val'] = [200]

qmu_qubo.build_model(**model_param)<jupyter_output>INFO:root:Construct model for M:2,D:8,A:300,hubo_qubo_val:200 0.0010666688283284505 min<jupyter_text>We can use the following method to check the properties of model. This way, we can build many models conveniently. After that, we save the model and update the value of **model_path**.<jupyter_code># describe the model parameters
model_info = qmu_qubo.describe_model()
# save the model
model_path = qmu_qubo.save("latest")

print(f"You have built the QUBO model and saved it as {model_path}")<jupyter_output>INFO:root:finish save qmu_117_ideal_model_latest.pickle
{'fraction_non_alphanumeric': 0.12015655577299413, 'fraction_numerical': 0.024657534246575342, 'mean_word_length': 5.553846153846154, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '624003', 'license': 'Apache-2.0', 'n_tokens_mistral': 876, 'n_tokens_neox': 808, 'n_words': 281, 'path': 'docs/en/workshop/a-molecular-unfolding/build-model.ipynb', 'repo_name': 'hy714335634/quantum-ready-solution-for-drug-discovery', 'size': '2555'}