Magentix2  2.1.1
es.upv.dsic.gti_ia.argAgents.argCBR.ArgCBR Class Reference

List of all members.

Public Member Functions

 ArgCBR (String initialDataFilePath, String storingDataFilePath)
boolean addCase (ArgumentCase newArgCase)
ArrayList< Float > getDegrees (ArgumentProblem argProblem, Solution solution, ArrayList< Position > allPositions, int index)
ArrayList< Float > getAttackDegree (ArrayList< SimilarArgumentCase > sameProblemAcceptedArgCases, ArrayList< Position > initialPositions)
ArrayList< Float > getEfficiencyDegree (ArrayList< SimilarArgumentCase > sameProblemAcceptedArgCases, ArrayList< Position > initialPositions)
ArrayList< Float > getExplanatoryPower (ArrayList< SimilarArgumentCase > sameProblemAcceptedArgCases, ArrayList< Position > initialPositions)
ArrayList< SimilarArgumentCasegetSameDomainAndSocialContextAccepted (HashMap< Integer, Premise > premises, Solution solution, SocialContext socialContext)
ArrayList< SimilarArgumentCasegetMostSimilarArgCases (ArgumentProblem argProblem)
Collection< ArrayList
< ArgumentCase > > 
getAllCases ()
Vector< ArgumentCasegetAllCasesVector ()
void doCache ()
void doCache (String fileName)
void doCacheInc ()

Detailed Description

This class implements the argumentation CBR. This CBR stores argument-cases that represent past argumentation experiences and their final outcome.

Author:
Jaume Jordan

Definition at line 35 of file ArgCBR.java.


Constructor & Destructor Documentation

es.upv.dsic.gti_ia.argAgents.argCBR.ArgCBR.ArgCBR ( String  initialDataFilePath,
String  storingDataFilePath 
)

Constructor that initializes the ArgCBR creating the HashMap structure and loading the argument-cases stored in the indicated path.

Parameters:
initialDataFilePathPath of the data file with the argument-cases to load
storingDataFilePathPath of the data file to store the argument-cases

Definition at line 51 of file ArgCBR.java.

                                                                              {

                this.initialFilePath = initialDataFilePath;
                this.storingFilePath = storingDataFilePath;

                argCB = new HashMap<Integer, ArrayList<ArgumentCase>>();

                try {

                        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(this.initialFilePath));

                        // Read first object
                        Object aux = ois.readObject();

                        // While there are objects
                        while (aux != null) {
                                if (aux instanceof ArgumentCase) {
                                        ArgumentCase acase = (ArgumentCase) aux;
                                        addCase(acase);
                                }
                                aux = ois.readObject();
                        }
                        ois.close();

                } catch (EOFException e) {

                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                }

                
        }

Member Function Documentation

Adds a new argument-case to the case-base. If the argument-case is in case-base, the associated domain-cases and the attacks received are added to that argument-case. Two cases are considered equal if they have the same domain context, social context, conclusion and status of acceptability.

Parameters:
newArgCaseA new argument-case to add to the case-base.
Returns:
true if the argument-case is added, otherwise false.

Definition at line 100 of file ArgCBR.java.

                                                        {
                // two cases are equal if they have the same domain context, social
                // context, conclusion and state of acceptability
                // if two cases are equal, also the domain-cases associated and attacks
                // received must be added to the corresponding argument-case

                HashMap<Integer, Premise> newCasePremises = newArgCase.getArgumentProblem().getDomainContext().getPremises();

                Iterator<Premise> iterNewCasePremises = newCasePremises.values().iterator();
                ArrayList<Premise> newCasePremisesList = new ArrayList<Premise>();

                while (iterNewCasePremises.hasNext()) { // copy the premises to an
                                                                                                // arraylist, ordered from lower
                                                                                                // to higher id
                        newCasePremisesList.add(iterNewCasePremises.next());
                }
                Premise firstCasePremise = newCasePremisesList.get(0);
                if (firstCasePremise != null) {
                        int firstPremiseID = firstCasePremise.getID();
                        ArrayList<ArgumentCase> candidateCases = argCB.get(firstPremiseID);
                        if (candidateCases != null && candidateCases.size() > 0) {
                                Iterator<ArgumentCase> iterArgCases = candidateCases.iterator();
                                while (iterArgCases.hasNext()) {
                                        ArgumentCase argCase = iterArgCases.next();
                                        HashMap<Integer, Premise> argCasePremises = argCase.getArgumentProblem().getDomainContext()
                                                        .getPremises();

                                        // if the premises are the same with the same content, check
                                        // if social context conclusion and state of acceptability
                                        // are the same
                                        if (isSameDomainContextPrecise(newCasePremisesList, argCasePremises)
                                                        && isSameSocialContext(newArgCase.getArgumentProblem().getSocialContext(), argCase
                                                                        .getArgumentProblem().getSocialContext())
                                                        && newArgCase.getArgumentSolution().getConclusion().getID() == argCase
                                                                        .getArgumentSolution().getConclusion().getID()
                                                        && newArgCase.getArgumentSolution().getAcceptabilityState()
                                                                        .compareTo(argCase.getArgumentSolution().getAcceptabilityState()) == 0) {

                                                // it is the same argument-case, so it is not introduced
                                                // but we add associated cases and attacks received, and
                                                // dialogue graphs and increase timesUsed

                                                // increase timesUsed
                                                int timesUsed = argCase.getTimesUsed() + newArgCase.getTimesUsed();
                                                argCase.setTimesUsed(timesUsed);

                                                // distinguishing premises
                                                ArrayList<Premise> distinguishingPremises = argCase.getArgumentSolution()
                                                                .getDistinguishingPremises();
                                                ArrayList<Premise> newDistinguishingPremises = newArgCase.getArgumentSolution()
                                                                .getDistinguishingPremises();
                                                if (newDistinguishingPremises == null)
                                                        newDistinguishingPremises = new ArrayList<Premise>();
                                                if (distinguishingPremises == null) {
                                                        argCase.getArgumentSolution().setDistinguishingPremises(newDistinguishingPremises);
                                                } else if (newDistinguishingPremises != null) {
                                                        for (int i = 0; i < newDistinguishingPremises.size(); i++) {
                                                                boolean addPremise = true;
                                                                for (int j = 0; j < distinguishingPremises.size(); j++) {
                                                                        // Take care that distinguishingPremises are
                                                                        // NEVER translated to HashMap (there are
                                                                        // several dp with the same ID but different
                                                                        // content in the ArrayList)
                                                                        if (newDistinguishingPremises.get(i).getID() == distinguishingPremises.get(j)
                                                                                        .getID()
                                                                                        && newDistinguishingPremises.get(i).getContent()
                                                                                                        .equalsIgnoreCase(distinguishingPremises.get(j).getContent())) {
                                                                                addPremise = false;
                                                                                break;
                                                                        }
                                                                }
                                                                if (addPremise)
                                                                        distinguishingPremises.add(newDistinguishingPremises.get(i));
                                                        }
                                                        argCase.getArgumentSolution().setDistinguishingPremises(distinguishingPremises);
                                                }

                                                // exceptions
                                                ArrayList<Premise> exceptions = argCase.getArgumentSolution().getExceptions();
                                                ArrayList<Premise> newExceptions = newArgCase.getArgumentSolution().getExceptions();
                                                if (newExceptions == null)
                                                        newExceptions = new ArrayList<Premise>();
                                                if (exceptions == null)
                                                        argCase.getArgumentSolution().setExceptions(newExceptions);
                                                else if (newExceptions != null) {
                                                        for (int i = 0; i < newExceptions.size(); i++) {
                                                                boolean addPremise = true;
                                                                for (int j = 0; j < exceptions.size(); j++) {
                                                                        if (newExceptions.get(i).getID() == exceptions.get(j).getID()
                                                                                        && newExceptions.get(i).getContent()
                                                                                                        .equalsIgnoreCase(exceptions.get(j).getContent())) {
                                                                                addPremise = false;
                                                                                break;
                                                                        }
                                                                }
                                                                if (addPremise)
                                                                        exceptions.add(newExceptions.get(i));
                                                        }
                                                        argCase.getArgumentSolution().setExceptions(exceptions);
                                                }

                                                // presumptions
                                                ArrayList<Premise> presumptions = argCase.getArgumentSolution().getPresumptions();
                                                ArrayList<Premise> newPresumptions = newArgCase.getArgumentSolution().getPresumptions();
                                                if (newPresumptions == null)
                                                        newPresumptions = new ArrayList<Premise>();
                                                if (presumptions == null)
                                                        argCase.getArgumentSolution().setPresumptions(newPresumptions);
                                                else if (newPresumptions != null) {
                                                        for (int i = 0; i < newPresumptions.size(); i++) {
                                                                boolean addPremise = true;
                                                                for (int j = 0; j < presumptions.size(); j++) {
                                                                        if (newPresumptions.get(i).getID() == presumptions.get(j).getID()
                                                                                        && newPresumptions.get(i).getContent()
                                                                                                        .equalsIgnoreCase(presumptions.get(j).getContent())) {
                                                                                addPremise = false;
                                                                                break;
                                                                        }
                                                                }
                                                                if (addPremise)
                                                                        presumptions.add(newPresumptions.get(i));
                                                        }
                                                        argCase.getArgumentSolution().setDistinguishingPremises(presumptions);
                                                }

                                                // counter examples domain-case ids
                                                ArrayList<Long> counterExamplesDCIds = argCase.getArgumentSolution()
                                                                .getCounterExamplesDomCaseIDList();
                                                ArrayList<Long> newCounterExamplesDCIds = newArgCase.getArgumentSolution()
                                                                .getCounterExamplesDomCaseIDList();
                                                if (newCounterExamplesDCIds == null)
                                                        newCounterExamplesDCIds = new ArrayList<Long>();
                                                if (counterExamplesDCIds == null)
                                                        argCase.getArgumentSolution().setCounterExamplesDomCaseIDList(newCounterExamplesDCIds);
                                                else if (newCounterExamplesDCIds != null) {
                                                        for (int i = 0; i < newCounterExamplesDCIds.size(); i++) {
                                                                boolean addCounterExample = true;
                                                                for (int j = 0; j < counterExamplesDCIds.size(); j++) {
                                                                        if (newCounterExamplesDCIds.get(i) == counterExamplesDCIds.get(j)) {
                                                                                addCounterExample = false;
                                                                                break;
                                                                        }
                                                                }
                                                                if (addCounterExample)
                                                                        counterExamplesDCIds.add(newCounterExamplesDCIds.get(i));
                                                        }
                                                        argCase.getArgumentSolution().setCounterExamplesDomCaseIDList(counterExamplesDCIds);
                                                }

                                                // counter examples argument-case ids
                                                ArrayList<Long> counterExamplesArgCIds = argCase.getArgumentSolution()
                                                                .getCounterExamplesArgCaseIDList();
                                                ArrayList<Long> newCounterExamplesArgCIds = newArgCase.getArgumentSolution()
                                                                .getCounterExamplesArgCaseIDList();
                                                if (newCounterExamplesArgCIds == null)
                                                        newCounterExamplesArgCIds = new ArrayList<Long>();
                                                if (counterExamplesArgCIds == null)
                                                        argCase.getArgumentSolution().setCounterExamplesArgCaseIDList(newCounterExamplesArgCIds);
                                                else if (newCounterExamplesArgCIds != null) {
                                                        for (int i = 0; i < newCounterExamplesArgCIds.size(); i++) {
                                                                boolean addCounterExample = true;
                                                                for (int j = 0; j < counterExamplesArgCIds.size(); j++) {
                                                                        if (newCounterExamplesArgCIds.get(i) == counterExamplesArgCIds.get(j)) {
                                                                                addCounterExample = false;
                                                                                break;
                                                                        }
                                                                }
                                                                if (addCounterExample)
                                                                        counterExamplesArgCIds.add(newCounterExamplesArgCIds.get(i));
                                                        }
                                                        argCase.getArgumentSolution().setCounterExamplesArgCaseIDList(counterExamplesArgCIds);
                                                }

                                                // associated domain-cases
                                                ArrayList<Long> domCases = argCase.getArgumentJustification().getDomainCasesIDs();
                                                ArrayList<Long> newDomCases = newArgCase.getArgumentJustification().getDomainCasesIDs();
                                                if (newDomCases == null)
                                                        newDomCases = new ArrayList<Long>();
                                                if (domCases == null)
                                                        argCase.getArgumentJustification().setDomainCases(newDomCases);
                                                else if (newDomCases != null) {
                                                        for (int i = 0; i < newDomCases.size(); i++) {
                                                                boolean addCase = true;
                                                                for (int j = 0; j < domCases.size(); j++) {
                                                                        if (newDomCases.get(i) == domCases.get(j)) {
                                                                                addCase = false;
                                                                                break;
                                                                        }
                                                                }
                                                                if (addCase)
                                                                        domCases.add(newDomCases.get(i));
                                                        }
                                                        argCase.getArgumentJustification().setDomainCases(domCases);
                                                }

                                                // associated argument-cases
                                                ArrayList<Long> argCases = argCase.getArgumentJustification().getArgumentCasesIDs();
                                                ArrayList<Long> newArgCases = newArgCase.getArgumentJustification().getArgumentCasesIDs();
                                                if (newArgCases == null)
                                                        newArgCases = new ArrayList<Long>();
                                                if (argCases == null)
                                                        argCase.getArgumentJustification().setArgumentCases(newArgCases);
                                                else if (newArgCases != null) {
                                                        for (int i = 0; i < newArgCases.size(); i++) {
                                                                boolean addCase = true;
                                                                for (int j = 0; j < argCases.size(); j++) {
                                                                        if (newArgCases.get(i) == argCases.get(j)) {
                                                                                addCase = false;
                                                                                break;
                                                                        }
                                                                }
                                                                if (addCase)
                                                                        argCases.add(newArgCases.get(i));
                                                        }
                                                        argCase.getArgumentJustification().setArgumentCases(argCases);
                                                }

                                                // dialogue graphs
                                                // take the id of the adding argcase (newArgCase),
                                                // search in to its dialogue graphs and change it by the
                                                // id of the argcase (argCase) with which it is joining
                                                ArrayList<DialogueGraph> dialogueGraphs = newArgCase.getArgumentJustification()
                                                                .getDialogueGraphs();
                                                Iterator<DialogueGraph> iterDialogues = dialogueGraphs.iterator();
                                                ArrayList<DialogueGraph> graphs = argCase.getArgumentJustification().getDialogueGraphs();
                                                while (iterDialogues.hasNext()) {
                                                        DialogueGraph diag = iterDialogues.next();
                                                        // change the ID of the new arg case to
                                                        // corresponding arg case in all nodes
                                                        ArrayList<ArgNode> nodesToChange = diag.getNodes(newArgCase.getID());
                                                        if (nodesToChange == null) {
                                                                System.err
                                                                                .println("ERROR updating argument-case case-base. No Argument-nodes matching in DialogueGraph");
                                                                continue;
                                                        }
                                                        for (ArgNode node : nodesToChange)
                                                                node.setArgCaseID(argCase.getID());
                                                        // add dialogue graph of newArgCase to argCase
                                                        graphs.add(diag);
                                                }

                                                return false;

                                        }
                                }
                        }
                        // the same case is not stored, so it is added
                        if (candidateCases == null)
                                candidateCases = new ArrayList<ArgumentCase>();
                        candidateCases.add(newArgCase);
                        argCB.put(firstPremiseID, candidateCases);
                        return true;

                }

                return false;
        }

Stores the argument-case case-base in the file path specified in the creation of the class

Definition at line 1196 of file ArgCBR.java.

                              {

                try {
                        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(storingFilePath));

                        Iterator<ArgumentCase> iterCases = getAllCasesVector().iterator();
                        int nCases = 0;
                        while (iterCases.hasNext()) {
                                ArgumentCase argCase = iterCases.next();
                                oos.writeObject(argCase);
                                nCases++;
                        }

                        oos.close();

                        System.out.println(nCases + " argCases introduced");

                } catch (FileNotFoundException e) {

                        e.printStackTrace();
                } catch (IOException e) {

                        e.printStackTrace();
                }

        }

Stores the argument-case case-base in the file path specified as argument

Parameters:
fileNameFile path to store the case-base

Definition at line 1229 of file ArgCBR.java.

                                             {

                try {
                        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fileName));

                        Iterator<ArgumentCase> iterCases = getAllCasesVector().iterator();
                        while (iterCases.hasNext()) {
                                ArgumentCase argCase = iterCases.next();
                                oos.writeObject(argCase);
                        }

                        oos.close();

                } catch (FileNotFoundException e) {

                        e.printStackTrace();
                } catch (IOException e) {

                        e.printStackTrace();
                }

        }

Stores the argument-case case-base in the file path specified in the creation of the class, but keeping all previous information of that file

Definition at line 1256 of file ArgCBR.java.

                                 {

                try {

                        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(this.storingFilePath));

                        // Read first object
                        Object aux = ois.readObject();

                        // While there are objects
                        while (aux != null) {
                                if (aux instanceof ArgumentCase) {
                                        ArgumentCase acase = (ArgumentCase) aux;
                                        addCase(acase);

                                }
                                aux = ois.readObject();
                        }
                        ois.close();

                } catch (EOFException e) {

                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                }

                try {
                        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(storingFilePath));

                        Iterator<ArgumentCase> iterCases = getAllCasesVector().iterator();
                        while (iterCases.hasNext()) {
                                ArgumentCase argCase = iterCases.next();
                                oos.writeObject(argCase);
                        }

                        oos.close();

                } catch (FileNotFoundException e) {

                        e.printStackTrace();
                } catch (IOException e) {

                        e.printStackTrace();
                }

        }

Returns all argument-cases in a Collection

Returns:
all argument-cases in a Collection

Definition at line 1168 of file ArgCBR.java.

                                                                 {
                return argCB.values();
        }

Returns all argument-cases in a Vector

Returns:
all argument-cases in a Vector

Definition at line 1177 of file ArgCBR.java.

                                                        {
                Vector<ArgumentCase> vector = new Vector<ArgumentCase>();

                Iterator<ArrayList<ArgumentCase>> iterLists = argCB.values().iterator();
                while (iterLists.hasNext()) {
                        ArrayList<ArgumentCase> list = iterLists.next();
                        Iterator<ArgumentCase> iterArgCase = list.iterator();
                        while (iterArgCase.hasNext()) {
                                vector.add(iterArgCase.next());
                        }
                }

                return vector;
        }
ArrayList<Float> es.upv.dsic.gti_ia.argAgents.argCBR.ArgCBR.getAttackDegree ( ArrayList< SimilarArgumentCase sameProblemAcceptedArgCases,
ArrayList< Position initialPositions 
)

Returns the attack degree of each given Position

Parameters:
sameProblemAcceptedArgCasesargument-cases with the same problem description and that were accepted
initialPositionsArrayList with different positions, but with the same problem description
Returns:
an ArrayList of Float with the attack degree of each initial position

Definition at line 632 of file ArgCBR.java.

                                                              {

                ArrayList<ArrayList<SimilarArgumentCase>> allPositionsCases = getAllPositionArgCases(
                                sameProblemAcceptedArgCases, initialPositions);

                ArrayList<Float> positionAttacksAverages = new ArrayList<Float>();

                // calculate min and max attacks
                int minAttacks = Integer.MAX_VALUE;
                int maxAttacks = Integer.MIN_VALUE;
                Iterator<ArrayList<SimilarArgumentCase>> iterListAllPositions = allPositionsCases.iterator();
                while (iterListAllPositions.hasNext()) {
                        ArrayList<SimilarArgumentCase> argCasesList = iterListAllPositions.next();
                        Iterator<SimilarArgumentCase> iterCasesOfPosition = argCasesList.iterator();
                        float positionAttacksAverage = 0f;
                        while (iterCasesOfPosition.hasNext()) {
                                SimilarArgumentCase simArgCasePosition = iterCasesOfPosition.next();
                                int nAttacks = simArgCasePosition.getArgumentCase().getArgumentSolution()
                                                .getCounterExamplesDomCaseIDList().size()
                                                + simArgCasePosition.getArgumentCase().getArgumentSolution().getCounterExamplesArgCaseIDList()
                                                                .size()
                                                + simArgCasePosition.getArgumentCase().getArgumentSolution().getDistinguishingPremises().size()
                                                + simArgCasePosition.getArgumentCase().getArgumentSolution().getExceptions().size()
                                                + simArgCasePosition.getArgumentCase().getArgumentSolution().getPresumptions().size();
                                if (nAttacks < minAttacks)
                                        minAttacks = nAttacks;
                                if (nAttacks > maxAttacks)
                                        maxAttacks = nAttacks;
                                positionAttacksAverage += nAttacks;// add attacks to obtain the
                                                                                                        // average
                        }
                        // calculate attacks average of this position and store it in the
                        // list
                        positionAttacksAverage = positionAttacksAverage / argCasesList.size();
                        positionAttacksAverages.add(positionAttacksAverage);
                }

                ArrayList<Float> attackDegrees = new ArrayList<Float>();

                Iterator<Float> iterAverages = positionAttacksAverages.iterator();
                while (iterAverages.hasNext()) {
                        float nAttacks = iterAverages.next();
                        float attackDegree = (nAttacks - minAttacks) / (maxAttacks - minAttacks);
                        attackDegrees.add(attackDegree);
                }

                return attackDegrees;
        }
ArrayList<Float> es.upv.dsic.gti_ia.argAgents.argCBR.ArgCBR.getDegrees ( ArgumentProblem  argProblem,
Solution  solution,
ArrayList< Position allPositions,
int  index 
)

Return a list with the degrees (attack, efficiency, explanatory power, persuasiveness, support and risk) of an argument-case

Parameters:
argProblemProblem to solve
solutionSolution that proposes the argument-case
allPositionsPositions to calculate the degrees of the argument-case
indexIndex of the position that represents the argument-case which the degrees are being calculated
Returns:
list with the degrees

Definition at line 373 of file ArgCBR.java.

                                   {

                ArrayList<Float> degrees = new ArrayList<Float>();

                ArrayList<SimilarArgumentCase> mostSimilarArgCases = getMostSimilarArgCases(argProblem);

                for (int i = 0; i < mostSimilarArgCases.size(); i++) {
                        SimilarArgumentCase simArg = mostSimilarArgCases.get(i);
                        // if it has different promote value, remove it
                        if (!simArg.getArgumentCase().getArgumentSolution().getPromotesValue()
                                        .equalsIgnoreCase(solution.getPromotesValue())) {
                                mostSimilarArgCases.remove(i);
                                i--;
                        }
                }

                ArrayList<SimilarArgumentCase> sameProblemAcceptedArgCases = getSameProblemAcceptedArgCases(mostSimilarArgCases);
                ArrayList<SimilarArgumentCase> sameProblemConclusionArgCases = getSameProblemConclusionArgCases(
                                mostSimilarArgCases, solution);
                ArrayList<SimilarArgumentCase> sameProblemConclusionAcceptedArgCases = getSameProblemConclusionAcceptedArgCases(sameProblemConclusionArgCases);
                ArrayList<SimilarArgumentCase> sameProblemConclusionAcceptedAttackedArgCases = getSameProblemConclusionAcceptedAttackedArgCases(sameProblemConclusionAcceptedArgCases);

                Iterator<SimilarArgumentCase> iteArgAccC = sameProblemConclusionAcceptedArgCases.iterator();
                int argAccC = 0;
                while (iteArgAccC.hasNext()) {
                        argAccC += iteArgAccC.next().getArgumentCase().getTimesUsed();
                }

                Iterator<SimilarArgumentCase> iteArgC = sameProblemConclusionArgCases.iterator();
                int argC = 0;
                while (iteArgC.hasNext()) {
                        argC += iteArgC.next().getArgumentCase().getTimesUsed();
                }

                float persuasivenessDegree = 0f;
                if (argC > 0)
                        persuasivenessDegree = argAccC / argC;

                Iterator<SimilarArgumentCase> iteArg = mostSimilarArgCases.iterator();
                int arg = 0;
                while (iteArg.hasNext()) {
                        arg += iteArg.next().getArgumentCase().getTimesUsed();
                }

                float supportDegree = 0f;
                if (arg > 0)
                        supportDegree = argAccC / arg;

                Iterator<SimilarArgumentCase> iteArgAccCAtt = sameProblemConclusionAcceptedAttackedArgCases.iterator();
                int argAccCAtt = 0;
                while (iteArgAccCAtt.hasNext()) {
                        argAccCAtt += iteArgAccCAtt.next().getArgumentCase().getTimesUsed();
                }

                float riskDegree = 0f;
                if (argAccC > 0)
                        riskDegree = argAccCAtt / argAccC;

                // Here we foster simplicity over efficiency, since for each position it
                // is calculated the attack degrees of allPositions
                float attackDegree = 0f;
                ArrayList<Float> attackDegrees = getAttackDegree(sameProblemAcceptedArgCases, allPositions);
                attackDegree = attackDegrees.get(index);

                // Here we foster simplicity over efficiency, since for each position it
                // is calculated the efficiency degree of allPositions
                float efficiencyDegree = 0f;
                ArrayList<Float> efficiencyDegrees = getEfficiencyDegree(sameProblemAcceptedArgCases, allPositions);
                efficiencyDegree = efficiencyDegrees.get(index);

                // Here we foster simplicity over efficiency, since for each position it
                // is calculated the explanatory power of allPositions
                float explanatoryPower = 0f;
                ArrayList<Float> explanatoryPowers = getExplanatoryPower(sameProblemAcceptedArgCases, allPositions);
                explanatoryPower = explanatoryPowers.get(index);

                degrees.add(persuasivenessDegree);
                degrees.add(supportDegree);
                degrees.add(riskDegree);
                degrees.add(attackDegree);
                degrees.add(efficiencyDegree);
                degrees.add(explanatoryPower);

                return degrees;

        }
