src/main/java/org/thegalactic/context/Context.java
public Context arrowClosureAttribute(TreeSet<Comparable> attr) {
        ConceptLattice cl = this.getReverseContext().conceptLattice(true); // Where is bug with it ^^
        ArrowRelation ar = cl.getArrowRelation();
        Context down = ar.getDoubleDownArrowTable();
        Context up = ar.getDoubleUpArrowTable();
        Context ctx = new Context();
        ctx.addAllToAttributes(attr);
        int sizeObs = ctx.getObservations().size();
        int sizeAttr = ctx.getAttributes().size();
        int prevObs = 0;
        int prevAttr = 0;
        while ((prevObs < sizeObs) || (prevAttr < sizeAttr)) {
            for (Comparable a : ctx.getAttributes()) {
                // Concept corresponding to observation a
                TreeSet<Comparable> setAa = this.getExtent(a);
                TreeSet<Comparable> setBa = this.getIntent(setAa);
                Concept cptA = new Concept(setAa, setBa);
                TreeSet<Comparable> obsDown = down.getExtent(cl.getNode(cptA));
                for (Comparable o : this.getObservations()) {
                    // Try to find attributes in down-arrow relation
                    TreeSet<Comparable> setBo = this.getIntent(o);
                    TreeSet<Comparable> setAo = this.getExtent(setBo);
                    Concept cptO = new Concept(setAo, setBo); // Concept corresponding to attribute o
                    if (obsDown.contains(cl.getNode(cptO))) {
                        ctx.addToObservations(o);
                    }
                }
            }
            for (Comparable o : ctx.getObservations()) {
                // Concept corresponding to observation o
                TreeSet<Comparable> setBo = this.getIntent(o);
                TreeSet<Comparable> setAo = this.getExtent(setBo);
                Concept cptO = new Concept(setAo, setBo);
                TreeSet<Comparable> attrUp = up.getIntent(cl.getNode(cptO)); // Doesn't work with up.getIntent(cptO) ...
                for (Comparable a : this.getAttributes()) { // NOT GOOD for complexity :-(
                    // Try to find attributes in up-arrow relation
                    TreeSet<Comparable> setAa = this.getExtent(a);
                    TreeSet<Comparable> setBa = this.getIntent(setAa);
                    Concept cptA = new Concept(setAa, setBa); // Concept corresponding to attribute a
                    if (attrUp.contains(cl.getNode(cptA))) {
                        ctx.addToAttributes(a);
                    }
                }
            }
            prevObs = sizeObs;
            prevAttr = sizeAttr;
            sizeObs = ctx.getObservations().size();
            sizeAttr = ctx.getAttributes().size();
        }
        return this.getSubContext(ctx.getObservations(), ctx.getAttributes());
    }
/**
     * Returns the arrow-closed subcontext of this component containing attr.
     *
     * A sub-context (H,N) of (G,M) is arrow-closed if :
     * 1. For all h in H, h uparrow m implies m in N and
     * 2. For all n in N, g downarrow n implies g in H
     *
     * @param attr set of attributes to keep
     *
     * @return the arrow-closed subcontext of this component containing attr.
     */
Returns the arrow-closed subcontext of this component containing attr.
A sub-context (H,N) of (G,M) is arrow-closed if :
1. For all h in H, h uparrow m implies m in N and
2. For all n in N, g downarrow n implies g in H

@param attr set of attributes to keep

