You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
863 B

5 years ago
  1. #!/usr/bin/env python3
  2. import util.script as script
  3. import mysql.connector
  4. from util.kSAT import kSAT
  5. def main():
  6. edb = script.connect_to_experimetns_db("database.config")
  7. idb = script.connect_to_instance_pool("database.config")["experiments"]
  8. cursor = edb.cursor()
  9. insert_row = ("INSERT INTO degree_of_variables "
  10. "(instance, variable, degree) "
  11. "VALUES (%s, %s, %s)")
  12. for instance in idb["instances"].find():
  13. sat = kSAT()
  14. for clause in instance["clauses"]:
  15. sat.addClause(clause)
  16. for variable, degree in sat.getDegreesOfVariables().items():
  17. cursor.execute(insert_row, (str(instance["_id"]), variable, degree))
  18. edb.commit()
  19. cursor.close()
  20. edb.close()
  21. if __name__ == "__main__":
  22. main()