Artificial Intelligence
Artificial Intelligence
Demonstration

      We offer a demonstration of an expert system of financial investment advice. The 'investment' is a small base of 17 facts and 13 rules. It offers investment of money solutions differences taking into account interest rates, inflation, accepted risk ...etc.

This demonstration is just one example of integration of an expert system in a Web application, do not too take the result seriously that it gives, and do not take into account the amounts that she advises.

      You can change the rates, amounts, choose the options accepted risk, and availability desired to observe the investment Council that has three data: sum savings, shares and bonds.


Bond rate
Inflation rate
Savings rate
Sum max savings
Sum to place
Accepted risk
Availability desired

Sum actions
Sum savings
Sum bond


      In this example, we use AJAX technology to query a web service in which we integrate an expert system to answer and provide financial investment advice. We want just to demonstrate the integration of our ielib.dll component in a web application in ASP.Net.

      

      With our software VESD that we designed this knowledge base that we call the 'investment '.

      

      

      The following source code shows the integration of artificial intelligence in the web service, using the objects InferenceEngine and KnowledgeBase.


    [WebMethod]
    public InvestResult DemoInvest(int iOpRisk, int iOpAvailability, float fRateBond,
                                float fRateInflation, float fRateSaving, double dMaxSavings,
                                double dSumPlace)
    {
        InvestResult result = new InvestResult();
        InferenceEngine ie = new InferenceEngine();
        HttpContext context = HttpContext.Current;

        if (context != null)
        {
            HttpServerUtility myserver = context.Server;

            ie.CurrentBase.LoadFrom(myserver.MapPath(ConfigurationManager.AppSettings["InvestBase"]));
        }
        result.bResolu = false;
        result.SumActions = result.SumBond = result.SumSavings = 0.0;
        if (!ie.CurrentBase.IsEmpty)
        {
            KnowledgeBase kb = ie.CurrentBase;

            SetFactValue(kb.GetFactById(13), dSumPlace); // Sum to place
            SetFactSymbolValue(kb.GetFactById(1), iOpAvailability); // Availability
            SetFactValue(kb.GetFactById(15), fRateSaving); // Rate Savings
            SetFactSymbolValue(kb.GetFactById(7), iOpRisk); // Risk
            SetFactValue(kb.GetFactById(17), fRateBond); // Rate bond
            SetFactValue(kb.GetFactById(14), dMaxSavings); // Sum max savings
            SetFactValue(kb.GetFactById(16), fRateInflation); // Rate inflation

            ChainingResult res = ie.Run();

            if (res.Result == ChainingResult.ExecuteResult.Conclusion)
            {
                Fact f;

                for (int i = 0; i < res.Count; i++)
                {
                    f = res[i];
                    switch (f.Id)
                    {
                        case 6: // Resolve
                            result.bResolu = (bool)f.Value;
                            break;
                        case 8: // sum actions
                            result.SumActions = (double)f.Value;
                            break;
                        case 9: // sum savings
                            result.SumSavings = (double)f.Value;
                            break;
                        case 10: // sum bond
                            result.SumBond = (double)f.Value;
                            break;
                        default: break;
                    }
                }
            }
        }
        return result;
    }

    #region Private section
    private void SetFactValue(Fact f, object oVal)
    {
        if (f != null) f.SetValue(oVal);
    }

    private void SetFactSymbolValue(Fact f, int iOpIndex)
    {
        if (f != null)
            f.SetValue((string)f.SymbolsList[iOpIndex]);
    }
    #endregion