//==============================================================================
//The Society of Actuaries (SOA) makes this computer model and its computer
//code available to its members for educational purposes. The model and its
//code may be modified and redistributed without prior authorization from the
//SOA. The SOA distributes this computer model and its computer code in the
//hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
//implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//PURPOSE.
//==============================================================================

package agents;

import implementation.SimulationUserPanel;
import java.util.ListIterator;
import repast.simphony.context.Context;
import repast.simphony.engine.environment.RunEnvironment;
import repast.simphony.parameter.Parameter;
import repast.simphony.ui.probe.ProbeID;
import resources.AgentID;
import resources.Constants;
import resources.Constants.GoalDescription;
import resources.Constants.PlanTag;
import resources.InsurancePlan;
import agents.Agent;

@SuppressWarnings("unused")
public class HealthInsuranceCompany extends Agent
{
//==============================================================================
// Attribute variables
// These variables do not change during the agent's life (unless the user
// changes an attribute parameter during a simulation).
//------------------------------------------------------------------------------ 
// Note that the agent's goals are also attributes.
    private double lapseThreshold;
    private double premiumDiscountFactor;
    private double maximumOfferIncreasePercent;
    private double copaymentPercentage_Plan2;
    private double competitorCopaymentPercentage_Plan2;

//==============================================================================

//==============================================================================
// Memory variables
// These variables can change during an agent's life.
// There are two types of memory variables:
// 1. Currently updated variables:  Variables that the agent updates during the
//    period to which they apply.
// 2. Previously updated variables:  Variables that the agent updates during the
//    period prior to the period in which they apply.
//------------------------------------------------------------------------------

    //1. Currently updated memory variables
    // Variables from p1_SetPremiumRates()
    private double currentPremium_Plan1;
    private double currentPremium_Plan2;
    private double priorPremium_Plan1;
    private double priorPremium_Plan2;
    private double currentPremiumRateIncreaseLimit_Plan1;
    private double currentPremiumRateIncreaseLimit_Plan2;
    private double currentProfitMaximizingPremium_Plan1;
    private double currentProfitMaximizingPremium_Plan2;
    private boolean currentLapseRateProblem_Plan1;
    private boolean currentLapseRateProblem_Plan2;
    private double currentCompetitivePremium_Plan1;
    private double currentCompetitivePremium_Plan2;
    private double priorCompetitorPremium_Plan1;
    private double priorCompetitorPremium_Plan2;

    // Variables from p2_ProvideRiskExperience()
    private double currentAverageDiseaseStatus_Plan1;
    private double currentAverageDiseaseStatus_Plan2;

    //Variables from p3_ProvideProfitExperience()
    private double currentPremiumIncome_Plan1;
    private double currentPremiumIncome_Plan2;
    private double currentPremiumReallocationAmount_Plan1;
    private double currentPremiumReallocationAmount_Plan2;
    private double currentClaimsPaid_Plan1;
    private double currentClaimsPaid_Plan2;
    private double currentProfit_Plan1;
    private double currentProfit_Plan2;
    private double currentProfit_Total;
    private double currentProfitPercentage_Plan1;
    private double currentProfitPercentage_Plan2;
    private double currentProfitPercentage_Total;

    //Variables from p4_NegotiateTreatmentCostAlpha()
    private int currentNegotiationRound;
    private double currentTreatmentCostAlpha;
    private double priorTreatmentCostAlpha;
    private double currentNetPremiumsReceived_Plan1;
    private double currentNetPremiumsReceived_Plan2;
    private double currentTreatmentCostAlphaMaximum;
    private double currentTreatmentCostAlphaOffer;
    private double currentTreatemntCostAlphaResponse;


    //2. Previously updated memory variables
    private double nextCurrentTreatmentCostAlpha;

//==============================================================================

//==============================================================================
// Other variables
// These are other variables used in the class.
//------------------------------------------------------------------------------
    private static double currentAccumulatedProfit_PlanA1;
    private static double currentAccumulatedProfit_PlanA2;
    private static double currentAccumulatedProfit_TotalA;
    private static double currentAccumulatedProfit_PlanB1;
    private static double currentAccumulatedProfit_PlanB2;
    private static double currentAccumulatedProfit_TotalB;

    private Context<Object> simulationContext;
    private double tickCount;

//==============================================================================
// Method:  HealthInsuranceCompany() constructor
//------------------------------------------------------------------------------

    public HealthInsuranceCompany(Context<Object> pContext, AgentID pHealthInsuranceCompanyID)
    {

        setAgentID(pHealthInsuranceCompanyID);
        simulationContext = pContext;

        init_InitializeVariables_Constructor();

    }//end HealthInsuranceCompany()

//==============================================================================


//==============================================================================
// Methods: Initialization methods for the agent. These are used in
//          the agent's constructor method or at the beginning of each
//          simulation period.
//==============================================================================

//==============================================================================
// Method:  init_InitializeVariables_Constructor()
// The constructor does the following:
// 1. Initializes variables that remain constant throughout
//    an agent's life (unless the user changes parameters).
//    These are the agent's "attribute" variables.
// 2. Initializes the value of all other variables.
// This method gives a valid (non-null) value to all the agent's variables.
//------------------------------------------------------------------------------
    private void init_InitializeVariables_Constructor()
    {

        // 1. Initialize "attribute" variables.
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            this.setAgentFirstPriorityGoalDescription(Environment.getPrimaryGoal_CompanyA());
            this.setAgentFirstPriorityGoalDescription(Environment.getPrimaryGoal_CompanyA());
            lapseThreshold = SimulationUserPanel.getLapseThreshold_CompanyA();
            premiumDiscountFactor = SimulationUserPanel.getPremiumDiscountFactor_CompanyA();
            maximumOfferIncreasePercent = SimulationUserPanel.getMaximumOfferIncreasePercent_CompanyA();
            copaymentPercentage_Plan2 = Environment.getCopaymentPercentage_PlanA2();
            competitorCopaymentPercentage_Plan2 = Environment.getCopaymentPercentage_PlanB2();
        }//end if
        else
        {
            this.setAgentFirstPriorityGoalDescription(Environment.getPrimaryGoal_CompanyB());
            this.setAgentFirstPriorityGoalDescription(Environment.getPrimaryGoal_CompanyB());
            lapseThreshold = SimulationUserPanel.getLapseThreshold_CompanyB();
            premiumDiscountFactor = SimulationUserPanel.getPremiumDiscountFactor_CompanyB();
            maximumOfferIncreasePercent = SimulationUserPanel.getMaximumOfferIncreasePercent_CompanyB();
            copaymentPercentage_Plan2 = Environment.getCopaymentPercentage_PlanB2();
            competitorCopaymentPercentage_Plan2 = Environment.getCopaymentPercentage_PlanA2();
        }//end else

        // 2. Initialize the value of all other variables.
        currentPremium_Plan1 = 0.0;
        currentPremium_Plan2 = 0.0;
        priorPremium_Plan1 = 0.0;
        priorPremium_Plan2 = 0.0;
        currentPremiumRateIncreaseLimit_Plan1 = 0.0;
        currentPremiumRateIncreaseLimit_Plan2 = 0.0;
        currentProfitMaximizingPremium_Plan1 = 0.0;
        currentProfitMaximizingPremium_Plan2 = 0.0;
        currentLapseRateProblem_Plan1 = false;
        currentLapseRateProblem_Plan2 = false;
        currentCompetitivePremium_Plan1 = 0.0;
        currentCompetitivePremium_Plan2 = 0.0;
        priorCompetitorPremium_Plan1 = 0.0;
        priorCompetitorPremium_Plan2 = 0.0;
        currentAverageDiseaseStatus_Plan1 = 0.0;
        currentAverageDiseaseStatus_Plan2 = 0.0;
        currentPremiumIncome_Plan1 = 0.0;
        currentPremiumIncome_Plan2 = 0.0;
        currentPremiumReallocationAmount_Plan1 = 0.0;
        currentPremiumReallocationAmount_Plan2 = 0.0;
        currentClaimsPaid_Plan1 = 0.0;
        currentClaimsPaid_Plan2 = 0.0;
        currentProfit_Plan1 = 0.0;
        currentProfit_Plan2 = 0.0;
        currentProfit_Total = 0.0;
        currentProfitPercentage_Plan1 = 0.0;
        currentProfitPercentage_Plan2 = 0.0;
        currentProfitPercentage_Total = 0.0;
        currentNegotiationRound = Constants.FIRST;
        currentTreatmentCostAlpha = 0.0;
        priorTreatmentCostAlpha = 0.0;
        currentNetPremiumsReceived_Plan1 = 0.0;
        currentNetPremiumsReceived_Plan2 = 0.0;
        currentTreatmentCostAlphaMaximum = 0.0;
        currentTreatmentCostAlphaOffer = 0.0;
        currentTreatemntCostAlphaResponse = 0.0;
        nextCurrentTreatmentCostAlpha = 0.0;
        currentAccumulatedProfit_PlanA1 = 0.0;
        currentAccumulatedProfit_PlanA2 = 0.0;
        currentAccumulatedProfit_TotalA = 0.0;
        currentAccumulatedProfit_PlanB1 = 0.0;
        currentAccumulatedProfit_PlanB2 = 0.0;
        currentAccumulatedProfit_TotalB = 0.0;


    }//end init_InitializeVariables_Constructor()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  init_InitializeVariables_BOP() (beginning of period)
// This method does the following:
// 1. Updates attribute variables. If the user changes an attribute parameter
//    during a simulation, these may change.
// 2. Updates the prior period values of all variables (after the first period).
// 3. Provides "current" values for certain variables that the agent
//    does not set at the beginning of the period with a separate behavior.
//    This is done for those variables will be needed by behaviors of this agent
//    or by other agents during the period.
// 4. Re-initialize all CURRENT (NOT PRIOR) variables (except those that would cause
//    display or chart problems (flickering, etc.).
// 5. removes agents that have died.
//------------------------------------------------------------------------------
    public void init_InitializeVariables_BOP()
    {

        // 1. Update attribute variables.
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            this.setAgentFirstPriorityGoalDescription(Environment.getPrimaryGoal_CompanyA());
            this.setAgentFirstPriorityGoalDescription(Environment.getPrimaryGoal_CompanyA());
            lapseThreshold = SimulationUserPanel.getLapseThreshold_CompanyA();
            premiumDiscountFactor = SimulationUserPanel.getPremiumDiscountFactor_CompanyA();
            maximumOfferIncreasePercent = SimulationUserPanel.getMaximumOfferIncreasePercent_CompanyA();
            copaymentPercentage_Plan2 = Environment.getCopaymentPercentage_PlanA2();
            competitorCopaymentPercentage_Plan2 = Environment.getCopaymentPercentage_PlanB2();
        }//end if
        else
        {
            this.setAgentFirstPriorityGoalDescription(Environment.getPrimaryGoal_CompanyB());
            this.setAgentFirstPriorityGoalDescription(Environment.getPrimaryGoal_CompanyB());
            lapseThreshold = SimulationUserPanel.getLapseThreshold_CompanyB();
            premiumDiscountFactor = SimulationUserPanel.getPremiumDiscountFactor_CompanyB();
            maximumOfferIncreasePercent = SimulationUserPanel.getMaximumOfferIncreasePercent_CompanyB();
            copaymentPercentage_Plan2 = Environment.getCopaymentPercentage_PlanB2();
            competitorCopaymentPercentage_Plan2 = Environment.getCopaymentPercentage_PlanA2();
        }//end else

        // 2. Update prior period values of all variables (after the first period).
        tickCount = RunEnvironment.getInstance().getCurrentSchedule().getTickCount();
        if (tickCount >= 1.0)
        {
            priorPremium_Plan1 = currentPremium_Plan1;
            priorPremium_Plan2 = currentPremium_Plan2;
            priorTreatmentCostAlpha = currentTreatmentCostAlpha;
        }//end if

        // 3. Provide "current" values for certain variables that the agent does not set at the
        //    beginning of the period with a separate behavior.
        // Note that the agent does not set the treatment cost alpha by a special behavior
        // until the second period.
        if (tickCount < 1.0)
        {
            if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
            {
                currentTreatmentCostAlpha = Environment.getInitialTreatmentCostAlpha_CompanyA();
            }//end if
            else
            {
                currentTreatmentCostAlpha = Environment.getInitialTreatmentCostAlpha_CompanyB();
            }//end else
        }//end if
        else currentTreatmentCostAlpha = nextCurrentTreatmentCostAlpha;

        // 4. Re-initialize all CURRENT (NOT PRIOR) variables (except those that would cause
        //    display or chart problems (flickering, etc.).
        currentPremium_Plan1 = 0.0;
        currentPremium_Plan2 = 0.0;
        currentPremiumRateIncreaseLimit_Plan1 = 0.0;
        currentPremiumRateIncreaseLimit_Plan2 = 0.0;
        currentProfitMaximizingPremium_Plan1 = 0.0;
        currentProfitMaximizingPremium_Plan2 = 0.0;
        currentLapseRateProblem_Plan1 = false;
        currentLapseRateProblem_Plan2 = false;
        currentCompetitivePremium_Plan1 = 0.0;
        currentCompetitivePremium_Plan2 = 0.0;
        priorCompetitorPremium_Plan1 = 0.0; // This variable is recalculated during the period.
        priorCompetitorPremium_Plan2 = 0.0; // This variable is recalculated during the period.
        currentAverageDiseaseStatus_Plan1 = 0.0;
        currentAverageDiseaseStatus_Plan2 = 0.0;
        currentPremiumIncome_Plan1 = 0.0;
        currentPremiumIncome_Plan2 = 0.0;
        currentPremiumReallocationAmount_Plan1 = 0.0;
        currentPremiumReallocationAmount_Plan2 = 0.0;
        currentClaimsPaid_Plan1 = 0.0;
        currentClaimsPaid_Plan2 = 0.0;
        currentProfit_Plan1 = 0.0;
        currentProfit_Plan2 = 0.0;
        currentProfit_Total = 0.0;
        currentProfitPercentage_Plan1 = 0.0;
        currentProfitPercentage_Plan2 = 0.0;
        currentProfitPercentage_Total = 0.0;
        currentNegotiationRound = Constants.FIRST;
//        currentTreatmentCostAlpha = 0.0; // This variable is initialized above.
        currentNetPremiumsReceived_Plan1 = 0.0;
        currentNetPremiumsReceived_Plan2 = 0.0;
        currentTreatmentCostAlphaMaximum = 0.0;
        currentTreatmentCostAlphaOffer = 0.0;
        currentTreatemntCostAlphaResponse = 0.0;
        nextCurrentTreatmentCostAlpha = 0.0;
//        currentAccumulatedProfit_PlanA1 = 0.0; // this is a static variable. Do not initialize.
//        currentAccumulatedProfit_PlanA2 = 0.0; // this is a static variable. Do not initialize.
//        currentAccumulatedProfit_TotalA = 0.0; // this is a static variable. Do not initialize.
//        currentAccumulatedProfit_PlanB1 = 0.0; // this is a static variable. Do not initialize.
//        currentAccumulatedProfit_PlanB2 = 0.0; // this is a static variable. Do not initialize.
//        currentAccumulatedProfit_TotalB = 0.0; // this is a static variable. Do not initialize.

        // 5. Remove agents that have died
        // None

    }//end init_InitializeVariables_BOP()
//------------------------------------------------------------------------------

//==============================================================================

//==============================================================================
// Methods:  "Input" methods for the agent. These are described in the
// detailed description of the model. Each method is preceded by "i#".
//==============================================================================

// For this model, there are no such methods.

//==============================================================================

    
//==============================================================================
// Methods:  "Process" methods for the agent. These are described in the
// detailed description of the model. Each method is preceded by "p#"
// to indicate its number according to the numbering scheme used in the
// detailed description.
//==============================================================================