@return the arrow-closed subcontext of this component containing attr.
Returns the arrow - closed subcontext of this component containing attr . A sub - context ( H N ) of ( G M ) is arrow - closed if : 1 . For all h in H h uparrow m implies m in N and 2 . For all n in N g downarrow n implies g in H @param attr set of attributes to keep @return the arrow - closed subcontext of this component containing attr .
public Context arrowClosureAttribute(TreeSet<Comparable> attr) {
        ConceptLattice cl = this.getReverseContext().conceptLattice(true); 
        ArrowRelation ar = cl.getArrowRelation();
        Context down = ar.getDoubleDownArrowTable();
        Context up = ar.getDoubleUpArrowTable();
        Context ctx = new Context();
        ctx.addAllToAttributes(attr);
        int sizeObs = ctx.getObservations().size();
        int sizeAttr = ctx.getAttributes().size();
        int prevObs = 0;
        int prevAttr = 0;
        while ((prevObs < sizeObs) || (prevAttr < sizeAttr)) {
            for (Comparable a : ctx.getAttributes()) {
                TreeSet<Comparable> setAa = this.getExtent(a);
                TreeSet<Comparable> setBa = this.getIntent(setAa);
                Concept cptA = new Concept(setAa, setBa);
                TreeSet<Comparable> obsDown = down.getExtent(cl.getNode(cptA));
                for (Comparable o : this.getObservations()) {
                    TreeSet<Comparable> setBo = this.getIntent(o);
                    TreeSet<Comparable> setAo = this.getExtent(setBo);
                    Concept cptO = new Concept(setAo, setBo); 
                    if (obsDown.contains(cl.getNode(cptO))) {
                        ctx.addToObservations(o);
                    }
                }
            }
            for (Comparable o : ctx.getObservations()) {
                TreeSet<Comparable> setBo = this.getIntent(o);
                TreeSet<Comparable> setAo = this.getExtent(setBo);
                Concept cptO = new Concept(setAo, setBo);
                TreeSet<Comparable> attrUp = up.getIntent(cl.getNode(cptO)); 
                for (Comparable a : this.getAttributes()) { 
                    TreeSet<Comparable> setAa = this.getExtent(a);
                    TreeSet<Comparable> setBa = this.getIntent(setAa);
                    Concept cptA = new Concept(setAa, setBa); 
                    if (attrUp.contains(cl.getNode(cptA))) {
                        ctx.addToAttributes(a);
                    }
                }
            }
            prevObs = sizeObs;
            prevAttr = sizeAttr;
            sizeObs = ctx.getObservations().size();
            sizeAttr = ctx.getAttributes().size();
        }
        return this.getSubContext(ctx.getObservations(), ctx.getAttributes());
    }
public Context arrowClosureAttribute ( TreeSet < Comparable > attr ) { ConceptLattice cl = this . getReverseContext ( ) . conceptLattice ( true ) ; ArrowRelation ar = cl . getArrowRelation ( ) ; Context down = ar . getDoubleDownArrowTable ( ) ; Context up = ar . getDoubleUpArrowTable ( ) ; Context ctx = new Context ( ) ; ctx . addAllToAttributes ( attr ) ; int sizeObs = ctx . getObservations ( ) . size ( ) ; int sizeAttr = ctx . getAttributes ( ) . size ( ) ; int prevObs = 0 ; int prevAttr = 0 ; while ( ( prevObs < sizeObs ) || ( prevAttr < sizeAttr ) ) { for ( Comparable a : ctx . getAttributes ( ) ) { TreeSet < Comparable > setAa = this . getExtent ( a ) ; TreeSet < Comparable > setBa = this . getIntent ( setAa ) ; Concept cptA = new Concept ( setAa , setBa ) ; TreeSet < Comparable > obsDown = down . getExtent ( cl . getNode ( cptA ) ) ; for ( Comparable o : this . getObservations ( ) ) { TreeSet < Comparable > setBo = this . getIntent ( o ) ; TreeSet < Comparable > setAo = this . getExtent ( setBo ) ; Concept cptO = new Concept ( setAo , setBo ) ; if ( obsDown . contains ( cl . getNode ( cptO ) ) ) { ctx . addToObservations ( o ) ; } } } for ( Comparable o : ctx . getObservations ( ) ) { TreeSet < Comparable > setBo = this . getIntent ( o ) ; TreeSet < Comparable > setAo = this . getExtent ( setBo ) ; Concept cptO = new Concept ( setAo , setBo ) ; TreeSet < Comparable > attrUp = up . getIntent ( cl . getNode ( cptO ) ) ; for ( Comparable a : this . getAttributes ( ) ) { TreeSet < Comparable > setAa = this . getExtent ( a ) ; TreeSet < Comparable > setBa = this . getIntent ( setAa ) ; Concept cptA = new Concept ( setAa , setBa ) ; if ( attrUp . contains ( cl . getNode ( cptA ) ) ) { ctx . addToAttributes ( a ) ; } } } prevObs = sizeObs ; prevAttr = sizeAttr ; sizeObs = ctx . getObservations ( ) . size ( ) ; sizeAttr = ctx . getAttributes ( ) . size ( ) ; } return this . getSubContext ( ctx . getObservations ( ) , ctx . getAttributes ( ) ) ; }
Returns the arrow-closed subcontext of this component containing attr.
Returns the arrow - closed subcontext of this component containing attr .
// Where is bug with it ^^ // Concept corresponding to observation a // Try to find attributes in down-arrow relation // Concept corresponding to attribute o // Concept corresponding to observation o // Doesn't work with up.getIntent(cptO) ... // NOT GOOD for complexity :-( // Try to find attributes in up-arrow relation // Concept corresponding to attribute a