Search in sources :

Example 1 with IStructure

use of edu.illinois.cs.cogcomp.sl.core.IStructure in project cogcomp-nlp by CogComp.

the class JLISCuttingPlaneILPSolverGurobi method populateViolatedConstraints.

private void populateViolatedConstraints(List<List<ILPConstraint>> violated) {
    violated.clear();
    IStructure y = outputGenerator.getOutput(baseSolver, variables, x);
    for (ILPConstraintGenerator c : this.cuttingPlaneConstraints) {
        // see if the constraint generator has anything to say about the input
        // upon which it operates. If not, then use the input to the inference,
        // namely x
        IInstance input = c.getConstraintInput();
        if (input == null)
            input = x;
        IStructure output = c.getConstraintOutput(y);
        List<ILPConstraint> cs = c.getViolatedILPConstraints(input, output, variables);
        violated.add(cs);
    }
}
Also used : IStructure(edu.illinois.cs.cogcomp.sl.core.IStructure) IInstance(edu.illinois.cs.cogcomp.sl.core.IInstance)

Example 2 with IStructure

use of edu.illinois.cs.cogcomp.sl.core.IStructure in project cogcomp-nlp by CogComp.

the class RealMeasureAverager method getFoldData.

public Pair<StructuredProblem, StructuredProblem> getFoldData(StructuredProblem problem, int foldId) {
    int testStart = splitIds[foldId];
    int testEnd = splitIds[foldId + 1];
    StructuredProblem train = new StructuredProblem();
    StructuredProblem test = new StructuredProblem();
    train.input_list = new ArrayList<IInstance>();
    test.input_list = new ArrayList<IInstance>();
    train.output_list = new ArrayList<IStructure>();
    test.output_list = new ArrayList<IStructure>();
    for (int i = 0; i < problem.input_list.size(); i++) {
        IInstance x = problem.input_list.get(i);
        IStructure y = problem.output_list.get(i);
        if (i < testStart || i >= testEnd) {
            train.input_list.add(x);
            train.output_list.add(y);
        } else {
            test.input_list.add(x);
            test.output_list.add(y);
        }
    }
    return new Pair<StructuredProblem, StructuredProblem>(train, test);
}
Also used : StructuredProblem(edu.illinois.cs.cogcomp.sl.core.StructuredProblem) IInstance(edu.illinois.cs.cogcomp.sl.core.IInstance) IStructure(edu.illinois.cs.cogcomp.sl.core.IStructure) Pair(edu.illinois.cs.cogcomp.core.datastructures.Pair)

Aggregations

IInstance (edu.illinois.cs.cogcomp.sl.core.IInstance)2 IStructure (edu.illinois.cs.cogcomp.sl.core.IStructure)2 Pair (edu.illinois.cs.cogcomp.core.datastructures.Pair)1 StructuredProblem (edu.illinois.cs.cogcomp.sl.core.StructuredProblem)1