## Thinking Through Rules in C#

As I continue with writing the manuscript on rules engines, I've isolated my examples to be coincidental with the overall theme of engineering decision support applications. Today, I am taking a close look at the seemingly simple act of identifying and rejecting unattractive alternatives when competing projects are under review to determine whether or not a given project will warrant funding.

Some of the determining factors are well known algorithms in the financial world. Specifically I am thinking about the rate of return on investment (roi), present worth (pw), annual cost (euac), annual benefit (euab), benefit-cost ratio (bc), net present worth (npw).  Overall, these calculations can quickly help decide whether the minimum level of economic attractiveness is met by a project. I will elaborate on each of these later. For now, any of the methods may be used independently or collectively to ultimately reject a candidate project.

Before we translate this decision process to a specific rule engine implementation, Let's look at a class stub I wrote to think it through:

using System;
using System.Collections.Generic;
using System.Text;

namespace CapitalExpendProjProp
{
public class ProjectProposal
{
// MARR = minimum attractive rate of return
public int ProjectReview(string Project, string[] alternative, int MARR)
{
int roi, pwb, pwc, euac, euab, bc, npw, rejTally = 0;

foreach(string alt in alternative)
{
roi = rateOfReturn();
if (roi < MARR)
{ rejTally = rejTally + 1; } // REJECT

pwb = presentWorthBenefits();
pwc = presentWorthCosts();

if (pwb < pwc)
{ rejTally = rejTally + 1; } //REJECT

euac = AnnualCost();
euab = AnnualBenefit();

if (euac > euab)
{ rejTally = rejTally + 1; } //REJECT

bc = BenefitCostRatio();

if (bc < 1)
{ rejTally = rejTally + 1; } //REJECT

npw = NetPresentWorth();
if (npw < 0)
{ rejTally = rejTally + 1; } //REJECT
}

return rejTally;
}
}
}

Friday, March 7, 2008 2:51 PM