//==============================================================================
// Method:  p1_SetPremiumRates()
// This method sets the premium rates for the company's plans, and writes them
// to the InsurancePlan agents. For details about the method, see the detailed
// design document.
//------------------------------------------------------------------------------
    public void p1_SetPremiumRates()
    {
        tickCount = RunEnvironment.getInstance().getCurrentSchedule().getTickCount();

        if (tickCount < 1.0)
        {
            if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
            {
                currentPremium_Plan1 = Environment.getInitialPremium_PlanA1();
                currentPremium_Plan2 = Environment.getInitialPremium_PlanA2();
            }//end if
            else
            {
                currentPremium_Plan1 = Environment.getInitialPremium_PlanB1();
                currentPremium_Plan2 = Environment.getInitialPremium_PlanB2();
            }//end else
        }//end if
        else
        {
            switch (r1_GetFirstGoal())
            {
                case MaximizeProfit:
                {
                    r2_ComputeProfitMaximizingPremiums();
                    currentPremium_Plan1 = currentProfitMaximizingPremium_Plan1;
                    currentPremium_Plan2 = currentProfitMaximizingPremium_Plan2;
                    break;
                }//end case
                
                case MaximizeMarketShare:
                {
                    r3_IdentifyLapseRateProblem();

                    if (currentLapseRateProblem_Plan1 == true)
                    {
                        r4_ComputeCompetitivePremiums();
                        currentPremium_Plan1 = currentCompetitivePremium_Plan1;
                    }//end if
                    else
                    {
                        currentPremium_Plan1 = priorPremium_Plan1;
                    }//end else

                    if (currentLapseRateProblem_Plan2 == true)
                    {
                        r4_ComputeCompetitivePremiums();
                        currentPremium_Plan2 = currentCompetitivePremium_Plan2;
                    }//end if
                    else
                    {
                        currentPremium_Plan2 = priorPremium_Plan2;
                    }//end else

                    break;
                }//end case

                default:
                {
                // There should be no default
                    System.out.println("Error:  Unexpected switch default in Health Insurance Company p1_SetPremiumRates()");
                }//end case

                
            }//end switch
            
        }//end else

        // Set the relevant current and premium rates for the InsurancePlan classes.
        
        for (int k = 0; k < Constants.NUMBER_OF_HEALTH_INSURANCE_PLANS; k++)
        {
            switch (k)
            {
                case Constants.PLAN_A1:
                {
                    if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
                    {
                        Environment.getInsurancePlanList().get(Constants.PLAN_A1).setCurrentPremiumAmount(currentPremium_Plan1);
                        Environment.getInsurancePlanList().get(Constants.PLAN_A1).setPriorPremiumAmount(priorPremium_Plan1);
                        Environment.getInsurancePlanList().get(Constants.PLAN_A1).setCopaymentPercentage(0.0);
                    }//end if
                    break;
                }//end case
                
                case Constants.PLAN_A2:
                {
                    if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
                    {
                        Environment.getInsurancePlanList().get(Constants.PLAN_A2).setCurrentPremiumAmount(currentPremium_Plan2);
                        Environment.getInsurancePlanList().get(Constants.PLAN_A2).setPriorPremiumAmount(priorPremium_Plan2);
                        Environment.getInsurancePlanList().get(Constants.PLAN_A2).setCopaymentPercentage(copaymentPercentage_Plan2);
                    }//end if
                    break;
                 }//end case
                
                case Constants.PLAN_B1:
                {
                    if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
                    {
                        Environment.getInsurancePlanList().get(Constants.PLAN_B1).setCurrentPremiumAmount(currentPremium_Plan1);
                        Environment.getInsurancePlanList().get(Constants.PLAN_B1).setPriorPremiumAmount(priorPremium_Plan1);
                        Environment.getInsurancePlanList().get(Constants.PLAN_B1).setCopaymentPercentage(0.0);
                    }//end if
                    break;
                }//end case

                case Constants.PLAN_B2:
                {
                    if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
                    {
                        Environment.getInsurancePlanList().get(Constants.PLAN_B2).setCurrentPremiumAmount(currentPremium_Plan2);
                        Environment.getInsurancePlanList().get(Constants.PLAN_B2).setPriorPremiumAmount(priorPremium_Plan2);
                        Environment.getInsurancePlanList().get(Constants.PLAN_B2).setCopaymentPercentage(copaymentPercentage_Plan2);
                    }//end if
                    break;
                }//end case

                default:
                {
                // There should be no default
                    System.out.println("Error:  Unexpected switch default in Health Insurance Company p1_SetPremiumRates()");
                }//end case

            }//end switch
        }//end for

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Test 
// This block tests this method.
// To run the test, remove comments from the code below.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//    System.out.println("HealthInsuranceCompany p1_SetPremiumRates()at " +
//            RunEnvironment.getInstance().getCurrentSchedule().getTickCount());
//
//    System.out.println("Health Insurance Company ID:  " + this.getAgentID().getAgentIDString());
//    System.out.println("Health Insurance Company name:  " + this.getAgentName());
//    System.out.println("First priority goal:  " + this.getAgentFirstPriorityGoalDescription().toString());    
//    System.out.println("priorPremium_Plan1:  " + priorPremium_Plan1);
//    System.out.println("priorPremium_Plan2:  " + priorPremium_Plan2);
//    System.out.println("currentPremiumRateIncreaseLimit_Plan1:  " + currentPremiumRateIncreaseLimit_Plan1);
//    System.out.println("currentPremiumRateIncreaseLimit_Plan2:  " + currentPremiumRateIncreaseLimit_Plan2);
//    System.out.println("priorLapseRateProblem_Plan1:  " + currentLapseRateProblem_Plan1);
//    System.out.println("priorLapseRateProblem_Plan2:  " + currentLapseRateProblem_Plan2);
//    System.out.println("priorCompetitorPremium_Plan1:  " + priorCompetitorPremium_Plan1);
//    System.out.println("priorCompetitorPremium_Plan2:  " + priorCompetitorPremium_Plan2);
//    System.out.println("premiumDiscountFactor:  " + premiumDiscountFactor);
//    System.out.println("lapseThreshold:  " + lapseThreshold);
//    System.out.println("currentPremium_Plan1:  " + currentPremium_Plan1);
//    System.out.println("currentPremium_Plan2:  " + currentPremium_Plan2);
//    System.out.println("copaymentPercentage_Plan2:  " + copaymentPercentage_Plan2);
//    System.out.println("");
//    System.out.println("Insurance Plan results:");
//
//    ListIterator<InsurancePlan> iterator2 = Environment.getInsurancePlanList().listIterator();
//    while (iterator2.hasNext())
//    {
//        InsurancePlan insurancePlan2 = iterator2.next();
//        System.out.println("----------------");
//        System.out.println("Plan ID:  " + insurancePlan2.getAgentID().getAgentIDString());
//        System.out.println("getExchangePresentationOrder:  " + insurancePlan2.getCurrentExchangePresentationOrder());
//        System.out.println("xLocation:  " + insurancePlan2.getAgentXLocation());
//        System.out.println("yLocation:  " + insurancePlan2.getAgentYLocation());
//        System.out.println("currentPremiumAmount:  " + insurancePlan2.getCurrentPremiumAmount());
//        System.out.println("priorPremiumAmount:  " + insurancePlan2.getPriorPremiumAmount());
//        System.out.println("copaymentPercentage_Plan2:  " + insurancePlan2.getCopaymentPercentage());
//    }//end while
//    System.out.println("--------------------------------------");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    }//end p1_SetPremiumRates()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  p2_ProvideRiskExperience()
// The Health Insurance Company provides the Risk Adjustment Agency the
// results of Rule 5 (Compute average disease status)
//------------------------------------------------------------------------------
    public void p2_ProvideRiskExperience()
    {
        r5_ComputeAverageDiseaseStatus();
    }//end p2_ProvideRiskExperience()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  p3_ProvideProfitExperience()
// The company provides the Premium Rate Limit Agency the results
// of Rule 6 (Compute profit percentage)
//------------------------------------------------------------------------------
    public void p3_ProvideProfitExperience()
    {
        r6_ComputeProfitPercentage();
    }//end p3_ProvideProfitExperience()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  p4_NegotiateTreatmentCostAlpha()
// The treatment cost alpha for the first period is set by the
// initialization parameters A1 and A2 on the parameter pane. Thereafter,
// to negotiate alpha, the Health Insurance Company first offers the result
// of Rule 8 (Compute alpha level offer). It then responds to the
// Provider Network response with Rule 9 (Compute negotiation response).
// Lastly, it accepts the Provider Network’s second response.
//------------------------------------------------------------------------------
    public void p4_NegotiateTreatmentCostAlpha()
    {
        tickCount = RunEnvironment.getInstance().getCurrentSchedule().getTickCount();

        if (tickCount >= 0.0) // Even though it does nothing, this statement is left for future use.
        {
            switch (currentNegotiationRound)
            {
                case Constants.FIRST:
                {
                    r8_ComputeTreatmentCostAlphaOffer();
                    currentNegotiationRound = Constants.SECOND;
                    break;
                }//end case
                case Constants.SECOND:
                {
                    r9_ComputeNegotiationsResponse();
                    currentNegotiationRound = Constants.THIRD;
                    break;
                }//end case
                case Constants.THIRD:
                {
                    if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
                    {
                        nextCurrentTreatmentCostAlpha = Environment.getProviderNetworkList().get(Constants.PROVIDER_NETWORK_A).getNextCurrentTreatmentCostAlpha();
                        currentNegotiationRound = Constants.FIRST;
                    }//end if
                    else
                    {
                        nextCurrentTreatmentCostAlpha = Environment.getProviderNetworkList().get(Constants.PROVIDER_NETWORK_B).getNextCurrentTreatmentCostAlpha();
                        currentNegotiationRound = Constants.FIRST;
                    }//end else
                    break;
                }//end case

                default:
                {
                // There should be no default
                    System.out.println("Error:  Unexpected switch default in Health Insurance Company p4_NegotiateTreatmentCostAlpha()");
                }//end case

            }//end switch

        }//end if

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Test 
// This block tests this method.
// To run the test, remove comments from the code below.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//    System.out.println("HealthInsuranceCompany p4_NegotiateTreatmentCostAlpha() at " +
//            RunEnvironment.getInstance().getCurrentSchedule().getTickCount());
//
//    System.out.println("Health Insurance Company ID:  " + this.getAgentID().getAgentIDString());
//    System.out.println("Health Insurance Company name:  " + this.getAgentName());
//    System.out.println("currentNegotiationRound:  " + currentNegotiationRound);
//    System.out.println("currentTreatmentCostAlpha:  " + currentTreatmentCostAlpha);
//
//    System.out.println("currentNetPremiumsReceived_Plan1:  " + currentNetPremiumsReceived_Plan1);
//    System.out.println("currentNetPremiumsReceived_Plan2:  " + currentNetPremiumsReceived_Plan2);
//    System.out.println("currentClaimsPaid_Plan1:  " + currentClaimsPaid_Plan1);
//    System.out.println("currentClaimsPaid_Plan2:  " + currentClaimsPaid_Plan2);
//
//    System.out.println("currentTreatmentCostAlphaMaximum:  " + currentTreatmentCostAlphaMaximum);
//    System.out.println("maximumOfferIncreasePercent:  " + maximumOfferIncreasePercent);
//    System.out.println("currentTreatmentCostAlphaOffer:  " + currentTreatmentCostAlphaOffer);
//    System.out.println("currentTreatemntCostAlphaResponse:  " + currentTreatemntCostAlphaResponse);
//    System.out.println("nextCurrentTreatmentCostAlpha:  " + nextCurrentTreatmentCostAlpha);
//    System.out.println("--------------------------------------");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


    }//end p4_NegotiateTreatmentCostAlpha()
//------------------------------------------------------------------------------

//==============================================================================


//==============================================================================
// Methods:  "Rule" methods for the agent. These are described in the
// detailed description of the model. Each method is preceded by "r#"
// to indicate its number according to the numbering scheme used in the
// detailed description.
//==============================================================================

//==============================================================================
// Method:  r1_GetFirstGoal()
// Determine the Health Insurance Company’s first-priority goal.
//------------------------------------------------------------------------------
    private GoalDescription r1_GetFirstGoal()
    {
        return getAgentFirstPriorityGoalDescription();// From the Agent class

    }//end r1_GetFirstGoal()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  r2_ComputeProfitMaximizingPremiums()
// For each of the company’s plans, set the premium equal to the premium
// in the prior period times the premium rate increase limit for the period,
// provided by the Premium Rate Limit Agency.
// This method is applied after the first period.
//------------------------------------------------------------------------------
    private void r2_ComputeProfitMaximizingPremiums()
    {

        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            currentPremiumRateIncreaseLimit_Plan1 = Environment.getPremiumRateLimitAgencyList().get(0).getCurrentPremiumIncreaseLimit_PlanA1();
            currentPremiumRateIncreaseLimit_Plan2 = Environment.getPremiumRateLimitAgencyList().get(0).getCurrentPremiumIncreaseLimit_PlanA2();
        }//end if
        else
        {
            currentPremiumRateIncreaseLimit_Plan1 = Environment.getPremiumRateLimitAgencyList().get(0).getCurrentPremiumIncreaseLimit_PlanB1();
            currentPremiumRateIncreaseLimit_Plan2 = Environment.getPremiumRateLimitAgencyList().get(0).getCurrentPremiumIncreaseLimit_PlanB2();
        }//end else

        currentProfitMaximizingPremium_Plan1 = priorPremium_Plan1 * (1 + currentPremiumRateIncreaseLimit_Plan1);
        currentProfitMaximizingPremium_Plan2 = priorPremium_Plan2 * (1 + currentPremiumRateIncreaseLimit_Plan2);

    }//end r2_ComputeProfitMaximizingPremiums()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  r3_IdentifyLapseRateProblem()
