%defines: implementation(hashlist). implementation(linkedlist). implementation(treelist). implementation(computation). operation(at). operation(sort). operation(insert). operation(seqaccess). connection_type(ct_inherits). connection_type(ct_convert). relation (recommends). relation (satisfied). relation(unsupported). relation_score(satisfied, 0). relation_score(recommends, 1). relation_score(unsupported, -1). %integration facts: relation_op(seqaccess, computation, recommends). relation_op(seqaccess, hashlist, unsupported). relation_op(at, hashlist, recommends). relation_op(at,treelist, satisfied). relation_op(sort, linkedlist, satisfied). relation_op(sort, treelist, satisfied). relation_op(sort, hashlist, unsupported). %static analysis: var(a).var(tmp2). var(b). var(tmp3). var(tmp4). var_connection(a, tmp2). bind_var_op(tmp2, seqaccess). var_connection(tmp2, b). var_connection(tmp2, b, ct_inherits). var_connection(b, tmp3). bind_var_op(tmp3, seqaccess). bind_var_op(tmp4, sort). %domain rules: impl_fulfill(OP, IMPL, SCORE):- relation_op(OP, IMPL, RL), relation_score(RL, SCORE), operation(OP), implementation(IMPL), RL!=unsupported. impl_not_fulfill(OP, IMPL):- relation_op(OP, IMPL, unsupported). impl_avail(VAR, IMPL) :- not impl_not_fulfill(OP, IMPL) : bind_var_op(VAR, OP), var(VAR), implementation(IMPL). %reasoning rules: 1{setup_impl(VAR, IMPL) : implementation(IMPL) }1 :- var(VAR). :- setup_impl(VAR, IMPL), not impl_avail(VAR, IMPL). var_connection(VAR1, VAR2, ct_convert) :- var(VAR1), var(VAR2), var_connection(VAR1, VAR2), setup_impl(VAR1, IMPL1), setup_impl(VAR2, IMPL2), IMPL1 != IMPL2. :- var(VAR1), var(VAE2), 2{var_connection(VAR1, VAR2, _)} . setup_var_impl_fulfill(VAR, SCORE) :- SCORE := #min[impl_fulfill(OP, IMPL, RATE): bind_var_op(VAR, OP) = RATE], var(VAR). model_score_convert(SCORE) :- SCORE := #count{var_connection(VAR1, VAR2, ct_convert): var(VAR1) : var(VAR2)}. model_score_impl(SCORE) :- SCORE:= [setup_var_fulfill(VAR, RATE): var(VAR) = RATE]. %pretty output: #hide. #show setup_impl/2. #show model_score/1. #show setup_var_impl_fulfill/2. %#show var_connection/3. %#show bind_var_impl/3. %#show var_cluster_owner/1. %#show var_connection/3. %#show bind_var_op/2.