ArrayList<Float> es.upv.dsic.gti_ia.argAgents.argCBR.ArgCBR.getEfficiencyDegree ( ArrayList< SimilarArgumentCase sameProblemAcceptedArgCases,
ArrayList< Position initialPositions 
)

Returns the efficiency degree of each initial position

Parameters:
sameProblemAcceptedArgCasesargument-cases with the same problem description and that were accepted
initialPositionsArrayList with different positions, but with the same problem description
Returns:
an ArrayList of Float with the efficiency degree of each initial position

Definition at line 694 of file ArgCBR.java.

                                                              {

                ArrayList<ArrayList<SimilarArgumentCase>> allPositionsCases = getAllPositionArgCases(
                                sameProblemAcceptedArgCases, initialPositions);

                ArrayList<Float> positionStepsAverages = new ArrayList<Float>();

                // calculate min and max steps
                int minSteps = Integer.MAX_VALUE;
                int maxSteps = Integer.MIN_VALUE;
                Iterator<ArrayList<SimilarArgumentCase>> iterListAllPositions = allPositionsCases.iterator();
                while (iterListAllPositions.hasNext()) {
                        ArrayList<SimilarArgumentCase> argCasesList = iterListAllPositions.next();
                        Iterator<SimilarArgumentCase> iterCasesOfPosition = argCasesList.iterator();
                        float positionStepsAverage = 0f;
                        int positionTotalDialogueGraphs = 0;
                        while (iterCasesOfPosition.hasNext()) {
                                SimilarArgumentCase simArgCasePosition = iterCasesOfPosition.next();

                                Iterator<DialogueGraph> iterDialogueGraphs = simArgCasePosition.getArgumentCase()
                                                .getArgumentJustification().getDialogueGraphs().iterator();
                                int nSteps = 0;
                                while (iterDialogueGraphs.hasNext()) {
                                        DialogueGraph dialogueGraph = iterDialogueGraphs.next();
                                        int dialogueSteps;
                                        try {
                                                dialogueSteps = dialogueGraph.distanceToFinal(simArgCasePosition.getArgumentCase().getID());
                                        } catch (Exception e) {

                                                e.printStackTrace();
                                                continue;
                                        }
                                        if (dialogueSteps < minSteps)
                                                minSteps = dialogueSteps;
                                        if (dialogueSteps > maxSteps)
                                                maxSteps = dialogueSteps;

                                        nSteps += dialogueSteps;
                                        positionTotalDialogueGraphs++;
                                }

                                positionStepsAverage += nSteps;// add steps to obtain the
                                                                                                // average
                        }
                        // calculate steps average of this position and store it in the list
                        positionStepsAverage = positionStepsAverage / positionTotalDialogueGraphs;
                        positionStepsAverages.add(positionStepsAverage);
                }

                ArrayList<Float> efficiencyDegrees = new ArrayList<Float>();

                Iterator<Float> iterAverages = positionStepsAverages.iterator();
                while (iterAverages.hasNext()) {
                        float nSteps = iterAverages.next();
                        float efficiencyDegree = (nSteps - minSteps) / (maxSteps - minSteps);
                        efficiencyDegrees.add(efficiencyDegree);
                }

                return efficiencyDegrees;
        }
ArrayList<Float> es.upv.dsic.gti_ia.argAgents.argCBR.ArgCBR.getExplanatoryPower ( ArrayList< SimilarArgumentCase sameProblemAcceptedArgCases,
ArrayList< Position initialPositions 
)

Returns the explanatory power of the given positions

Parameters:
sameProblemAcceptedArgCasesargument-cases with the same problem description and that were accepted
initialPositionsArrayList with different positions, but with the same problem description
Returns:
an ArrayList of Float with the explanatory power of each initial position

