Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
removed reduction from all reasoning modes but minimal inconsisten cores
Browse files Browse the repository at this point in the history
  • Loading branch information
sthiele committed Jun 2, 2014
1 parent b0936d6 commit 4ee11fb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.5.3
----------------
fixed bug, caused by reduction applied to other other reasoning modes than minimal inconsitent cores

1.5.2
----------------
use pyasp-1.3.3
Expand Down
1 change: 0 additions & 1 deletion ingranalyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
repair_options = query.get_repair_options_add_edges(net_with_data)
print 'done.'


print '\nCompute minimal numbers of necessary repair operations ...',
optimum = query.get_minimum_of_repairs(net_with_data, repair_options)
print 'done.'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run(self):

setup(cmdclass={'install': install},
name='ingranalyze',
version='1.5.2',
version='1.5.3',
url='http://pypi.python.org/pypi/ingranalyze/',
license='GPLv3+',
description='Influence graph analysis, consistency check, diagnosis, repair and prediction.',
Expand Down
54 changes: 29 additions & 25 deletions src/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def get_consistent_labelings(instance,nmodels=0,exclude=[]):
representing (maybe partial) solutions that are to be avoided. If [nmodels] equals [0]
then the list contain all feasible models.
'''
inputs = get_reductions(instance)
prg = [ consistency_prg, inputs.to_file(), instance.to_file(), exclude_sol(exclude) ]
#inputs = get_reductions(instance)
inst = instance.to_file()
prg = [ consistency_prg, inst, exclude_sol(exclude) ]
co= str(nmodels)
solver = GringoClasp(clasp_options=co)
models = solver.run(prg)
os.unlink(prg[1])
os.unlink(inst)
os.unlink(prg[2])
os.unlink(prg[3])
return models


Expand Down Expand Up @@ -166,28 +166,32 @@ def get_repair_options_add_edges(instance):


def get_minimum_of_repairs(instance,repair_options,exclude=[]):
inputs = get_reductions(instance)
instance2 = instance.union(inputs)
prg = [ instance2.to_file(),repair_options.to_file(), exclude_sol(exclude), repair_core_prg, repair_cardinality_prg ]
#inputs = get_reductions(instance)
#instance2 = instance.union(inputs)
inst = instance.to_file()
repops = repair_options.to_file()
prg = [ inst, repops, exclude_sol(exclude), repair_core_prg, repair_cardinality_prg ]

solver = GringoClasp()
optimum = solver.run(prg)
os.unlink(prg[0])
os.unlink(prg[1])
os.unlink(inst)
os.unlink(repops)
os.unlink(prg[2])
return optimum[0]


def get_minimal_repair_sets(instance, repair_options ,optimum,nmodels=0,exclude=[]):
inputs = get_reductions(instance)
instance2 = instance.union(inputs)
prg = [ instance2.to_file(), repair_options.to_file(), exclude_sol(exclude), repair_core_prg, repair_cardinality_prg ]
#inputs = get_reductions(instance)
#instance2 = instance.union(inputs)
inst = instance.to_file()
repops = repair_options.to_file()
prg = [ inst, repops, exclude_sol(exclude), repair_core_prg, repair_cardinality_prg ]

options='--project --opt-mode=optN '+str(nmodels)
solver = GringoClasp(clasp_options=options)
models = solver.run(prg, collapseTerms=True, collapseAtoms=False)
os.unlink(prg[0])
os.unlink(prg[1])
os.unlink(inst)
os.unlink(repops)
os.unlink(prg[2])
return models

Expand All @@ -198,16 +202,17 @@ def get_predictions_under_minimal_repair(instance, repair_options, optimum):
derived from [instance], minus those that are a direct consequence
of obs_[ev]label predicates
'''
inputs = get_reductions(instance)
instance2 = instance.union(inputs)

prg = [ instance2.to_file(), repair_options.to_file(), prediction_core_prg, repair_cardinality_prg ]
#inputs = get_reductions(instance)
#instance2 = instance.union(inputs)
inst = instance.to_file()
repops = repair_options.to_file()
prg = [ inst, repops, prediction_core_prg, repair_cardinality_prg ]

options='--project --enum-mode cautious --opt-mode=optN --opt-bound='+str(optimum)
solver = GringoClasp(clasp_options=options)
models = solver.run(prg, collapseTerms=True, collapseAtoms=False)
os.unlink(prg[0])
os.unlink(prg[1])
os.unlink(inst)
os.unlink(repops)
return whatsnew(instance,models[0])


Expand Down Expand Up @@ -239,13 +244,12 @@ def get_predictions_under_consistency(instance):
derived from [instance], minus those that are a direct consequence
of obs_[ev]label predicates
'''
inputs = get_reductions(instance)

prg = [ prediction_prg, inputs.to_file(), instance.to_file(), exclude_sol([]) ]
#inputs = get_reductions(instance)
inst = instance.to_file()
prg = [ prediction_prg, inst, exclude_sol([]) ]
solver = GringoClasp(clasp_options='--project --enum-mode cautious')
models = solver.run(prg, collapseTerms=True, collapseAtoms=False)
os.unlink(prg[1])
os.unlink(inst)
os.unlink(prg[2])
os.unlink(prg[3])
return whatsnew(instance,models[0])

0 comments on commit 4ee11fb

Please sign in to comment.