
--------------------------------------------
----    File generated by Tree2C V1.0   ----
---- (c) 2017-2019, Alessandro Pedretti ----
-------------------------------------------/


---- Model class ----

random_tree = {}
random_tree.__index = random_tree

function random_tree:New()
  local Acnt = {}
  setmetatable(Acnt, random_tree)

  ---- Output values ----

  self.C_FALSE = 0
  self.C_TRUE = 1

  ---- Values of the attributes ----

  self.C_FG_CON2_NO = 0
  self.C_FG_CON2_YES = 1
  self.C_FG_COOH_NO = 0
  self.C_FG_COOH_YES = 1
  self.C_FG_COOR_NO = 0
  self.C_FG_COOR_YES = 1
  self.C_FG_F_NO = 0
  self.C_FG_F_YES = 1
  self.C_FG_PHOH_NO = 0
  self.C_FG_PHOH_YES = 1

  ---- Properties ----

  self.Angles = 0.0
  self.Atoms = 0.0
  self.Bonds = 0.0
  self.ChiralAtms = 0.0
  self.Dipole = 0.0
  self.EzBnds = 0.0
  self.FG_CON2 = 0
  self.FG_COOH = 0
  self.FG_COOR = 0
  self.FG_F = 0
  self.FG_PhOH = 0
  self.FlexTorsions = 0.0
  self.Gyrrad = 0.0
  self.HbAcc = 0.0
  self.HbDon = 0.0
  self.HeavyAtoms = 0.0
  self.Lipole = 0.0
  self.Mass = 0.0
  self.Ovality = 0.0
  self.Psa = 0.0
  self.Rings = 0.0
  self.Sas = 0.0
  self.Sav = 0.0
  self.Sdiam = 0.0
  self.Torsions = 0.0
  self.Vdiam = 0.0
  self.VirtualLogP = 0.0

  return Acnt
end


---- Classification method ----

function random_tree:Classify()
  local Res = 0

  if self.HbDon < 0.5000 then
    if self.Sas < 756.1100 then
      if self.FG_COOR == self.C_FG_COOR_YES then
        if self.Angles < 106.5000 then
          if self.Atoms < 48.0000 then
            Res = self.C_TRUE;
          else
            if self.Atoms < 51.0000 then
              Res = self.C_FALSE;
            else
              Res = self.C_TRUE;
            end
          end
        else
          Res = self.C_FALSE;
        end
      else
        if self.HeavyAtoms < 13.5000 then
          if self.Gyrrad < 2.8500 then
            Res = self.C_TRUE;
          else
            Res = self.C_FALSE;
          end
        else
          Res = self.C_TRUE;
        end
      end
    else
      Res = self.C_FALSE;
    end
  else
    if self.Angles < 92.5000 then
      if self.Gyrrad < 3.6800 then
        if self.Torsions < 17.5000 then
          if self.Sas < 283.4200 then
            Res = self.C_TRUE;
          else
            if self.FlexTorsions < 0.5000 then
              if self.Sas < 301.9000 then
                Res = self.C_FALSE;
              else
                Res = self.C_TRUE;
              end
            else
              if self.FG_CON2 == self.C_FG_CON2_YES then
                if self.Lipole < 2.1200 then
                  Res = self.C_TRUE;
                else
                  Res = self.C_FALSE;
                end
              else
                if self.HbAcc < 2.5000 then
                  if self.Rings < 1.5000 then
                    if self.Sav < 575.0000 then
                      Res = self.C_TRUE;
                    else
                      if self.Sdiam < 8.5700 then
                        Res = self.C_FALSE;
                      else
                        Res = self.C_TRUE;
                      end
                    end
                  else
                    if self.Torsions < 15.5000 then
                      Res = self.C_FALSE;
                    else
                      if self.HeavyAtoms < 15.5000 then
                        Res = self.C_TRUE;
                      else
                        Res = self.C_FALSE;
                      end
                    end
                  end
                else
                  if self.HeavyAtoms < 12.5000 then
                    Res = self.C_FALSE;
                  else
                    if self.Angles < 39.5000 then
                      Res = self.C_TRUE;
                    else
                      if self.Torsions < 14.5000 then
                        Res = self.C_FALSE;
                      else
                        if self.HeavyAtoms < 16.5000 then
                          if self.ChiralAtms < 1.5000 then
                            Res = self.C_FALSE;
                          else
                            Res = self.C_TRUE;
                          end
                        else
                          Res = self.C_TRUE;
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        else
          if self.Vdiam < 7.3000 then
            Res = self.C_FALSE;
          else
            if self.Sas < 561.9500 then
              if self.HeavyAtoms < 19.5000 then
                if self.Torsions < 19.5000 then
                  if self.FG_COOH == self.C_FG_COOH_YES then
                    Res = self.C_FALSE;
                  else
                    Res = self.C_TRUE;
                  end
                else
                  Res = self.C_TRUE;
                end
              else
                Res = self.C_TRUE;
              end
            else
              Res = self.C_FALSE;
            end
          end
        end
      else
        if self.Ovality < 1.6900 then
          if self.HbAcc < 3.5000 then
            if self.Rings < 1.5000 then
              Res = self.C_FALSE;
            else
              if self.Mass < 303.4100 then
                if self.Ovality < 1.5900 then
                  Res = self.C_FALSE;
                else
                  Res = self.C_TRUE;
                end
              else
                Res = self.C_FALSE;
              end
            end
          else
            if self.Mass < 356.3800 then
              Res = self.C_FALSE;
            else
              if self.EzBnds < 0.5000 then
                Res = self.C_FALSE;
              else
                if self.Mass < 362.3900 then
                  Res = self.C_TRUE;
                else
                  Res = self.C_FALSE;
                end
              end
            end
          end
        else
          if self.Sdiam < 10.9700 then
            if self.Lipole < 2.3800 then
              if self.HbAcc < 3.5000 then
                Res = self.C_TRUE;
              else
                Res = self.C_FALSE;
              end
            else
              Res = self.C_FALSE;
            end
          else
            if self.VirtualLogP < 3.4100 then
              if self.Dipole < 2.8300 then
                Res = self.C_FALSE;
              else
                Res = self.C_TRUE;
              end
            else
              Res = self.C_TRUE;
            end
          end
        end
      end
    else
      if self.FlexTorsions < 1.0000 then
        Res = self.C_TRUE;
      else
        if self.Ovality < 1.7300 then
          Res = self.C_FALSE;
        else
          if self.Psa < 59.6600 then
            if self.HeavyAtoms < 31.0000 then
              if self.Bonds < 51.5000 then
                Res = self.C_FALSE;
              else
                Res = self.C_TRUE;
              end
            else
              if self.FlexTorsions < 9.0000 then
                Res = self.C_FALSE;
              else
                Res = self.C_TRUE;
              end
            end
          else
            if self.FG_PhOH == self.C_FG_PHOH_YES then
              if self.Angles < 119.5000 then
                Res = self.C_TRUE;
              else
                if self.Angles < 230.0000 then
                  Res = self.C_FALSE;
                else
                  if self.ChiralAtms < 21.5000 then
                    Res = self.C_FALSE;
                  else
                    Res = self.C_TRUE;
                  end
                end
              end
            else
              if self.FG_F == self.C_FG_F_YES then
                if self.ChiralAtms < 1.5000 then
                  Res = self.C_TRUE;
                else
                  if self.Vdiam < 9.0700 then
                    Res = self.C_FALSE;
                  else
                    Res = self.C_TRUE;
                  end
                end
              else
                if self.Lipole < 2.3100 then
                  if self.FlexTorsions < 8.5000 then
                    if self.Sas < 977.1200 then
                      if self.EzBnds < 0.5000 then
                        if self.ChiralAtms < 0.5000 then
                          if self.Mass < 441.2400 then
                            Res = self.C_TRUE;
                          else
                            Res = self.C_FALSE;
                          end
                        else
                          Res = self.C_FALSE;
                        end
                      else
                        if self.Bonds < 59.0000 then
                          Res = self.C_FALSE;
                        else
                          Res = self.C_TRUE;
                        end
                      end
                    else
                      Res = self.C_TRUE;
                    end
                  else
                    Res = self.C_FALSE;
                  end
                else
                  Res = self.C_FALSE;
                end
              end
            end
          end
        end
      end
    end
  end

  return Res