Definition at line 768 of file ArgCBR.java.

                                                              {

                ArrayList<ArrayList<SimilarArgumentCase>> allPositionsCases = getAllPositionArgCases(
                                sameProblemAcceptedArgCases, initialPositions);

                ArrayList<Float> kRAverages = new ArrayList<Float>();

                // calculate min and max number of used knowledge resources
                int minKR = Integer.MAX_VALUE;
                int maxKR = Integer.MIN_VALUE;
                Iterator<ArrayList<SimilarArgumentCase>> iterListAllPositions = allPositionsCases.iterator();
                while (iterListAllPositions.hasNext()) {
                        ArrayList<SimilarArgumentCase> argCasesList = iterListAllPositions.next();
                        Iterator<SimilarArgumentCase> iterCasesOfPosition = argCasesList.iterator();
                        float kRAverage = 0f;
                        while (iterCasesOfPosition.hasNext()) {
                                SimilarArgumentCase simArgCasePosition = iterCasesOfPosition.next();
                                int nKR = simArgCasePosition.getArgumentCase().getArgumentJustification().getArgumentationSchemes()
                                                .size()
                                                + simArgCasePosition.getArgumentCase().getArgumentJustification().getDomainCasesIDs().size()
                                                + simArgCasePosition.getArgumentCase().getArgumentJustification().getArgumentCasesIDs().size();
                                if (nKR < minKR)
                                        minKR = nKR;
                                if (nKR > maxKR)
                                        maxKR = nKR;
                                kRAverage += nKR;// add knowledge resources to obtain the
                                                                        // average
                        }
                        // calculate knowledge resources average of this position and store
                        // it in the list
                        kRAverage = kRAverage / argCasesList.size();
                        kRAverages.add(kRAverage);
                }

                ArrayList<Float> explanatoryPowers = new ArrayList<Float>();

                Iterator<Float> iterAverages = kRAverages.iterator();
                while (iterAverages.hasNext()) {
                        float nKR = iterAverages.next();
                        float explanatoryPower = (nKR - minKR) / (maxKR - minKR);
                        explanatoryPowers.add(explanatoryPower);
                }

                return explanatoryPowers;

        }

Get the argument-cases with the same domain context as the given argument-case and the same dependency relation. The returned argument-cases are weighted with a degree of suitability that depends on the degree of similarity with the social context of the given argument-case

Parameters:
argProblemThe argument problem with a specific domain context and social context that the returned argument-cases have to be similar
Returns:
an ArrayList of SimilarArgumentCase that have the same domain context as the given argument-case and the same dependency relation, weighted with a suitability degree

Definition at line 927 of file ArgCBR.java.

                                                                                                 {
                ArrayList<SimilarArgumentCase> mostSimilarArgCases = new ArrayList<SimilarArgumentCase>();
                Configuration c = new Configuration();

                ArrayList<ArgumentCase> domainSimilarArgCases = getDomainSimilarArgCases(argProblem.getDomainContext()
                                .getPremises());
                Iterator<ArgumentCase> iterDomainSimilarArgCases = domainSimilarArgCases.iterator();
                while (iterDomainSimilarArgCases.hasNext()) {
                        float suitability = 0;
                        ArgumentCase currentArgCase = iterDomainSimilarArgCases.next();

                        SocialContext socialContext = argProblem.getSocialContext();
                        // if there is a social context
                        if (socialContext != null) {
                                // if the dependency relation is the same
                                if (argProblem.getSocialContext().getDependencyRelation() == null
                                                || argProblem
                                                                .getSocialContext()
                                                                .getDependencyRelation()
                                                                .compareTo(
                                                                                currentArgCase.getArgumentProblem().getSocialContext().getDependencyRelation()) == 0) {
                                        float proponentIDcomp = 0f, proponentPrefcomp = 0f, opponentIDcomp = 0f, opponentPrefcomp = 0f, groupIDcomp = 0f, groupPrefcomp = 0f;
                                        try {
                                                if (argProblem.getSocialContext().getProponent().getID() == currentArgCase.getArgumentProblem()
                                                                .getSocialContext().getProponent().getID())
                                                        proponentIDcomp = c.argCBRproponentidweight;
                                        } catch (Exception e) {

                                        }
                                        try {
                                                if (argProblem
                                                                .getSocialContext()
                                                                .getProponent()
                                                                .getValPref()
                                                                .getPreferred()
                                                                .equalsIgnoreCase(
                                                                                currentArgCase.getArgumentProblem().getSocialContext().getProponent()
                                                                                                .getValPref().getPreferred()))
                                                        proponentPrefcomp = c.argCBRproponentprefweight;
                                        } catch (Exception e) {

                                        }

                                        try {
                                                if (argProblem.getSocialContext().getOpponent().getID() == currentArgCase.getArgumentProblem()
                                                                .getSocialContext().getOpponent().getID())
                                                        opponentIDcomp = c.argCBRopponentidweight;
                                        } catch (Exception e) {

                                        }

                                        try {
                                                if (argProblem
                                                                .getSocialContext()
                                                                .getOpponent()
                                                                .getValPref()
                                                                .getPreferred()
                                                                .equalsIgnoreCase(
                                                                                currentArgCase.getArgumentProblem().getSocialContext().getOpponent()
                                                                                                .getValPref().getPreferred()))
                                                        opponentPrefcomp = c.argCBRopponentprefweight;
                                        } catch (Exception e) {

                                        }

                                        try {
                                                if (argProblem.getSocialContext().getGroup().getID() == currentArgCase.getArgumentProblem()
                                                                .getSocialContext().getGroup().getID())
                                                        groupIDcomp = c.argCBRgroupidweight;
                                        } catch (Exception e) {

                                        }
                                        try {
                                                if (argProblem
                                                                .getSocialContext()
                                                                .getGroup()
                                                                .getValPref()
                                                                .getPreferred()
                                                                .equalsIgnoreCase(
                                                                                currentArgCase.getArgumentProblem().getSocialContext().getGroup().getValPref()
                                                                                                .getPreferred()))
                                                        groupPrefcomp = c.argCBRgroupprefweight;
                                        } catch (Exception e) {

                                        }

                                        suitability = (proponentIDcomp + proponentPrefcomp + opponentIDcomp + opponentPrefcomp
                                                        + groupIDcomp + groupPrefcomp)
                                                        / (c.argCBRproponentidweight + c.argCBRproponentprefweight + c.argCBRopponentidweight
                                                                        + c.argCBRopponentprefweight + c.argCBRgroupidweight + c.argCBRgroupprefweight);
                                }
                        }

                        mostSimilarArgCases.add(new SimilarArgumentCase(currentArgCase, suitability));

                }

                return mostSimilarArgCases;

        }

