Skip to content

Instantly share code, notes, and snippets.

@chakib-belgaid
Created May 22, 2015 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chakib-belgaid/06879179dcd468743302 to your computer and use it in GitHub Desktop.
Save chakib-belgaid/06879179dcd468743302 to your computer and use it in GitHub Desktop.
gsat_heuristiques
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="DependencyValidationManager">
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectModuleManager">
<modules />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.4.3 (C:\Python34\python.exe)" project-jdk-type="Python SDK" />
<component name="RunManager">
<list size="0" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/sat.iml" filepath="$PROJECT_DIR$/.idea/sat.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
__author__ = 'chakib'
class sat:
def __init__(self , clauses ):
self.clauses = clauses.copy()
self.maxi = -1 ;
for i in clauses :
for j in i :
if abs(j) > self.maxi : self.maxi = abs(j)
def interpreter(self, interpretation) :
cpt = 0
for c in self.clauses :
if sat.satisfait(c,interpretation ):cpt +=1
return cpt
def satisfait(c, interpretation):
var = False
for i in c :
if c[i] > 0 :
var = var or (c[i] in interpretation )
else:
var = var or not (-c[i] in interpretation)
return var
def list_interpreter(self, interpretation ):
l = []
for i in self.clauses
c = [[1,-2],[1,0]]
s = sat(c)
i = s.interpreter([1])
print(s.maxi)
#print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment