use of catdata.aql.Instance in project fql by CategoricalData.
the class AqlDisplay method report.
private JComponent report(Program<Exp<?>> prog, AqlEnv env, List<String> order, float c1, float c2, String pre) {
DecimalFormat df = new DecimalFormat("#.#");
df.setRoundingMode(RoundingMode.CEILING);
List<String> l = new LinkedList<>();
Object[][] rowData = new Object[env.defs.insts.size()][3];
int i = 0;
List<String> missing = new LinkedList<>();
for (String k : order) {
if (env.defs.insts.containsKey(k)) {
Instance<?, ?, ?, ?, ?, ?, ?, ?, ?> I = (Instance<?, ?, ?, ?, ?, ?, ?, ?, ?>) env.get(Kind.INSTANCE, k);
String s = k + "\t" + I.size() + "\t" + env.performance.get(k);
l.add(s);
rowData[i][0] = k;
rowData[i][1] = I.size();
rowData[i][2] = env.performance.get(k);
i++;
} else if (prog.exps.get(k).kind().equals(Kind.INSTANCE)) {
missing.add(k);
}
}
JPanel t = GuiUtil.makeTable(BorderFactory.createEmptyBorder(), "", rowData, "instance", "rows", "seconds");
JPanel pan = new JPanel(new GridLayout(1, 1));
pan.add(new JScrollPane(t));
String tsv = "instance\trows\tseconds\n" + Util.sep(l, "\n");
JTabbedPane jtb = new JTabbedPane();
String text = pre;
if (!missing.isEmpty()) {
text += "\n\nInstances not computed: " + Util.sep(Util.alphabetical(missing), ", ");
}
text += "\n\nComputation wall-clock time: " + df.format(c1) + "s\nGUI building time: " + df.format(c2) + "s\n";
Map<Kind, Float> perfs = new HashMap<>();
for (Kind k : Kind.values()) {
perfs.put(k, 0f);
}
for (String s : env.performance.keySet()) {
Kind k = prog.exps.get(s).kind();
perfs.put(k, perfs.get(k) + env.performance.get(s));
}
for (Kind k : Kind.values()) {
if (perfs.get(k) < .05f) {
continue;
}
text += "\n" + k + " computation total time: " + df.format(perfs.get(k)) + "s";
}
if (!prog.options.isEmpty()) {
text += "\n\nGlobal options:\n";
text += Util.sep(prog.options, " = ", "\n");
}
jtb.addTab("Text", new CodeTextPanel("", text));
jtb.addTab("Performance", pan);
jtb.addTab("TSV", new CodeTextPanel("", tsv));
// jtb.addTab("Tree", viewTree(prog));
return jtb;
}
use of catdata.aql.Instance in project fql by CategoricalData.
the class InstExpImport method forTheory.
public static <Ty, En, Sym, Fk, Att, Gen> Instance<Ty, En, Sym, Fk, Att, Gen, Null<?>, Gen, Null<?>> forTheory(Schema<Ty, En, Sym, Fk, Att> sch, Ctx<En, Collection<Gen>> ens0, Ctx<Ty, Collection<Null<?>>> tys0, Ctx<Gen, Ctx<Fk, Gen>> fks0, Ctx<Gen, Ctx<Att, Term<Ty, Void, Sym, Void, Void, Void, Null<?>>>> atts0, AqlOptions op) {
Set<Pair<Term<Ty, En, Sym, Fk, Att, Gen, Null<?>>, Term<Ty, En, Sym, Fk, Att, Gen, Null<?>>>> eqs0 = new HashSet<>();
Collage<Ty, En, Sym, Fk, Att, Gen, Null<?>> col = new Collage<>(sch.collage());
for (Gen gen : fks0.keySet()) {
for (Fk fk : fks0.get(gen).keySet()) {
eqs0.add(new Pair<>(Term.Fk(fk, Term.Gen(gen)), Term.Gen(fks0.get(gen).get(fk))));
col.eqs.add(new Eq<>(new Ctx<>(), Term.Fk(fk, Term.Gen(gen)), Term.Gen(fks0.get(gen).get(fk))));
}
}
for (Gen gen : atts0.keySet()) {
for (Att att : atts0.get(gen).keySet()) {
eqs0.add(new Pair<>(Term.Att(att, Term.Gen(gen)), atts0.get(gen).get(att).convert()));
col.eqs.add(new Eq<>(new Ctx<>(), Term.Att(att, Term.Gen(gen)), atts0.get(gen).get(att).convert()));
}
}
for (En en : ens0.keySet()) {
for (Gen gen : ens0.get(en)) {
col.gens.put(gen, en);
}
}
for (Ty ty : tys0.keySet()) {
for (Null<?> sk : tys0.get(ty)) {
col.sks.put(sk, ty);
}
}
InitialAlgebra<Ty, En, Sym, Fk, Att, Gen, Null<?>, ID> initial = new InitialAlgebra<>(op, sch, col, new It(), (Gen x) -> x.toString(), (Null<?> x) -> x.toString());
Instance<Ty, En, Sym, Fk, Att, Gen, Null<?>, ID, Chc<Null<?>, Pair<ID, Att>>> I = new LiteralInstance<>(sch, col.gens.map, col.sks.map, eqs0, initial.dp(), initial, (Boolean) op.getOrDefault(AqlOption.require_consistency), (Boolean) op.getOrDefault(AqlOption.allow_java_eqs_unsafe));
@SuppressWarnings("unchecked") Instance<Ty, En, Sym, Fk, Att, Gen, Null<?>, Gen, Null<?>> J = (Instance<Ty, En, Sym, Fk, Att, Gen, Null<?>, Gen, Null<?>>) ((Object) I);
return J;
}
Aggregations