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

Nico/preprocess facts #14

Merged
merged 41 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d736a47
first ideas on processed fact format
Apr 17, 2024
ed2b85f
further ideas
Apr 17, 2024
0d1935f
rewrote core and kids bike with processed fact format
Apr 18, 2024
96a1863
rewritten partonomy encoding and city bike
Apr 18, 2024
467135d
started preprocess encoding
Apr 18, 2024
7772280
added aux_instance to preprocess.lp
Apr 18, 2024
01e74ce
Merge branch 'nico/tests' into nico/preprocess-facts
Apr 19, 2024
6da689f
preprocess converts to dot path format
Apr 19, 2024
60d8955
changed fact format for constraints and combinations. added require a…
Apr 19, 2024
16a9a38
preprocess.lp works for kids and city bike
Apr 19, 2024
033de15
minor
Apr 19, 2024
5758018
fix bug with boolean enum
May 8, 2024
429fa06
root is empty string. renamed instance/2 predicate to included/1 and …
May 10, 2024
88fa211
modularized encodings and added core and partonomy for fclingo
May 10, 2024
432b57e
implemented preprocessing for clingo. trying for fclingo
May 10, 2024
051a3fa
fclingo integration for core and partonomy
May 10, 2024
f4a105b
fixed coom output format
May 10, 2024
0e75b08
fixed pylint and typecheck
May 10, 2024
3c415dd
fixed almost all tests
May 10, 2024
be68475
fixed fclingo test
May 13, 2024
2b1962e
Merge branch 'master' into nico/preprocess-facts
nrueh May 13, 2024
e139a52
removed duplicate test
May 13, 2024
c46e6a5
added numeric encoding for preprocessed facts
May 13, 2024
1ec0a70
preprocess encoding extended for numerics. integrated into package fo…
May 13, 2024
49ccea1
fix parsing imply test
May 13, 2024
1c5bff2
added numeric encoding for fclingo
May 13, 2024
69aa803
renamed some encoding variables
May 14, 2024
51aff74
minor
May 14, 2024
3ef3042
feedback from think tank 2.
May 15, 2024
b8fc137
adapted tests to new predicate names
nrueh May 16, 2024
d72c6bd
removed context argument coom_binary/5
nrueh May 16, 2024
207605d
minor
nrueh May 16, 2024
63fef57
using uniform type/2 predicate
nrueh May 17, 2024
76442f9
added option to show preprocessing. fixed bug with condition.
nrueh May 17, 2024
09e802f
fixed clingo numeric bug. default rules for undefined arithmetics.
nrueh May 17, 2024
8f3aa07
fixed typecheck
nrueh May 17, 2024
0ddecc0
made num/1 into type/2 as well
nrueh May 17, 2024
73edb44
organized preprocess.lp
nrueh May 17, 2024
692f88c
val/2 predicates only added for testing in fclingo. otherwise during …
nrueh May 17, 2024
6da16be
fixed asp examples
nrueh May 17, 2024
7220fcf
renamed asp instances
nrueh May 20, 2024
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ _autosummary
# ANTLR4
.antlr


default.profraw
96 changes: 51 additions & 45 deletions doc/content/factformat.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Fact format of instances
The instances are generated automatically by parsing a COOM file. We describe here the ASP fact format used for the translation.
The instances are generated automatically by parsing a COOM file.
We describe here the ASP fact format used for the translation.
We prefix every predicate by `coom_` to make distinguish the predicates here
from the processed predicates used later in the encoding.


TODO: Add prefix

## Building up a product domain

### Structure
A COOM product can be made up of a hierarchical component structure.
The building blocks of the product can be defined by the predicate `structure/1`.

> **Note:** Every product has at least the `structure(":root")` predicate at the top of the hierarchy.
> **Note:** Every product has at least the `structure("")` predicate at the top of the hierarchy.