Returns the argument-cases with the same domain and social context that have been accepted in teh past

Parameters:
premisesHashMap of the premises that describe the domain context
solutionSolution of the problem
socialContextSocialContext of the current situation
Returns:
argument-cases with the same domain and social context that have been accepted

Definition at line 830 of file ArgCBR.java.

                                                                        {
                ArrayList<SimilarArgumentCase> finalArgCases = new ArrayList<SimilarArgumentCase>();
                Configuration c = new Configuration();

                ArrayList<ArgumentCase> domainSimilarArgCases = getDomainSimilarArgCases(premises);
                Iterator<ArgumentCase> iterDomainSimilarArgCases = domainSimilarArgCases.iterator();
                while (iterDomainSimilarArgCases.hasNext()) {
                        float suitability = 0;
                        ArgumentCase currentArgCase = iterDomainSimilarArgCases.next();
                        if (socialContext.getDependencyRelation().compareTo(
                                        currentArgCase.getArgumentProblem().getSocialContext().getDependencyRelation()) == 0) {
                                float proponentIDcomp = 0f, proponentPrefcomp = 0f, opponentIDcomp = 0f, opponentPrefcomp = 0f, groupIDcomp = 0f, groupPrefcomp = 0f;
                                if (socialContext.getProponent().getID() == currentArgCase.getArgumentProblem().getSocialContext()
                                                .getProponent().getID())
                                        proponentIDcomp = c.argCBRproponentidweight;
                                if (socialContext
                                                .getProponent()
                                                .getValPref()
                                                .getPreferred()
                                                .equalsIgnoreCase(
                                                                currentArgCase.getArgumentProblem().getSocialContext().getProponent().getValPref()
                                                                                .getPreferred()))
                                        proponentPrefcomp = c.argCBRproponentprefweight;

                                if (socialContext.getOpponent().getID() == currentArgCase.getArgumentProblem().getSocialContext()
                                                .getOpponent().getID())
                                        opponentIDcomp = c.argCBRopponentidweight;
                                if (socialContext
                                                .getOpponent()
                                                .getValPref()
                                                .getPreferred()
                                                .equalsIgnoreCase(
                                                                currentArgCase.getArgumentProblem().getSocialContext().getOpponent().getValPref()
                                                                                .getPreferred()))
                                        opponentPrefcomp = c.argCBRopponentprefweight;

                                if (socialContext.getGroup().getID() == currentArgCase.getArgumentProblem().getSocialContext()
                                                .getGroup().getID())
                                        groupIDcomp = c.argCBRgroupidweight;
                                if (socialContext
                                                .getGroup()
                                                .getValPref()
                                                .getPreferred()
                                                .equalsIgnoreCase(
                                                                currentArgCase.getArgumentProblem().getSocialContext().getGroup().getValPref()
                                                                                .getPreferred()))
                                        groupPrefcomp = c.argCBRgroupprefweight;

                                suitability = (proponentIDcomp + proponentPrefcomp + opponentIDcomp + opponentPrefcomp + groupIDcomp + groupPrefcomp)
                                                / (c.argCBRproponentidweight + c.argCBRproponentprefweight + c.argCBRopponentidweight
                                                                + c.argCBRopponentprefweight + c.argCBRgroupidweight + c.argCBRgroupprefweight);

                                finalArgCases.add(new SimilarArgumentCase(currentArgCase, suitability));

                        }

                }

                // only with the same solution id, and the same promoted value
                for (int i = 0; i < finalArgCases.size(); i++) {
                        if (finalArgCases.get(i).getArgumentCase().getArgumentSolution().getConclusion().getID() != solution
                                        .getConclusion().getID()
                                        || !finalArgCases.get(i).getArgumentCase().getArgumentSolution().getPromotesValue()
                                                        .equalsIgnoreCase(solution.getPromotesValue())) {
                                finalArgCases.remove(i);
                                i--;
                        }
                }

                // only accepted cases
                for (int i = 0; i < finalArgCases.size(); i++) {
                        // if the case is not accepted, remove it from list
                        if (finalArgCases.get(i).getArgumentCase().getArgumentSolution().getAcceptabilityState()
                                        .compareTo(AcceptabilityStatus.ACCEPTABLE) != 0) {
                                finalArgCases.remove(i);
                                i--;
                        }
                }

                return finalArgCases;
        }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables