////////////////////////////////////////////////////////////////////
// SysAdmin Boolean MDP 
//
// An example RDDL description for the well-known SysAdmin problem
// (Guestrin, Koller, Parr, IJCAI-01).
//
// Author: Scott Sanner (ssanner [at] gmail.com)
////////////////////////////////////////////////////////////////////
domain sysadmin_mdp {
  
	requirements = { 
		reward-deterministic // this domain does not use a stochastic reward
	};
	
	types {
  		computer : object;
	};
      
	pvariables { 
    		  		    		  		
		REBOOT-PROB : { non-fluent, real, default = 0.1 };
		REBOOT-PENALTY : { non-fluent, real, default = 0.75 };

		CONNECTED(computer, computer) : { non-fluent, bool, default = false };

		running(computer) : { state-fluent, bool, default = false };
      
		reboot(computer) : { action-fluent, bool, default = false }; 
	};
	
	cpfs {
  
		running'(?x) = if (reboot(?x))
						then KronDelta(true)  // if computer is rebooted then must be running 
						else if (running(?x)) // otherwise outcome depends on network properties
							then Bernoulli(.45 + .5*[1 + sum_{?y : computer} (CONNECTED(?y,?x) ^ running(?y))] 
													/ [1 + sum_{?y : computer} CONNECTED(?y,?x)])
							else Bernoulli(REBOOT-PROB); 
	};
  
	reward = sum_{?c : computer} [running(?c) - (REBOOT-PENALTY * reboot(?c))];
}