// Determine if the lapse rate for each plan (the percentage of Person agents
// who dropped the plan in the current period) is greater than the company’s
// “lapse threshold” (a parameter). If it is, or if nobody chose the plan,
// return “TRUE”. Otherwise, return “FALSE”.
// Because of inadequate experience, for the first two simulation periods,
// the rule returns “FALSE”.
//------------------------------------------------------------------------------
    private void r3_IdentifyLapseRateProblem()
    {
        tickCount = RunEnvironment.getInstance().getCurrentSchedule().getTickCount();

        if (tickCount < 2.0)
        {
            currentLapseRateProblem_Plan1 = false;
            currentLapseRateProblem_Plan2 = false;
        }//end if
        else
        {
            ListIterator<Person> iterator = Environment.getPersonList().listIterator();
    
            int lapseCount_PlanA1 = 0;
            int lapseCount_PlanA2 = 0;
            int lapseCount_PlanB1 = 0;
            int lapseCount_PlanB2 = 0;
    
            int totalCount_PlanA1 = 0;
            int totalCount_PlanA2 = 0;
            int totalCount_PlanB1 = 0;
            int totalCount_PlanB2 = 0;
    
            while (iterator.hasNext())
            {
                Person person = iterator.next();
                switch (person.getPenultimatePlanChosen())
                {
                    case PlanA1:
                    {
                        totalCount_PlanA1 = totalCount_PlanA1 + 1;
                        if(person.getPriorPlanChosen() != person.getPenultimatePlanChosen())
                        {
                            lapseCount_PlanA1 = lapseCount_PlanA1 + 1;
                        }//end if
                        break;
                    }//end case
    
                    case PlanA2:
                    {
                        totalCount_PlanA2 = totalCount_PlanA2 + 1;
                        if(person.getPriorPlanChosen() != person.getPenultimatePlanChosen())
                        {
                            lapseCount_PlanA2 = lapseCount_PlanA2 + 1;
                        }//end if
                        break;
                    }//end case
    
                    case PlanB1:
                    {
                        totalCount_PlanB1 = totalCount_PlanB1 + 1;
                        if(person.getPriorPlanChosen() != person.getPenultimatePlanChosen())
                        {
                            lapseCount_PlanB1 = lapseCount_PlanB1 + 1;
                        }//end if
                        break;
                    }//end case
    
                    case PlanB2:
                    {
                        totalCount_PlanB2 = totalCount_PlanB2 + 1;
                        if(person.getPriorPlanChosen() != person.getPenultimatePlanChosen())
                        {
                            lapseCount_PlanB2 = lapseCount_PlanB2 + 1;
                        }//end if
                        break;
                    }//end case

                    case None:
                    {
                        // Do nothing
                        break;
                    }//end case

                    default:
                    {
                    // There should be no default
                        System.out.println("Error:  Unexpected switch default in Health Insurance Company r3_IdentifyLapseRateProblem()");
                    }//end case

                }//end switch
    
            }//end while

            double lapseRate_PlanA1 = 0.0;
            double lapseRate_PlanA2 = 0.0;
            double lapseRate_PlanB1 = 0.0;
            double lapseRate_PlanB2 = 0.0;

            if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
            {

                if (totalCount_PlanA1 == 0) lapseRate_PlanA1 = 0.0;
                else lapseRate_PlanA1 = (double) lapseCount_PlanA1/ (double) totalCount_PlanA1;

                if (totalCount_PlanA2 == 0) lapseRate_PlanA2 = 0.0;
                else lapseRate_PlanA2 = (double) lapseCount_PlanA2/ (double) totalCount_PlanA2;

                if ((totalCount_PlanA1  == 0) || (lapseRate_PlanA1 > lapseThreshold))
                    currentLapseRateProblem_Plan1 = true;
    
                if ((totalCount_PlanA2  == 0) || (lapseRate_PlanA2 > lapseThreshold))
                    currentLapseRateProblem_Plan2 = true;
    
            }//end if

            if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
            {

                if (totalCount_PlanB1 == 0) lapseRate_PlanB1 = 0.0;
                else lapseRate_PlanB1 = (double) lapseCount_PlanB1/ (double) totalCount_PlanB1;

                if (totalCount_PlanB2 == 0) lapseRate_PlanB2 = 0.0;
                else lapseRate_PlanB2 = (double) lapseCount_PlanB2/ (double) totalCount_PlanB2;

                if ((totalCount_PlanB1  == 0) || (lapseRate_PlanB1 > lapseThreshold))
                    currentLapseRateProblem_Plan1 = true;
    
                if ((totalCount_PlanB2  == 0) || (lapseRate_PlanB2 > lapseThreshold))
                    currentLapseRateProblem_Plan2 = true;
    
            }//end if


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Test 
// This block tests this method.
// To run the test, remove comments from the code below.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//    System.out.println("HealthInsuranceCompany r3_IdentifyLapseRateProblem()at " +
//            RunEnvironment.getInstance().getCurrentSchedule().getTickCount());
//
//    System.out.println("Health Insurance Company ID:  " + this.getAgentID().getAgentIDString());
//    System.out.println("Health Insurance Company name:  " + this.getAgentName());
//    System.out.println("lapseCount_PlanA1:  " + lapseCount_PlanA1);
//    System.out.println("lapseCount_PlanA2:  " + lapseCount_PlanA2);
//    System.out.println("lapseCount_PlanB1:  " + lapseCount_PlanB1);
//    System.out.println("lapseCount_PlanB2:  " + lapseCount_PlanB2);
//    System.out.println("totalCount_PlanA1:  " + totalCount_PlanA1);
//    System.out.println("totalCount_PlanA2:  " + totalCount_PlanA2);
//    System.out.println("totalCount_PlanB1:  " + totalCount_PlanB1);
//    System.out.println("totalCount_PlanB2:  " + totalCount_PlanB2);
//    System.out.println("lapseRate_PlanA1:  " + lapseRate_PlanA1);
//    System.out.println("lapseRate_PlanA2:  " + lapseRate_PlanA2);
//    System.out.println("lapseRate_PlanB1:  " + lapseRate_PlanB1);
//    System.out.println("lapseRate_PlanB2:  " + lapseRate_PlanB2);
//    System.out.println("lapseThreshold:  " + lapseThreshold);
//    System.out.println("currentLapseRateProblem_Plan1:  " + currentLapseRateProblem_Plan1);
//    System.out.println("currentLapseRateProblem_Plan2:  " + currentLapseRateProblem_Plan2);
//    System.out.println("--------------------------------------");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        }//end else

    }//end r3_IdentifyLapseRateProblem()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  r4_ComputeCompetitivePremium()
// For the relevant competitor’s plan, calculate the competitive premium
// as the competitor’s premium for the plan in the previous period, divided by
// the “premium discount factor” (a parameter), but not more than the
// profit maximizing premium for the company’s plan (the result of Rule 2).
// This is the premium that the Company believes would be competitive
// in the market place.
//------------------------------------------------------------------------------
    private void r4_ComputeCompetitivePremiums()
    {

        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            priorCompetitorPremium_Plan1 =
                    Environment.getHealthInsuranceCompanyList().get(Constants.HEALTH_INSURANCE_COMPANY_B).getPriorPremium_Plan1();
            priorCompetitorPremium_Plan2 =
                    Environment.getHealthInsuranceCompanyList().get(Constants.HEALTH_INSURANCE_COMPANY_B).getPriorPremium_Plan2();

        }//end if
        else
        {
            priorCompetitorPremium_Plan1 =
                    Environment.getHealthInsuranceCompanyList().get(Constants.HEALTH_INSURANCE_COMPANY_A).getPriorPremium_Plan1();
            priorCompetitorPremium_Plan2 =
                    Environment.getHealthInsuranceCompanyList().get(Constants.HEALTH_INSURANCE_COMPANY_A).getPriorPremium_Plan2();
        }//end else        priorCompetitorPremium_Plan1 = Environment

        r2_ComputeProfitMaximizingPremiums();

        currentCompetitivePremium_Plan1 = Math.min(priorCompetitorPremium_Plan1/premiumDiscountFactor, currentProfitMaximizingPremium_Plan1);
        currentCompetitivePremium_Plan2 = Math.min(priorCompetitorPremium_Plan2/premiumDiscountFactor, currentProfitMaximizingPremium_Plan2);

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Test 
// This block tests this method.
// To run the test, remove comments from the code below.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//    System.out.println("+++++++++++++++++");
//    System.out.println("HealthInsuranceCompany r4_ComputeCompetitivePremiums() at " +
//            RunEnvironment.getInstance().getCurrentSchedule().getTickCount());
//
//    System.out.println("Health Insurance Company ID:  " + this.getAgentID().getAgentIDString());
//    System.out.println("Health Insurance Company name:  " + this.getAgentName());
//
//    System.out.println("priorCompetitorPremium_Plan1:  " + priorCompetitorPremium_Plan1);    
//    System.out.println("priorCompetitorPremium_Plan2:  " + priorCompetitorPremium_Plan2);
//    System.out.println("premiumDiscountFactor:  " + premiumDiscountFactor);
//    System.out.println("currentProfitMaximizingPremium_Plan1:  " + currentProfitMaximizingPremium_Plan1);
//    System.out.println("currentProfitMaximizingPremium_Plan2:  " + currentProfitMaximizingPremium_Plan2);
//    System.out.println("currentCompetitivePremium_Plan1:  " + currentCompetitivePremium_Plan1);
//    System.out.println("currentCompetitivePremium_Plan2:  " + currentCompetitivePremium_Plan2);
//
//    System.out.println("+++++++++++++++++");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


    }//end r4_ComputeCompetitivePremiums()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  r5_ComputeAverageDiseaseStatus()