end


---- Domain check method ----

--
-- Return the number of domain violations
--

function random_tree:DomCheck()
  local Violations = 0

  if self.Angles < 6.00000000 or self.Angles > 374.00000000 then Violations = Violations + 1 end
  if self.Atoms < 5.00000000 or self.Atoms > 203.00000000 then Violations = Violations + 1 end
  if self.Bonds < 4.00000000 or self.Bonds > 206.00000000 then Violations = Violations + 1 end
  if self.ChiralAtms < 0.00000000 or self.ChiralAtms > 25.00000000 then Violations = Violations + 1 end
  if self.Dipole < 0.00001200 or self.Dipole > 22.36607000 then Violations = Violations + 1 end
  if self.EzBnds < 0.00000000 or self.EzBnds > 7.00000000 then Violations = Violations + 1 end
  if self.FlexTorsions < 0.00000000 or self.FlexTorsions > 28.00000000 then Violations = Violations + 1 end
  if self.Gyrrad < 1.41856400 or self.Gyrrad > 10.56297000 then Violations = Violations + 1 end
  if self.HbAcc < 0.00000000 or self.HbAcc > 26.00000000 then Violations = Violations + 1 end
  if self.HbDon < 0.00000000 or self.HbDon > 21.00000000 then Violations = Violations + 1 end
  if self.HeavyAtoms < 3.00000000 or self.HeavyAtoms > 101.00000000 then Violations = Violations + 1 end
  if self.Lipole < 0.00000300 or self.Lipole > 6.34667600 then Violations = Violations + 1 end
  if self.Mass < 70.08984000 or self.Mass > 1449.25400000 then Violations = Violations + 1 end
  if self.Ovality < 1.16274900 or self.Ovality > 2.74024100 then Violations = Violations + 1 end
  if self.Psa < 0.00000000 or self.Psa > 544.81690000 then Violations = Violations + 1 end
  if self.Rings < 0.00000000 or self.Rings > 10.00000000 then Violations = Violations + 1 end
  if self.Sas < 203.40610000 or self.Sas > 2006.11400000 then Violations = Violations + 1 end
  if self.Sav < 252.97150000 or self.Sav > 3811.29900000 then Violations = Violations + 1 end
  if self.Sdiam < 5.14906200 or self.Sdiam > 22.48208000 then Violations = Violations + 1 end
  if self.Torsions < 0.00000000 or self.Torsions > 94.00000000 then Violations = Violations + 1 end
  if self.Vdiam < 4.77512900 or self.Vdiam > 13.58132000 then Violations = Violations + 1 end
  if self.VirtualLogP < -7.13032600 or self.VirtualLogP > 9.48374900 then Violations = Violations + 1 end

  return Violations
end