```prolog
structure(Name).
Expand All @@ -18,7 +24,7 @@ Parameters:

Examples:
```prolog
structure(":root").
structure("").
structure("Carrier").
```

Expand All @@ -44,8 +50,8 @@ Numeric features are accompanied by a `range/4` predicate.

Examples:
```prolog
feature(":root","totalWeight","num",1,1).
feature(":root","rearWheel","Wheel",1,1).
feature("","totalWeight","num",1,1).
feature("","rearWheel","Wheel",1,1).
feature("Carrier","bags","Bag",0,3).
feature("Frame","bags","Bag",2,2).
```
Expand All @@ -66,10 +72,10 @@ Parameters:

Examples:
```prolog
range(":root","totalWeight",#inf,#sup).
range(":root","maxWeight",1,100).
range(":root","totalVolume",0,200).
range(":root","requestedVolume",0,200).
range("","totalWeight",#inf,#sup).
range("","maxWeight",1,100).
range("","totalVolume",0,200).
range("","requestedVolume",0,200).
```
> **Note:** When no range is specified in COOM the translation makes use of the
clingo built-in `#inf` and `#sup` operators.
Expand All @@ -80,7 +86,7 @@ Enumerations represent features with a finite domain of predefined choices.
The predicate `enumeration/1` declares an enumeration field and
is always accompanied at least by `option/2` predicates specifying the possible choices.
Optionally, enumerations can also contain attributes such that each option comes along with a fixed set of values.
These are specified by predicates `attribute/3` and `attr_value/4`.
These are specified by predicates `attribute/3` and `attribute_value/4`.


```prolog
Expand Down Expand Up @@ -136,7 +142,7 @@ attribute("Capacity","weight","num").
Assigns an attribute value to an enumeration option.

```prolog
attr_value(NameOfEnumeration,NameOfOption,NameOfAttribute,AttributeValue).
attribute_value(NameOfEnumeration,NameOfOption,NameOfAttribute,AttributeValue).
```

Parameters:
Expand All @@ -147,14 +153,14 @@ Parameters:

Examples:
```prolog
attr_value("Capacity","B10","volume",10).
attr_value("Capacity","B10","weight",100).
attr_value("Capacity","B20","volume",20).
attr_value("Capacity","B20","weight",250).
attr_value("Capacity","B50","volume",50).
attr_value("Capacity","B50","weight",600).
attr_value("Capacity","B100","volume",100).
attr_value("Capacity","B100","weight",1200).
attribute_value("Capacity","B10","volume",10).
attribute_value("Capacity","B10","weight",100).
attribute_value("Capacity","B20","volume",20).
attribute_value("Capacity","B20","weight",250).
attribute_value("Capacity","B50","volume",50).
attribute_value("Capacity","B50","weight",600).
attribute_value("Capacity","B100","volume",100).
attribute_value("Capacity","B100","weight",1200).
```

## Constraints
Expand All @@ -173,8 +179,8 @@ Parameters:

Examples:
```prolog
behavior((":root",0)).
behavior((":root",1)).
behavior(("",0)).
behavior(("",1)).
behavior(("Bag",7)).
```

Expand All @@ -198,10 +204,10 @@ Parameters:

Examples:
```prolog
require((":root",0),"count(carrier.bags)+count(frame.bags)<=4").
require((":root",2),"totalWeight<=maxWeight").
require((":root",4),"totalVolume>=requestedVolume").
require((":root",6),"frontWheel.size=20").
require(("",0),"count(carrier.bags)+count(frame.bags)<=4").
require(("",2),"totalWeight<=maxWeight").
require(("",4),"totalVolume>=requestedVolume").
require(("",6),"frontWheel.size=20").
```


Expand All @@ -222,8 +228,8 @@ Parameters:

Examples:
```prolog
condition((":root",6),"color=Red").
condition((":root",0),"color=Yellow").
condition(("",6),"color=Red").
condition(("",0),"color=Yellow").
```


Expand All @@ -242,8 +248,8 @@ Parameters:

Examples:
```prolog
imply((":root",1),"totalWeight","frontWheel.weight+rearWheel.weight").
imply((":root",3),"totalVolume","sum(carrier.bags.capacity.volume)+sum(frame.bags.capacity.volume)").
imply(("",1),"totalWeight","frontWheel.weight+rearWheel.weight").
imply(("",3),"totalVolume","sum(carrier.bags.capacity.volume)+sum(frame.bags.capacity.volume)").
```

### Combinations
Expand All @@ -262,8 +268,8 @@ Parameters:

Examples:
```prolog
combinations((":root",1),0,"wheelSupport").
combinations((":root",1),1,"rearWheel").
combinations(("",1),0,"wheelSupport").
combinations(("",1),1,"rearWheel").
```

> **Note:** Longer paths can be formed in COOM by concatenating paths with a dot ('.').
Expand All @@ -286,12 +292,12 @@ Parameters:

Examples:
```prolog
allow((":root",1),(0,0),"True").
allow((":root",1),(1,0),"W14").
allow((":root",1),(1,0),"W16").
allow((":root",1),(0,1),"False").
allow((":root",1),(1,1),"W18").
allow((":root",1),(1,1),"W20").
allow(("",1),(0,0),"True").
allow(("",1),(1,0),"W14").
allow(("",1),(1,0),"W16").
allow(("",1),(0,1),"False").
allow(("",1),(1,1),"W18").
allow(("",1),(1,1),"W20").
```

### Unary
Expand All @@ -318,10 +324,10 @@ Parameters:

Examples:
```prolog
binary(":root","color=Red","color","=","Red").
binary(":root","frontWheel.size=20","frontWheel.size","=","20").
binary(":root","count(carrier.bags)+count(frame.bags)<=4","count(carrier.bags)+count(frame.bags)","<=","4").
binary(":root","count(carrier.bags)+count(frame.bags)","count(carrier.bags)","+","count(frame.bags)").
binary("","color=Red","color","=","Red").
binary("","frontWheel.size=20","frontWheel.size","=","20").
binary("","count(carrier.bags)+count(frame.bags)<=4","count(carrier.bags)+count(frame.bags)","<=","4").
binary("","count(carrier.bags)+count(frame.bags)","count(carrier.bags)","+","count(frame.bags)").
binary("Bag","material=Leather","material","=","Leather").
```

Expand All @@ -344,10 +350,10 @@ Parameters:

Examples:
```prolog
function(":root","count(carrier.bags)","count","carrier.bags").
function(":root","count(frame.bags)","count","frame.bags").
function(":root","sum(carrier.bags.capacity.weight)","sum","carrier.bags.capacity.weight").
function(":root","sum(frame.bags.capacity.weight)","sum","frame.bags.capacity.weight").
function("","count(carrier.bags)","count","carrier.bags").
function("","count(frame.bags)","count","frame.bags").
function("","sum(carrier.bags.capacity.weight)","sum","carrier.bags.capacity.weight").
function("","sum(frame.bags.capacity.weight)","sum","frame.bags.capacity.weight").
```

### Path expressions
Expand Down
134 changes: 134 additions & 0 deletions examples/asp/city-bike-coom.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
coom_structure("product").
coom_feature("product","color","Color",1,1).
coom_feature("product","basket","Basket",0,1).
coom_feature("product","saddle","Saddle",1,1).
coom_feature("product","frontWheel","Wheel",1,1).
coom_feature("product","rearWheel","Wheel",1,1).
coom_feature("product","carrier","Carrier",1,1).

coom_structure("Basket").
coom_feature("Basket","position","Position",1,1).
coom_feature("Basket","color","Color",1,1).

coom_structure("Carrier").
coom_feature("Carrier","bag","Bag",0,2).

coom_structure("Bag").
coom_feature("Bag","capacity","Capacity",1,1).
coom_feature("Bag","material","Material",1,1).

coom_enumeration("Color").
coom_option("Color", "Silver").
coom_option("Color", "White").
coom_option("Color", "Black").
coom_option("Color", "Blue").

coom_enumeration("Position").
coom_option("Position", "Front").
coom_option("Position", "Back").

coom_enumeration("Saddle").
coom_option("Saddle", "Standard").
coom_option("Saddle", "Comfort").
coom_option("Saddle", "Vintage").

coom_enumeration("Wheel").
coom_attribute("Wheel","size","num").
coom_option("Wheel", "W26").
coom_attribute_value("Wheel","W26","size",26).
coom_option("Wheel", "W27").
coom_attribute_value("Wheel","W27","size",27).
coom_option("Wheel", "W28").
coom_attribute_value("Wheel","W28","size",28).
coom_option("Wheel", "W29").
coom_attribute_value("Wheel","W29","size",29).

coom_enumeration("Capacity").
coom_attribute("Capacity","volume","num").
coom_option("Capacity", "B10").
coom_attribute_value("Capacity","B10","volume",10).
coom_option("Capacity", "B20").
coom_attribute_value("Capacity","B20","volume",20).
coom_option("Capacity", "B50").
coom_attribute_value("Capacity","B50","volume",50).
coom_option("Capacity", "B100").
coom_attribute_value("Capacity","B100","volume",100).

coom_enumeration("Material").
coom_option("Material", "Cotton").
coom_option("Material", "Leather").
coom_option("Material", "Polyester").

coom_behavior(0).
coom_context(0,"product").
coom_require(0,"color=basket.color").
coom_binary("color=basket.color","color","=","basket.color").
coom_path("color",0,"color").
coom_path("basket.color",0,"basket").
coom_path("basket.color",1,"color").

coom_behavior(1).
coom_context(1,"product").
coom_condition(1,"basket.position=Front").
coom_binary("basket.position=Front","basket.position","=","Front").
coom_path("basket.position",0,"basket").
coom_path("basket.position",1,"position").
coom_constant("Front").
coom_require(1,"frontWheel.size<29").
coom_binary("frontWheel.size<29","frontWheel.size","<","29").
coom_path("frontWheel.size",0,"frontWheel").
coom_path("frontWheel.size",1,"size").
coom_number("29",29).

coom_behavior(2).
coom_context(2,"product").
coom_condition(2,"carrier.bag.capacity.volume=100").
coom_binary("carrier.bag.capacity.volume=100","carrier.bag.capacity.volume","=","100").
coom_path("carrier.bag.capacity.volume",0,"carrier").
coom_path("carrier.bag.capacity.volume",1,"bag").
coom_path("carrier.bag.capacity.volume",2,"capacity").
coom_path("carrier.bag.capacity.volume",3,"volume").
coom_number("100",100).
coom_require(2,"rearWheel.size>=28").
coom_binary("rearWheel.size>=28","rearWheel.size",">=","28").
coom_path("rearWheel.size",0,"rearWheel").
coom_path("rearWheel.size",1,"size").
coom_number("28",28).

coom_behavior(3).
coom_context(3,"product").
coom_condition(3,"saddle=Vintage").
coom_binary("saddle=Vintage","saddle","=","Vintage").
coom_path("saddle",0,"saddle").
coom_constant("Vintage").
coom_require(3,"carrier.bag.material=Leather").
coom_binary("carrier.bag.material=Leather","carrier.bag.material","=","Leather").
coom_path("carrier.bag.material",0,"carrier").
coom_path("carrier.bag.material",1,"bag").
coom_path("carrier.bag.material",2,"material").
coom_constant("Leather").

coom_behavior(4).
coom_context(4,"product").
coom_require(4,"frontWheel.size=rearWheel.size").
coom_binary("frontWheel.size=rearWheel.size","frontWheel.size","=","rearWheel.size").
coom_path("frontWheel.size",0,"frontWheel").
coom_path("frontWheel.size",1,"size").
coom_path("rearWheel.size",0,"rearWheel").
coom_path("rearWheel.size",1,"size").

coom_behavior(5).
coom_context(5,"Bag").
coom_combinations(5,0,"material").
coom_combinations(5,1,"capacity").
coom_path("material",0,"material").
coom_path("capacity",0,"capacity").
coom_allow(5,(0,0),"Leather").
coom_allow(5,(1,0),"B10").
coom_allow(5,(0,1),"Cotton").
coom_allow(5,(1,1),"B20").
coom_allow(5,(1,1),"B50").
coom_allow(5,(0,2),"Polyester").
coom_allow(5,(1,2),"B20").
coom_allow(5,(1,2),"B50").
coom_allow(5,(1,2),"B100").
Loading