// Calculate the average disease status of Person agents for whom the
// Health Insurance Company paid claims in the previous period, for each
// of the company’s plans.
//------------------------------------------------------------------------------
    private void r5_ComputeAverageDiseaseStatus()
    {
        ListIterator<Person> iterator = Environment.getPersonList().listIterator();
        int numberOfPersonAgents_Plan1 = 0;
        int numberOfPersonAgents_Plan2 = 0;
        double totalDiseaseStatus_Plan1 = 0.0;
        double totalDiseaseStatus_Plan2 = 0.0;

        while (iterator.hasNext())
        {
            Person person = iterator.next();
            if (person.isCurrentExchangeParticipationStatus() == true)
            {
                switch (person.getCurrentPlanChosen())
                {
                    case PlanA1:
                    {
                        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
                        {
                            totalDiseaseStatus_Plan1 = totalDiseaseStatus_Plan1 + person.getCurrentDiseaseStatus();
                            numberOfPersonAgents_Plan1 = numberOfPersonAgents_Plan1 + 1;
                        }//end if
                        break;
                    }//end case
                    case PlanA2:
                    {
                        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
                        {
                            totalDiseaseStatus_Plan2 = totalDiseaseStatus_Plan2 + person.getCurrentDiseaseStatus();
                            numberOfPersonAgents_Plan2 = numberOfPersonAgents_Plan2 + 1;
                        }//end if
                        break;
                    }//end case
                    case PlanB1:
                    {
                        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
                        {
                            totalDiseaseStatus_Plan1 = totalDiseaseStatus_Plan1 + person.getCurrentDiseaseStatus();
                            numberOfPersonAgents_Plan1 = numberOfPersonAgents_Plan1 + 1;
                        }//end if
                        break;
                    }//end case
                    case PlanB2:
                    {
                        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
                        {
                            totalDiseaseStatus_Plan2 = totalDiseaseStatus_Plan2 + person.getCurrentDiseaseStatus();
                            numberOfPersonAgents_Plan2 = numberOfPersonAgents_Plan2 + 1;
                        }//end if
                        break;
                    }//end case

                    default:
                    {
                    // There should be no default
                        System.out.println("Error:  Unexpected switch default in Health Insurance Company r5_ComputeAverageDiseaseStatus()");
                    }//end case

                }//end switch
                                   
            }//end if

        }//end while

        if (numberOfPersonAgents_Plan1 > 0)
        {
            currentAverageDiseaseStatus_Plan1 = totalDiseaseStatus_Plan1/numberOfPersonAgents_Plan1;
        }//end if
        else
        {
            currentAverageDiseaseStatus_Plan1 = 0.0;
        }//end else

        if (numberOfPersonAgents_Plan2 > 0)
        {
            currentAverageDiseaseStatus_Plan2 = totalDiseaseStatus_Plan2/numberOfPersonAgents_Plan2;
        }//end if
        else
        {
          currentAverageDiseaseStatus_Plan2 = 0.0;
        }//end else


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Test 
// This block tests this method.
// To run the test, remove comments from the code below.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//    System.out.println("HealthInsuranceCompany r5_ComputeAverageDiseaseStatus() at " +
//            RunEnvironment.getInstance().getCurrentSchedule().getTickCount());
//
//    System.out.println("Health Insurance Company ID:  " + this.getAgentID().getAgentIDString());
//    System.out.println("Health Insurance Company name:  " + this.getAgentName());
//
//    System.out.println("totalDiseaseStatus_Plan1:  " + totalDiseaseStatus_Plan1);
//    System.out.println("numberOfPersonAgents_Plan1:  " + numberOfPersonAgents_Plan1);
//    System.out.println("currentAverageDiseaseStatus_Plan1:  " + currentAverageDiseaseStatus_Plan1);
//
//    System.out.println("totalDiseaseStatus_Plan2:  " + totalDiseaseStatus_Plan2);
//    System.out.println("numberOfPersonAgents_Plan2:  " + numberOfPersonAgents_Plan2);
//    System.out.println("currentAverageDiseaseStatus_Plan2:  " + currentAverageDiseaseStatus_Plan2);
//
//    System.out.println("--------------------------------------");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    }//end r5_ComputeAverageDiseaseStatus()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  r6_ComputeProfitPercentage()
// For each plan, calculate the period’s profit, equal to total net premiums
// (gross premiums less Exchange advertising expenses, plus any risk adjustment
// allocation amount) minus total claims paid, divided by total net premiums.
//------------------------------------------------------------------------------
    private void r6_ComputeProfitPercentage()
    {

        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            currentPremiumIncome_Plan1 = Environment.getExchangeList().get(0).getCurrentPremiumsTransferred_PlanA1();
            currentPremiumIncome_Plan2 = Environment.getExchangeList().get(0).getCurrentPremiumsTransferred_PlanA2();
            currentClaimsPaid_Plan1 = Environment.getProviderNetworkList().get(Constants.PROVIDER_NETWORK_A).getCurrentClaims_Plan1();
            currentClaimsPaid_Plan2 = Environment.getProviderNetworkList().get(Constants.PROVIDER_NETWORK_A).getCurrentClaims_Plan2();
        }//end if
        else
        {
            currentPremiumIncome_Plan1 = Environment.getExchangeList().get(0).getCurrentPremiumsTransferred_PlanB1();
            currentPremiumIncome_Plan2 = Environment.getExchangeList().get(0).getCurrentPremiumsTransferred_PlanB2();
            currentClaimsPaid_Plan1 = Environment.getProviderNetworkList().get(Constants.PROVIDER_NETWORK_B).getCurrentClaims_Plan1();
            currentClaimsPaid_Plan2 = Environment.getProviderNetworkList().get(Constants.PROVIDER_NETWORK_B).getCurrentClaims_Plan2();

        }//end else

        currentProfit_Plan1 = currentPremiumIncome_Plan1 - currentClaimsPaid_Plan1;
        currentProfit_Plan2 = currentPremiumIncome_Plan2 - currentClaimsPaid_Plan2;
        currentProfit_Total = currentProfit_Plan1 + currentProfit_Plan2;

        if (currentPremiumIncome_Plan1 != 0.0)
        {
            currentProfitPercentage_Plan1 = currentProfit_Plan1/currentPremiumIncome_Plan1;
        }//end if
        else currentProfitPercentage_Plan1 = 0.0;

        if (currentPremiumIncome_Plan2 != 0.0)
        {
            currentProfitPercentage_Plan2 = currentProfit_Plan2/currentPremiumIncome_Plan2;
        }//end if
        else currentProfitPercentage_Plan2 = 0.0;

        if ((currentPremiumIncome_Plan1 != 0.0) || (currentPremiumIncome_Plan2 != 0.0))
        {
            currentProfitPercentage_Total = currentProfit_Total/(currentPremiumIncome_Plan1 + currentPremiumIncome_Plan2);
        }//end if
        else currentProfitPercentage_Total = 0.0;

        // Update static variable

        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            currentAccumulatedProfit_PlanA1 = currentAccumulatedProfit_PlanA1 + currentProfit_Plan1;
            currentAccumulatedProfit_PlanA2 = currentAccumulatedProfit_PlanA2 + currentProfit_Plan2;
            currentAccumulatedProfit_TotalA = currentAccumulatedProfit_TotalA + currentProfit_Total;
        }//end if

        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            currentAccumulatedProfit_PlanB1 = currentAccumulatedProfit_PlanB1 + currentProfit_Plan1;
            currentAccumulatedProfit_PlanB2 = currentAccumulatedProfit_PlanB2 + currentProfit_Plan2;
            currentAccumulatedProfit_TotalB = currentAccumulatedProfit_TotalB + currentProfit_Total;
        }//end if

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Test 
// This block tests this method.
// To run the test, remove comments from the code below.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//    System.out.println("HealthInsuranceCompany r6_ComputeProfitPercentage() at " +
//            RunEnvironment.getInstance().getCurrentSchedule().getTickCount());
//
//    System.out.println("Health Insurance Company ID:  " + this.getAgentID().getAgentIDString());
//    System.out.println("Health Insurance Company name:  " + this.getAgentName());
//    System.out.println("currentPremiumIncome_Plan1:  " + currentPremiumIncome_Plan1);
//    System.out.println("currentPremiumReallocationAmount_Plan1:  " + currentPremiumReallocationAmount_Plan1);
//    System.out.println("currentClaimsPaid_Plan1:  " + currentClaimsPaid_Plan1);
//    System.out.println("currentProfit_Plan1:  " + currentProfit_Plan1);
//    System.out.println("currentProfitPercentage_Plan1:  " + currentProfitPercentage_Plan1);
//
//    System.out.println("currentPremiumIncome_Plan2:  " + currentPremiumIncome_Plan2);
//    System.out.println("currentPremiumReallocationAmount_Plan2:  " + currentPremiumReallocationAmount_Plan2);
//    System.out.println("currentClaimsPaid_Plan2:  " + currentClaimsPaid_Plan2);
//    System.out.println("currentProfit_Plan2:  " + currentProfit_Plan2);
//    System.out.println("currentProfitPercentage_Plan2:  " + currentProfitPercentage_Plan2);
//
//    System.out.println("currentProfit_Total:  " + currentProfit_Total);
//
//    if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
//    {
//        System.out.println("currentAccumulatedProfit_PlanA1:  " + currentAccumulatedProfit_PlanA1);
//        System.out.println("currentAccumulatedProfit_PlanA2:  " + currentAccumulatedProfit_PlanA2);
//        System.out.println("currentAccumulatedProfit_TotalA:  " + currentAccumulatedProfit_TotalA);
//    }//end if
//
//    if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
//    {
//        System.out.println("currentAccumulatedProfit_PlanB1:  " + currentAccumulatedProfit_PlanB1);
//        System.out.println("currentAccumulatedProfit_PlanB2:  " + currentAccumulatedProfit_PlanB2);
//        System.out.println("currentAccumulatedProfit_TotalB:  " + currentAccumulatedProfit_TotalB);
//    }//end if
//
//    System.out.println("--------------------------------------");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


    }//end r6_ComputeProfitPercentage()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  r7_ComputeMaximumAlpha()
