Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate tests #31

Merged
merged 18 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/asp/kids-bike-coom.lp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
coom_structure("product").
coom_feature("product","color","Color",1,1).
coom_feature("product","wheelSupport","bool",1,1).
coom_feature("product","wheelSupport","Bool",1,1).
coom_feature("product","frontWheel","Wheel",1,1).
coom_feature("product","rearWheel","Wheel",1,1).

Expand Down
8 changes: 4 additions & 4 deletions examples/asp/kids-bike.lp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ range("Wheel.size",14,20).
% domain("Wheel.size",18).
% domain("Wheel.size",20).

discrete("bool").
domain("bool", "True").
domain("bool", "False").
discrete("Bool").
domain("Bool", "True").
domain("Bool", "False").

% Complete instance tree
type("root","product").
Expand All @@ -48,7 +48,7 @@ type("root.rearWheel[0].size[0]","Wheel.size").
parent("root.rearWheel[0].size[0]","root.rearWheel[0]").
index("root.rearWheel[0].size[0]",0).

type("root.wheelSupport[0]","bool").
type("root.wheelSupport[0]","Bool").
parent("root.wheelSupport[0]", "root").
index("root.wheelSupport[0]",0).

Expand Down
2 changes: 1 addition & 1 deletion examples/coom/kids-bike.coom
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

