class_docstr: The method class for GraphAF algorithm proposed in the paper `GraphAF: a Flow-based Autoregressive Model for Molecular Graph Generation <https://arxiv.org/abs/2001.09382>`_. This class provides interfaces for running random generation, property
  optimization, and constrained optimization with GraphAF. Please refer to the `example codes <https://github.com/divelab/DIG/tree/dig-stable/examples/ggraph/GraphAF>`_ for usage examples.
class_docstr_tok: ["The","method","class","for","GraphAF","algorithm","proposed","in","the","paper","`","GraphAF",":","a","Flow-based","Autoregressive","Model","for","Molecular","Graph","Generation","<","https",":","\/\/arxiv.org\/abs\/2001.09382",">","`","_",".","This","class","provides","interfaces","for","running","random","generation",",","property","optimization",",","and","constrained","optimization","with","GraphAF",".","Please","refer","to","the","`","example","codes","<","https",":","\/\/github.com\/divelab\/DIG\/tree\/dig-stable\/examples\/ggraph\/GraphAF",">","`","_","for","usage","examples","."]
code: def run_cons_optim_one_mol(
      self,
      adj,
      x,
      org_smile,
      mol_size,
      bfs_perm_origin,
      max_size_rl=38,
      temperature=0.70,
      atom_list=[6, 7, 8, 9],
  ):
      best_mol0 = None
      best_mol2 = None
      best_mol4 = None
      best_mol6 = None
      best_imp0 = -100.0
      best_imp2 = -100.0
      best_imp4 = -100.0
      best_imp6 = -100.0
      final_sim0 = -1.0
      final_sim2 = -1.0
      final_sim4 = -1.0
      final_sim6 = -1.0
  
      mol_org = Chem.MolFromSmiles(org_smile)
      mol_org_size = mol_org.GetNumAtoms()
      assert mol_org_size == mol_size
  
      (
          cur_mols,
          cur_mol_imps,
          cur_mol_sims,
      ) = self.model.reinforce_constrained_optim_one_mol(
          x,
          adj,
          mol_size,
          org_smile,
          bfs_perm_origin,
          atom_list=atom_list,
          temperature=temperature,
          max_size_rl=max_size_rl,
      )
      num_success = len(cur_mol_imps)
      for i in range(num_success):
          cur_mol = cur_mols[i]
          cur_imp = cur_mol_imps[i]
          cur_sim = cur_mol_sims[i]
          assert cur_imp > 0
          if cur_sim > 0:
              if cur_imp > best_imp0:
                  best_mol0 = cur_mol
                  best_imp0 = cur_imp
                  final_sim0 = cur_sim
          if cur_sim > 0.2:
              if cur_imp > best_imp2:
                  best_mol2 = cur_mol
                  best_imp2 = cur_imp
                  final_sim2 = cur_sim
          if cur_sim > 0.4:
              if cur_imp > best_imp4:
                  best_mol4 = cur_mol
                  best_imp4 = cur_imp
                  final_sim4 = cur_sim
          if cur_sim > 0.6:
              if cur_imp > best_imp6:
                  best_mol6 = cur_mol
                  best_imp6 = cur_imp
                  final_sim6 = cur_sim
  
      return (
          [best_mol0, best_mol2, best_mol4, best_mol6],
          [best_imp0, best_imp2, best_imp4, best_imp6],
          [final_sim0, final_sim2, final_sim4, final_sim6],
      )
  
file_path: DIG/dig/ggraph/method/GraphAF/graphaf.py
imports: import os
  import torch
  import torch.nn
  from rdkit import Chem
  from dig.ggraph.method import Generator
  from .model import GraphFlowModel, GraphFlowModel_rl, GraphFlowModel_con_rl
  from .train_utils import adjust_learning_rate, DataIterator
label_desc: Use image node_id 9 for calling the GraphAF obj's underlying member method code with example usage: obj.run_cons_optim_one_mol(adj, x, org_smile, mol_size, bfs_perm_origin, max_size_rl, temperature, atom_list) and returns: list,  list,  list