// For the formula, see the model's detailed description.
//------------------------------------------------------------------------------
    private void r7_ComputeMaximumAlpha()
    {

        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            currentNetPremiumsReceived_Plan1 = Environment.getExchangeList().get(0).getCurrentPremiumsTransferred_PlanA1();
            currentNetPremiumsReceived_Plan2 = Environment.getExchangeList().get(0).getCurrentPremiumsTransferred_PlanA2();
        }//end if
        else 
        {
            currentNetPremiumsReceived_Plan1 = Environment.getExchangeList().get(0).getCurrentPremiumsTransferred_PlanB1();
            currentNetPremiumsReceived_Plan2 = Environment.getExchangeList().get(0).getCurrentPremiumsTransferred_PlanB2();
        }//end else

        double numerator = (currentNetPremiumsReceived_Plan1 + currentNetPremiumsReceived_Plan2);
        double denominator = (currentClaimsPaid_Plan1 + currentClaimsPaid_Plan2);

        if (denominator != 0.0)
        {
            currentTreatmentCostAlphaMaximum = currentTreatmentCostAlpha * numerator/denominator;
        }//end if
        else currentTreatmentCostAlphaMaximum = currentTreatmentCostAlpha; 

    }//end r7_ComputeMaximumAlpha()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  r8_ComputeTreatmentCostAlphaOffer()
// Calculate the treatment cost alpha to initially offer the Provider Network.
// For the formula, see the model's detailed description.
//------------------------------------------------------------------------------
    private void r8_ComputeTreatmentCostAlphaOffer()
    {

        r7_ComputeMaximumAlpha();

        currentTreatmentCostAlphaOffer = (currentTreatmentCostAlpha + currentTreatmentCostAlphaMaximum)/2.0;
        currentTreatmentCostAlphaOffer = Math.min(currentTreatmentCostAlphaOffer, currentTreatmentCostAlphaMaximum);
        currentTreatmentCostAlphaOffer = Math.min(currentTreatmentCostAlphaOffer, currentTreatmentCostAlpha * (1 + maximumOfferIncreasePercent));

    }//end r8_ComputeTreatmentCostAlphaOffer()
//------------------------------------------------------------------------------

