brandmaier/onyx

Rewriting Onyx Script Export to be more readable

Opened this issue · 0 comments

The Onyx Script Export in importexport.OnyxJavaExport should be more readable. Timo added some methods to OnyxModel that generate nodes/edges and request their addition. Code like this works and looks fairly good, plus should be easy to put in loops for extending in some design:

public static void tryingReadableBuild()  {
    OnyxModel model = new OnyxModel();
    model.setMeanTreatment(MeanTreatment.implicit);

    Node n1 = model.newNode("M1", false); 
    Node n2 = model.newNode("M2", false); 
    Node n3 = model.newNode("factor",true); 
    Edge e1 = model.newEdge(n3,n1,false,1.0); 
    Edge e2 = model.newEdge(n3,n2,false,1.0); 
    Edge v1 = model.newEdge(n1,n1,true,"var1",1.0); 
    Edge v2 = model.newEdge(n2,n2,true,"var2",1.0); 
    Edge v3 = model.newEdge(n3,n3,true,"factor Variance",1.0);

    RawDataset data = RawDataset.loadRawDataset("exampleData.txt");
    
    boolean allok = model.runUntil(data, Until.CONVERGED, 60000);
    if (!allok) System.err.println("Model "+model.name+" did not converge reliably.");
    ModelRunUnit est = model.modelRun.getBestUnit();
    System.out.println(est.getParameterDescription());

}

Torben is assigned to create the new export function in a fork, to be remerged after control by Andy.