welcome: please sign in
location: attachment:company-controls.rfc.asp.txt of EncodingsExamples

Attachment 'company-controls.rfc.asp.txt'

Download

   1 % Company Controls
   2 
   3 % Input:
   4 % - company(C), for each company C
   5 % - owns(X,Y,S), if X owns S% of Y
   6 % - checkForMaxControls(C), if the solver must controls if C has the greater
   7 %   number of controlled companies.
   8 
   9 % Output:
  10 % - controls(X,Y), if the company X controls the company Y.
  11 
  12 % Author: Mario Alviano.
  13 
  14 
  15 % A company X can control something only if it has at least one direct control.
  16 canBeController(X) :- owns(X,Y,_), #sum{S : owns(X,Y,S)} > 50.
  17 
  18 % A company Y can be controlled only if more than 50% of its stocks is shared by
  19 % all the companies.
  20 canBeControlled(Y) :- company(Y), #sum{S,X : owns(X,Y,S)} > 50.
  21 
  22 % Each company controls the stocks directly owned.
  23 controls_stock(X,X,Y,S) :- canBeController(X), canBeControlled(Y), owns(X,Y,S).
  24 
  25 % A company controlling a company Z controls the stock owned by Z.
  26 controls_stock(X,Z,Y,S) :- controls(X,Z), canBeControlled(Y), owns(Z,Y,S).
  27 
  28 
  29 % A company controlling more than 50% of the stock of a company Y exerts 
  30 % controls on Y.
  31 controls(X,Y) :-
  32     50 < #sum{S,Z : controls_stock(X,Z,Y,S) }, canBeController(X), canBeControlled(Y).
  33 
  34 
  35 % For each company compute the number of controlled companies.
  36 count_controls(X,S) :- canBeController(X), #count{Y : controls(X,Y)} = S.
  37 
  38 % Check that no company controls more companies than X, if X is the company to
  39 % to be checked for maximal controls.
  40 :- checkForMaxControls(X), count_controls(X,S), 
  41    #max{N : count_controls(Y,N)} = SS, SS > S.

Attached Files

You are not allowed to attach a file to this page.