//==============================================================================
// Method:  r9_ComputeNegotiationsResponse()
// Calculate the treatment cost alpha to offer the Provider Network as a response
// to its negotiation response.
// For the formula, see the model's detailed description.
//------------------------------------------------------------------------------
    private void r9_ComputeNegotiationsResponse()
    {

        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            currentTreatemntCostAlphaResponse =
                    (Environment.getProviderNetworkList().get(Constants.PROVIDER_NETWORK_A).getNextCurrentTreatmentCostAlpha() + currentTreatmentCostAlphaMaximum)/2.0;
        }//end if
        else
        {
            currentTreatemntCostAlphaResponse =
                    (Environment.getProviderNetworkList().get(Constants.PROVIDER_NETWORK_A).getNextCurrentTreatmentCostAlpha() + currentTreatmentCostAlphaMaximum)/2.0;
        }//end else

    }//end r9_ComputeNegotiationsResponse()
//------------------------------------------------------------------------------

//==============================================================================


//==============================================================================
//Methods: "Probe" methods for the model user to probe the agent's data.
//Note:    As a simulation runs, the model user can probe an agent by
//         double-clicking on its icon in the display. For more information
//         about probes, see the Repast Simphony reference documentation.
//==============================================================================

// The "ProbeID" annotation provides the probe ID
    @ProbeID
    public String getName()
    {
        return getAgentName();
    }

    @Parameter (usageName="currentPremium_Plan1", displayName="A1. Current premium - Plan 1")
    public double getCurrentPremium_Plan1()
    {
        return currentPremium_Plan1;
    }

    @Parameter (usageName="currentPremium_Plan2", displayName="A2. Current premium - Plan 2")
    public double getCurrentPremium_Plan2()
    {
        return currentPremium_Plan2;
    }

    @Parameter (usageName="currentPremiumRateIncreaseLimit_Plan1", displayName="A3. Current premium increase limit - Plan 1")
    public double getCurrentPremiumRateIncreaseLimit_Plan1()
    {
        return currentPremiumRateIncreaseLimit_Plan1;
    }

    @Parameter (usageName="currentPremiumRateIncreaseLimit_Plan2", displayName="A4. Current premium increase limit - Plan 2")
    public double getCurrentPremiumRateIncreaseLimit_Plan2()
    {
        return currentPremiumRateIncreaseLimit_Plan2;
    }

    @Parameter (usageName="currentProfitMaximizingPremium_Plan1", displayName="B1. Current profit maximizing premium - Plan 1")
    public double getCurrentProfitMaximizingPremium_Plan1()
    {
        return currentProfitMaximizingPremium_Plan1;
    }

    @Parameter (usageName="currentProfitMaximizingPremium_Plan2", displayName="B2. Current profit maximizing premium - Plan 2")
    public double getCurrentProfitMaximizingPremium_Plan2()
    {
        return currentProfitMaximizingPremium_Plan2;
    }

    @Parameter (usageName="currentLapseRateProblem_Plan1", displayName="B3. Current lapse rate problem - Plan 1")
    public boolean isCurrentLapseRateProblem_Plan1()
    {
        return currentLapseRateProblem_Plan1;
    }

    @Parameter (usageName="currentLapseRateProblem_Plan2", displayName="B4. Current lapse rate problem - Plan 2")
    public boolean isCurrentLapseRateProblem_Plan2()
    {
        return currentLapseRateProblem_Plan2;
    }

    @Parameter (usageName="currentCompetitivePremium_Plan1", displayName="B5. Current competitive premium - Plan 1")
    public double getCurrentCompetitivePremium_Plan1()
    {
        return currentCompetitivePremium_Plan1;
    }

    @Parameter (usageName="currentCompetitivePremium_Plan2", displayName="B6. Current competitive premium - Plan 2")
    public double getCurrentCompetitivePremium_Plan2()
    {
        return currentCompetitivePremium_Plan2;
    }

    @Parameter (usageName="priorCompetitorPremium_Plan1", displayName="B7. Prior competitor premium - Plan 1")
    public double getPriorCompetitorPremium_Plan1()
    {
        return priorCompetitorPremium_Plan1;
    }

    @Parameter (usageName="priorCompetitorPremium_Plan2", displayName="B8. Prior competitor premium - Plan 2")
    public double getPriorCompetitorPremium_Plan2()
    {
        return priorCompetitorPremium_Plan2;
    }

    @Parameter (usageName="currentAverageDiseaseStatus_Plan1", displayName="C1. Current risk experience - Plan 1")
    public double getCurrentAverageDiseaseStatus_Plan1()
    {
        return currentAverageDiseaseStatus_Plan1;
    }

    @Parameter (usageName="currentAverageDiseaseStatus_Plan2", displayName="C2. Current risk experience - Plan 2")
    public double getCurrentAverageDiseaseStatus_Plan2()
    {
        return currentAverageDiseaseStatus_Plan2;
    }

    @Parameter (usageName="currentProfitPercentage_Plan1", displayName="D1. Current profit percentage - Plan 1")
    public double getCurrentProfitPercentage_Plan1()
    {
        return currentProfitPercentage_Plan1;
    }

    @Parameter (usageName="currentProfitPercentage_Plan2", displayName="D2. Current profit percentage - Plan 2")
    public double getCurrentProfitPercentage_Plan2()
    {
        return currentProfitPercentage_Plan2;
    }


    @Parameter (usageName="currentPremiumIncome_Plan1", displayName="D3. Current premium income - Plan 1")
    public double getCurrentPremiumIncome_Plan1()
    {
        return currentPremiumIncome_Plan1;
    }

    @Parameter (usageName="currentPremiumIncome_Plan2", displayName="D4. Current premium income - Plan 2")
    public double getCurrentPremiumIncome_Plan2()
    {
        return currentPremiumIncome_Plan2;
    }

    @Parameter (usageName="currentPremiumReallocationAmount_Plan1", displayName="D5. Current premium reallocation amount - Plan 1")
    public double getCurrentPremiumReallocationAmount_Plan1()
    {
        return currentPremiumReallocationAmount_Plan1;
    }

    @Parameter (usageName="currentPremiumReallocationAmount_Plan2", displayName="D6. Current premium reallocation amount - Plan 2")
    public double getCurrentPremiumReallocationAmount_Plan2()
    {
        return currentPremiumReallocationAmount_Plan2;
    }

    @Parameter (usageName="currentClaimsPaid_Plan1", displayName="D7. Current claims paid - Plan 1")
    public double getCurrentClaimsPaid_Plan1()
    {
        return currentClaimsPaid_Plan1;
    }

    @Parameter (usageName="currentClaimsPaid_Plan2", displayName="D8. Current claims paid - Plan 2")
    public double getCurrentClaimsPaid_Plan2()
    {
        return currentClaimsPaid_Plan2;
    }

    @Parameter (usageName="currentTreatmentCostAlpha", displayName="E1. Current treatment cost alpha")
    public double getCurrentTreatmentCostAlpha()
    {
        return currentTreatmentCostAlpha;
    }

    @Parameter (usageName="currentNegotiationRound", displayName="E2. Current negotiation round")
    public int getCurrentNegotiationRound()
    {
        return currentNegotiationRound;
    }

    @Parameter (usageName="currentTreatmentCostAlpha", displayName="E3. Prior treatment cost alpha")
    public double getPriorTreatmentCostAlpha()
    {
        return priorTreatmentCostAlpha;
    }

    @Parameter (usageName="currentNetPremiumsReceived_Plan1", displayName="E4. Current net premiums received - Plan 1")
    public double getCurrentNetPremiumsReceived_Plan1()
    {
        return currentNetPremiumsReceived_Plan1;
    }

    @Parameter (usageName="currentNetPremiumsReceived_Plan2", displayName="E5. Current net premiums received - Plan 2")
    public double getCurrentNetPremiumsReceived_Plan2()
    {
        return currentNetPremiumsReceived_Plan2;
    }

    @Parameter (usageName="currentTreatmentCostAlphaMaximum", displayName="E6. Current treatment cost alpha maximum")
    public double getCurrentTreatmentCostAlphaMaximum()
    {
        return currentTreatmentCostAlphaMaximum;
    }

    @Parameter (usageName="currentTreatmentCostAlphaOffer", displayName="E7. Current treatment cost alpha offer")
    public double getCurrentTreatmentCostAlphaOffer()
    {
        return currentTreatmentCostAlphaOffer;
    }

    @Parameter (usageName="currentTreatmentCostAlphaResponse", displayName="E8. Current treatment cost alpha response")
    public double getCurrentTreatemntCostAlphaResponse()
    {
        return currentTreatemntCostAlphaResponse;
    }


//==============================================================================


//==============================================================================
// Methods:  "Analysis" methods to support simulation charts and graphs.
//==============================================================================

    public double analysisGetMarketShare_CompanyA()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            int numberOfParticipants_A = 0;
            int numberOfParticipants_B = 0;
            int numberOfParticipants_Total = 0;
            double marketShare_A = 0.0;
            double marketShare_B = 0.0;
            
            ListIterator<Person> iterator = Environment.getPersonList().listIterator();
             
            while (iterator.hasNext())
            {
                Person person = iterator.next();
                if ((person.getCurrentPlanChosen() == PlanTag.PlanA1) || (person.getCurrentPlanChosen() == PlanTag.PlanA2))
                {
                    numberOfParticipants_A = numberOfParticipants_A + 1;
                    numberOfParticipants_Total = numberOfParticipants_Total + 1;
                }//end if

                if (((person.getCurrentPlanChosen() == PlanTag.PlanB1) || (person.getCurrentPlanChosen() == PlanTag.PlanB2)) == true)
                {
                    numberOfParticipants_B = numberOfParticipants_B + 1;
                    numberOfParticipants_Total = numberOfParticipants_Total + 1;
                }//end if

            }//end while

            marketShare_A = (double) numberOfParticipants_A/ (double) numberOfParticipants_Total;
            marketShare_B = (double) numberOfParticipants_B/ (double) numberOfParticipants_Total;

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Test 
// This block tests this method.
// To run the test, remove comments from the code below.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//    System.out.println("Health Insurance Company analysisGetMarketShare_CompanyA() at " +
//            RunEnvironment.getInstance().getCurrentSchedule().getTickCount());
//
//    System.out.println("Health Insurance Company ID:  " + this.getName());
//    System.out.println("numberOfParticipants_A:  " + numberOfParticipants_A);
//    System.out.println("numberOfParticipants_B:  " + numberOfParticipants_B);
//    System.out.println("numberOfParticipants_Total:  " + numberOfParticipants_Total);
//    System.out.println("marketShare_A:  " + marketShare_A);
//    System.out.println("marketShare_B:  " + marketShare_B);
//    System.out.println("--------------------------------------");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

            return marketShare_A;

        }//end if
        else
        {
            return 0.0;

        }//end else

    }//end analysisGetMarketShare_CompanyA()

    public double analysisGetMarketShare_CompanyB()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            int numberOfParticipants_A = 0;
            int numberOfParticipants_B = 0;
            int numberOfParticipants_Total = 0;
            double marketShare_A = 0.0;
            double marketShare_B = 0.0;
            
            ListIterator<Person> iterator = Environment.getPersonList().listIterator();
             
            while (iterator.hasNext())
            {
                Person person = iterator.next();
                if (((person.getCurrentPlanChosen() == PlanTag.PlanA1) || (person.getCurrentPlanChosen() == PlanTag.PlanA2)) == true)
                {
                    numberOfParticipants_A ++;
                    numberOfParticipants_Total ++;
                }//end if

                if (((person.getCurrentPlanChosen() == PlanTag.PlanB1) || (person.getCurrentPlanChosen() == PlanTag.PlanB2)) == true)
                {
                    numberOfParticipants_B ++;
                    numberOfParticipants_Total ++;
                }//end if

            }//end while

            marketShare_A = (double) numberOfParticipants_A/ (double) numberOfParticipants_Total;
            marketShare_B = (double) numberOfParticipants_B/ (double) numberOfParticipants_Total;

            return marketShare_B;
        }//end if
        else
        {
            return 0.0;

        }//end else

    }//end analysisGetMarketShare_CompanyB()


    public double analysisGetLapseProblem_PlanA1()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            if (currentLapseRateProblem_Plan1 == true) return 0.1;
            else return 0.0;
        }//end if
        else return 0.0;
    }

    public double analysisGetLapseProblem_PlanA2()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            if (currentLapseRateProblem_Plan1 == true) return 0.2;
            else return 0.0;
        }//end if
        else return 0.0;
    }

    public double analysisGetLapseProblem_PlanB1()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            if (currentLapseRateProblem_Plan1 == true) return 0.3;
            else return 0.0;
        }//end if
        else return 0.0;
    }

    public double analysisGetLapseProblem_PlanB2()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            if (currentLapseRateProblem_Plan1 == true) return 0.4;
            else return 0.0;
        }//end if
        else return 0.0;
    }


    public double analysisGetPremium_PlanA1()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            return currentPremium_Plan1;
        }//end if
        else return 0.0;
    }

    public double analysisGetPremium_PlanA2()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            return currentPremium_Plan2;
        }//end if
        else return 0.0;
    }

    public double analysisGetPremium_PlanB1()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            return currentPremium_Plan1;
        }//end if
        else return 0.0;
    }

    public double analysisGetPremium_PlanB2()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            return currentPremium_Plan2;
        }//end if
        else return 0.0;
    }

    public double analysisGetProfitPercentage_TotalA()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            return currentProfitPercentage_Total;
        }//end if
        else return 0.0;
    }

    public double analysisGetProfitPercentage_TotalB()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            return currentProfitPercentage_Total;
        }//end if
        else return 0.0;
    }

    public double analysisGetProfitPercentage_PlanA1()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            return currentProfitPercentage_Plan1;
        }//end if
        else return 0.0;
    }

    public double analysisGetProfitPercentage_PlanA2()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            return currentProfitPercentage_Plan2;
        }//end if
        else return 0.0;
    }

    public double analysisGetProfitPercentage_PlanB1()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            return currentProfitPercentage_Plan1;
        }//end if
        else return 0.0;
    }

    public double analysisGetProfitPercentage_PlanB2()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            return currentProfitPercentage_Plan2;
        }//end if
        else return 0.0;
    }


    public double analysisGetAverageDiseaseStatus_PlanA1()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            return currentAverageDiseaseStatus_Plan1;
        }//end if
        else return 0.0;
    }

    public double analysisGetAverageDiseaseStatus_PlanA2()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            return currentAverageDiseaseStatus_Plan2;
        }//end if
        else return 0.0;
    }

    public double analysisGetAverageDiseaseStatus_PlanB1()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            return currentAverageDiseaseStatus_Plan1;
        }//end if
        else return 0.0;
    }

    public double analysisGetAverageDiseaseStatus_PlanB2()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            return currentAverageDiseaseStatus_Plan2;
        }//end if
        else return 0.0;
    }



    public double analysisGetTreatmentCostAlpha_CompanyA()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_A)
        {
            return currentTreatmentCostAlpha;
        }//end if
        else return 0.0;
    }

    public double analysisGetTreatmentCostAlpha_CompanyB()
    {
        if (this.getAgentID().getAgentNumber() == Constants.HEALTH_INSURANCE_COMPANY_B)
        {
            return currentTreatmentCostAlpha;
        }//end if
        else return 0.0;
    }


    public double analysisGetAccumulatedProfit_PlanA1()
    {
            return currentAccumulatedProfit_PlanA1;
    }

    public double analysisGetAccumulatedProfit_PlanA2()
    {
            return currentAccumulatedProfit_PlanA2;
    }

    public double analysisGetAccumulatedProfit_TotalA()
    {
            return currentAccumulatedProfit_TotalA;
    }

    public double analysisGetAccumulatedProfit_PlanB1()
    {
            return currentAccumulatedProfit_PlanB1;
    }

    public double analysisGetAccumulatedProfit_PlanB2()
    {
            return currentAccumulatedProfit_PlanB2;
    }

    public double analysisGetAccumulatedProfit_TotalB()
    {
            return currentAccumulatedProfit_TotalB;
    }

//==============================================================================


//==============================================================================
// Methods:  General methods for the agent.
//==============================================================================

// None

//==============================================================================


//==============================================================================
// Methods:  getter and setter methods
//==============================================================================

    public void setCurrentPremiumRateIncreaseLimit_Plan1(
            double currentPremiumRateIncreaseLimit_Plan1)
    {
        this.currentPremiumRateIncreaseLimit_Plan1 = currentPremiumRateIncreaseLimit_Plan1;
    }

    public void setCurrentPremiumRateIncreaseLimit_Plan2(
            double currentPremiumRateIncreaseLimit_Plan2)
    {
        this.currentPremiumRateIncreaseLimit_Plan2 = currentPremiumRateIncreaseLimit_Plan2;
    }

    public double getPriorPremium_Plan1()
    {
        return priorPremium_Plan1;
    }

    public double getPriorPremium_Plan2()
    {
        return priorPremium_Plan2;
    }

    public int getAgentNumber()
    {
        return getAgentID().getAgentNumber();
    }


//==============================================================================


}//end HealthInsuranceCompany class