product {
Color color
bool wheelSupport
Bool wheelSupport
Wheel frontWheel
Wheel rearWheel
}
Expand Down
2 changes: 1 addition & 1 deletion examples/coom/pc.coom
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ product {
Efficiency efficiency
num 2500-2500 maxPrice
num 0-2500 price
bool internetConn
Bool internetConn
1..2 HDUnit hdunit
Motherboard motherboard
1..2 Screen screen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coom_structure("product").
coom_feature("product","wheelSupport","bool",1,1).
coom_feature("product","wheelSupport","Bool",1,1).
coom_feature("product","wheel","Wheel",1,1).

coom_enumeration("Wheel").
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coom_structure("product").
coom_feature("product","wheelSupport","bool",1,1).
coom_feature("product","wheelSupport","Bool",1,1).
coom_feature("product","wheel","Wheel",2,2).

coom_structure("Wheel").
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
coom_structure("product").
coom_feature("product","wheel","Wheel",1,1).
coom_feature("product","wheelSupport","bool",1,1).
coom_feature("product","wheelSupport","Bool",1,1).

coom_enumeration("Wheel").
coom_option("Wheel", "Small").
Expand Down
15 changes: 15 additions & 0 deletions examples/tests/preprocess/conditional_require_undef.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
coom_structure("product").
coom_feature("product","Size","size",1,1).
coom_enumeration("Size").
coom_option("Size","Small").
coom_option("Size","Big").

coom_behavior(("product",0)).
coom_condition(("product",0),"color=Silver").
coom_binary("color=Silver","color","=","Silver").
coom_path("color",0,"color").
coom_constant("Silver").
coom_require(("product",0),"size=Big").
coom_binary("size=Big","size","=","Big").
coom_path("size",0,"size").
coom_constant("Big").
11 changes: 11 additions & 0 deletions examples/tests/preprocess/count.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
coom_structure("product").
coom_feature("product","bag","Bag",0,3).
coom_structure("Bag").

coom_behavior(0).
coom_context(0,"product").
coom_require(0,"count(bag)<=2").
coom_binary("count(bag)<=2","count(bag)","<=","2").
coom_function("product","count(bag)","count","bag").
coom_path("bag",0,"bag").
coom_number("2",2).
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
coom_structure("product").
coom_feature("product","a","num",1,1).
coom_range("product","a",1,3).
coom_range("product","a",1,1).
coom_feature("product","b","num",1,1).
coom_range("product","b",3,4).
coom_range("product","b",3,3).

coom_behavior(0).
coom_context(0,"product").
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
structure("product").
feature("product","storageNeeded","bool",1,1).
feature("product","storageNeeded","Bool",1,1).
feature("product","bag","Bag",0,1).

structure("Bag").
Expand Down
11 changes: 11 additions & 0 deletions examples/tests/preprocess/sum.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
coom_structure("product").
coom_feature("product","x","num",0,3).
coom_range("product","x",0,10).

coom_behavior(0).
coom_context(0,"product").
coom_require(0,"sum(x)<=10").
coom_binary("sum(x)<=10","sum(x)","<=","10").
coom_function("product","sum(x)","sum","x").
coom_path("x",0,"x").
coom_number("10",10).
21 changes: 21 additions & 0 deletions examples/tests/solve/count.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
part("product").
part("X").
type("root.x[0]","X").
type("root.x[1]","X").
type("root.x[2]","X").
parent("root.x[0]","root").
parent("root.x[1]","root").
parent("root.x[2]","root").
index("root.x[0]",0).
index("root.x[1]",1).
index("root.x[2]",2).

constraint((0,"count(root.x)=2"),"boolean").
binary("count(root.x)=2","count(root.x)","=","2").
function("count(root.x)","count","root.x").
set("root.x","root.x[0]").
set("root.x","root.x[1]").
set("root.x","root.x[2]").
number("2",2).

constraint(("root.x",0),"lowerbound").
18 changes: 18 additions & 0 deletions examples/tests/solve/max.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
part("product").
integer("X").
range("X",3,4).
type("root.x[0]","X").
type("root.x[1]","X").
parent("root.x[0]","root").
parent("root.x[1]","root").
index("root.x[0]",0).
index("root.x[1]",1).

constraint((0,"max(root.x)=3"),"boolean").
binary("max(root.x)=3","max(root.x)","=","3").
function("max(root.x)","max","root.x").
set("root.x","root.x[0]").
set("root.x","root.x[1]").
number("3",3).

constraint(("root.x",2),"lowerbound").
18 changes: 18 additions & 0 deletions examples/tests/solve/min.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
part("product").
integer("X").
range("X",3,4).
type("root.x[0]","X").
type("root.x[1]","X").
parent("root.x[0]","root").
parent("root.x[1]","root").
index("root.x[0]",0).
index("root.x[1]",1).

constraint((0,"min(root.x)=3"),"boolean").
binary("min(root.x)=3","min(root.x)","=","3").
function("min(root.x)","min","root.x").
set("root.x","root.x[0]").
set("root.x","root.x[1]").
number("3",3).

constraint(("root.x",2),"lowerbound").
18 changes: 18 additions & 0 deletions examples/tests/solve/sum.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
part("product").
integer("X").
range("X",1,2).
type("root.x[0]","X").
type("root.x[1]","X").
parent("root.x[0]","root").
parent("root.x[1]","root").
index("root.x[0]",0).
index("root.x[1]",1).

constraint((0,"sum(root.x)=3"),"boolean").
binary("sum(root.x)=3","sum(root.x)","=","3").
function("sum(root.x)","sum","root.x").
set("root.x","root.x[0]").
set("root.x","root.x[1]").
number("3",3).

constraint(("root.x",2),"lowerbound").
25 changes: 25 additions & 0 deletions examples/tests/solve/table_discrete.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
part("product").
discrete("A").
domain("A",("A1";"A2";"A3")).
type("root.x[0]","A").
type("root.y[0]","A").
parent("root.x[0]","root").
parent("root.y[0]","root").
index("root.x[0]",0).
index("root.y[0]",0).

constraint((0,"root"),"table").
column((0,"root"),0,0,"root.x[0]").
column((0,"root"),0,1,"root.y[0]").
allow(0,(0,0),"A1").
allow(0,(1,0),"A2").
allow(0,(1,0),"A3").
allow(0,(0,1),"A2").
allow(0,(1,1),"A1").
allow(0,(0,2),"A3").
allow(0,(1,2),"A2").

constraint(("root.x",1),"lowerbound").
set("root.x","root.x[0]").
constraint(("root.y",1),"lowerbound").
set("root.y","root.y[0]").
25 changes: 25 additions & 0 deletions examples/tests/solve/table_integer.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
part("product").
integer("A").
range("A",1,3).
type("root.x[0]","A").
type("root.y[0]","A").
parent("root.x[0]","root").
parent("root.y[0]","root").
index("root.x[0]",0).
index("root.y[0]",0).

constraint((0,"root"),"table").
column((0,"root"),0,0,"root.x[0]").
column((0,"root"),0,1,"root.y[0]").
allow(0,(0,0),1).
allow(0,(1,0),2).
allow(0,(1,0),3).
allow(0,(0,1),2).
allow(0,(1,1),1).
allow(0,(0,2),3).
allow(0,(1,2),2).

constraint(("root.x",1),"lowerbound").
set("root.x","root.x[0]").
constraint(("root.y",1),"lowerbound").
set("root.y","root.y[0]").
27 changes: 27 additions & 0 deletions examples/tests/solve/table_mixed.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
part("product").
discrete("A").
domain("A",("A1";"A2";"A3")).
integer("B").
range("B",1,3).
type("root.x[0]","A").
type("root.y[0]","B").
parent("root.x[0]","root").
parent("root.y[0]","root").
index("root.x[0]",0).
index("root.y[0]",0).

constraint((0,"root"),"table").
column((0,"root"),0,0,"root.x[0]").
column((0,"root"),0,1,"root.y[0]").
allow(0,(0,0),"A1").
allow(0,(1,0),2).
allow(0,(1,0),3).
allow(0,(0,1),"A2").
allow(0,(1,1),1).
allow(0,(0,2),"A3").
allow(0,(1,2),2).

constraint(("root.x",1),"lowerbound").
set("root.x","root.x[0]").
constraint(("root.y",1),"lowerbound").
set("root.y","root.y[0]").
17 changes: 17 additions & 0 deletions examples/tests/solve/table_undef.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
part("product").
discrete("A").
domain("A",("A1";"A2")).
type("root.x[0]","A").
parent("root.x[0]","root").
index("root.x[0]",0).


constraint((0,"root"),"table").
column((0,"root"),0,0,"root.x[0]").
column((0,"root"),0,1,"root.y[0]").
allow(0,(0,0),"A1").
allow(0,(1,0),"A2").
allow(0,(1,0),"A3").

constraint(("root.x",1),"lowerbound").
set("root.x","root.x[0]").
21 changes: 21 additions & 0 deletions examples/tests/solve/table_wildcard.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
part("product").
discrete("A").
domain("A",("A1";"A2")).
type("root.x[0]","A").
type("root.y[0]","A").
parent("root.x[0]","root").
parent("root.y[0]","root").
index("root.x[0]",0).
index("root.y[0]",0).

constraint((0,"root"),"table").
column((0,"root"),0,0,"root.x[0]").
column((0,"root"),0,1,"root.y[0]").
allow(0,(0,0),"A1").
allow(0,(1,0),"A1").
allow(0,(0,1),"A2").

constraint(("root.x",1),"lowerbound").
set("root.x","root.x[0]").
constraint(("root.y",1),"lowerbound").
set("root.y","root.y[0]").
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
EDITABLE_TESTS = True
PYTHON_VERSIONS = ["3.12"]
if "GITHUB_ACTIONS" in os.environ:
PYTHON_VERSIONS = ["3.9", "3.11"]
PYTHON_VERSIONS = ["3.11"]
EDITABLE_TESTS = False


Expand Down
16 changes: 13 additions & 3 deletions src/coomsuite/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,26 @@ def main():
elif args.command == "solve":
log.info("Converting and solving COOM file %s", args.input)
with TemporaryDirectory() as temp_dir:
options = (
clingo_options = (
[convert_instance(args.input, "model", temp_dir)]
+ ([convert_instance(args.user_input, "user", temp_dir)] if args.user_input else [])
+ unknown_args
)

if args.show_facts:
options.append("--outf=3")
clingo_options.append("--outf=3")

clingo_main(COOMApp(solver=args.solver, output=args.output, show_facts=args.show_facts), options)
options = {
"solver": args.solver,
"output_format": args.output,
"show_facts": args.show_facts,
"preprocess": True,
}

clingo_main(
COOMApp(options=options),
clingo_options,
)


if __name__ == "__main__":
Expand Down
Loading
Loading