Prolog Electricity consumers are supplied with electricity from an electricity g
ID: 3848715 • Letter: P
Question
Prolog
Electricity consumers are supplied with electricity from an electricity generating station. Electricity is distributed from the main power station to the various consumers (Ci) through a network of transformers (Tj) as shown in the diagram below.
Nodes C1 to C10 are consumers; nodes T1 to T6 are transformers. Each consumer has a direct connection to only one transformer. Sometimes a transformer may malfunction or need to be taken out of service temporarily.
(a) Devise a list data structure in Prolog to represent networks like this.
(b) Write a Prolog program to define predicate supplies such that goal supplies( X, Y ) succeeds when there is an electricity supply from node X to node Y in the network.
(c) Run and test your Prolog code from (a) and (b). Document your results.
(d) Explain how to enhance your representation to permit multiple connections that can be used to make a supply around a transformer that has been taken out of service. Note: The supplies predicate may contain arguments in addition to X and Y at your discretion.
ci T4 C2 T1 C3 C4 T5 Station T2 C6 C7 C5 C8 T6 T3 C9 C10Explanation / Answer
[T1,T2,T3]
[[T4,T5],[C6,C7],[T6,C10]]
[[C1,C2,C3],[C4,C5],[],[C8,C9],[]]
If [T1,T4,T5] is matched to [X | Y],then X = T1 and Y = [T4,T5].
If [T2,C6,C7] is matched to the pattern [X|Y], then X = T2, Y = C6,C7
If [T3,T6,C10] is matched to [X|Y], then X = T3, Y = [T6,C10]
If [T4,C1,C2,C3] is matched to [X|Y], then X =T4, Y = C1,C2,C3
If [T5,C4,C5] is matched to [X|Y], then X =T5, Y = C4,C5
If [C6,C7,[]] is matched to [X|Y], then X =C6,C7 Y = []
If [T6,C8,C9] is matched to [X|Y], then X =T6, Y = C8,C9
If [C10,[]] is matched to [X|Y], then X =C10, Y = []
Lets see what happends when we ask some simple queries
?- p([T1,T4,T5], X, Y)
X=T1
Y=[T4,T5]
Yes
?- p([T4,C1,C2,C10],X, Y)
X=T4
Y=[C1,C2,C10]
No
as so on......
Three phase is used so often for power distributin systems.we would be able to step up and down. you can varity of configurations.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.