use of com.google.cloud.automl.v1.Model in project org.hl7.fhir.core by hapifhir.
the class TerminologyClientR2 method read.
@Override
public CanonicalResource read(String type, String id) {
Class<Resource> t;
try {
// todo: do we have to deal with any resource renaming? Use cases are limited...
t = (Class<Resource>) Class.forName("org.hl7.fhir.dstu2.model." + type);
} catch (ClassNotFoundException e) {
throw new FHIRException("Unable to fetch resources of type " + type + " in R2");
}
org.hl7.fhir.dstu2.model.Resource r2 = client.read(t, id);
if (r2 == null) {
throw new FHIRException("Unable to fetch resource " + Utilities.pathURL(getAddress(), type, id));
}
org.hl7.fhir.r5.model.Resource r5 = VersionConvertorFactory_10_50.convertResource(r2);
if (r5 != null) {
throw new FHIRException("Unable to convert resource " + Utilities.pathURL(getAddress(), type, id) + " to R5 (internal representation)");
}
if (!(r5 instanceof CanonicalResource)) {
throw new FHIRException("Unable to convert resource " + Utilities.pathURL(getAddress(), type, id) + " to R5 canonical resource (internal representation)");
}
return (CanonicalResource) r5;
}
use of com.google.cloud.automl.v1.Model in project MCCustomSkinLoader by xfl03.
the class CustomSkinAPI method toUserProfile.
@Override
public UserProfile toUserProfile(String root, String json, boolean local) {
CustomSkinAPIProfile profile = CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
UserProfile p = new UserProfile();
if (StringUtils.isNotBlank(profile.skin)) {
p.skinUrl = root + TEXTURES + profile.skin;
if (local)
p.skinUrl = HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
}
if (StringUtils.isNotBlank(profile.cape)) {
p.capeUrl = root + TEXTURES + profile.cape;
if (local)
p.capeUrl = HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
}
if (StringUtils.isNotBlank(profile.elytra)) {
p.elytraUrl = root + TEXTURES + profile.elytra;
if (local)
p.elytraUrl = HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
}
Map<String, String> textures = new LinkedHashMap<String, String>();
if (profile.skins != null)
textures.putAll(profile.skins);
if (profile.textures != null)
textures.putAll(profile.textures);
if (textures.isEmpty())
return p;
boolean hasSkin = false;
for (String model : textures.keySet()) {
Model enumModel = ModelManager0.getEnumModel(model);
if (enumModel == null || StringUtils.isEmpty(textures.get(model)))
continue;
if (ModelManager0.isSkin(enumModel))
if (hasSkin)
continue;
else
hasSkin = true;
String url = root + TEXTURES + textures.get(model);
if (local)
url = HttpTextureUtil.getLocalFakeUrl(url);
p.put(enumModel, url);
}
return p;
}
use of com.google.cloud.automl.v1.Model in project theta by ftsrg.
the class Z3ModelTest method test.
@Test
public void test() {
final Context context = new Context();
final Solver solver = context.mkSimpleSolver();
final BoolExpr a = context.mkBoolConst("a");
final BoolExpr b = context.mkBoolConst("b");
final BoolExpr expr = context.mkOr(a, b);
solver.add(expr);
solver.check();
final Model model = solver.getModel();
Assert.assertTrue(model.getConstInterp(a).isTrue());
Assert.assertNull(model.getConstInterp(b));
context.close();
}
use of com.google.cloud.automl.v1.Model in project bmoth by hhu-stups.
the class Issue73Test method testSatPredicateWithoutModel.
@Test
public void testSatPredicateWithoutModel() throws IOException {
String formula = "1 < 2";
BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
SolutionFinder finder = new SolutionFinder(z3Solver, z3Context);
Set<Model> solutions = finder.findSolutions(constraint, 20);
assertEquals(0, solutions.size());
}
use of com.google.cloud.automl.v1.Model in project batfish by batfish.
the class Encoder method verify.
/**
* Checks that a property is always true by seeing if the encoding is unsatisfiable. mkIf the
* model is satisfiable, then there is a counter example to the property.
*
* @return A VerificationResult indicating the status of the check.
*/
public Tuple<VerificationResult, Model> verify() {
EncoderSlice mainSlice = _slices.get(MAIN_SLICE_NAME);
int numVariables = _allVariables.size();
int numConstraints = _solver.getAssertions().length;
int numNodes = mainSlice.getGraph().getConfigurations().size();
int numEdges = 0;
for (Map.Entry<String, Set<String>> e : mainSlice.getGraph().getNeighbors().entrySet()) {
numEdges += e.getValue().size();
}
long start = System.currentTimeMillis();
Status status = _solver.check();
long time = System.currentTimeMillis() - start;
VerificationStats stats = null;
if (_question.getBenchmark()) {
stats = new VerificationStats();
stats.setAvgNumNodes(numNodes);
stats.setMaxNumNodes(numNodes);
stats.setMinNumNodes(numNodes);
stats.setAvgNumEdges(numEdges);
stats.setMaxNumEdges(numEdges);
stats.setMinNumEdges(numEdges);
stats.setAvgNumVariables(numVariables);
stats.setMaxNumVariables(numVariables);
stats.setMinNumVariables(numVariables);
stats.setAvgNumConstraints(numConstraints);
stats.setMaxNumConstraints(numConstraints);
stats.setMinNumConstraints(numConstraints);
stats.setAvgSolverTime(time);
stats.setMaxSolverTime(time);
stats.setMinSolverTime(time);
}
if (status == Status.UNSATISFIABLE) {
VerificationResult res = new VerificationResult(true, null, null, null, null, null, stats);
return new Tuple<>(res, null);
} else if (status == Status.UNKNOWN) {
throw new BatfishException("ERROR: satisfiability unknown");
} else {
VerificationResult result;
Model m;
while (true) {
m = _solver.getModel();
SortedMap<String, String> model = new TreeMap<>();
SortedMap<String, String> packetModel = new TreeMap<>();
SortedSet<String> fwdModel = new TreeSet<>();
SortedMap<String, SortedMap<String, String>> envModel = new TreeMap<>();
SortedSet<String> failures = new TreeSet<>();
buildCounterExample(this, m, model, packetModel, fwdModel, envModel, failures);
if (_previousEncoder != null) {
buildCounterExample(_previousEncoder, m, model, packetModel, fwdModel, envModel, failures);
}
result = new VerificationResult(false, model, packetModel, envModel, fwdModel, failures, stats);
if (!_question.getMinimize()) {
break;
}
BoolExpr blocking = environmentBlockingClause(m);
add(blocking);
Status s = _solver.check();
if (s == Status.UNSATISFIABLE) {
break;
}
if (s == Status.UNKNOWN) {
throw new BatfishException("ERROR: satisfiability unknown");
}
}
return new Tuple<>(result, m);
}
}
Aggregations