Search in sources :

Example 16 with Model

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;
}
Also used : Resource(org.hl7.fhir.dstu2.model.Resource) Resource(org.hl7.fhir.dstu2.model.Resource) org.hl7.fhir.r5.model(org.hl7.fhir.r5.model) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 17 with Model

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;
}
Also used : UserProfile(customskinloader.profile.UserProfile) Model(customskinloader.profile.ModelManager0.Model) LinkedHashMap(java.util.LinkedHashMap)

Example 18 with Model

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();
}
Also used : Context(com.microsoft.z3.Context) BoolExpr(com.microsoft.z3.BoolExpr) Solver(com.microsoft.z3.Solver) Model(com.microsoft.z3.Model) Test(org.junit.Test)

Example 19 with Model

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());
}
Also used : BoolExpr(com.microsoft.z3.BoolExpr) Model(com.microsoft.z3.Model) SolutionFinder(de.bmoth.backend.z3.SolutionFinder) Test(org.junit.Test)

Example 20 with Model

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);
    }
}
Also used : Status(com.microsoft.z3.Status) BatfishException(org.batfish.common.BatfishException) BoolExpr(com.microsoft.z3.BoolExpr) SortedSet(java.util.SortedSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SortedSet(java.util.SortedSet) SortedMap(java.util.SortedMap) Model(com.microsoft.z3.Model) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Tuple(org.batfish.symbolic.utils.Tuple)

Aggregations

Test (org.junit.Test)51 Model (org.eclipse.xtext.valueconverter.bug250313.Model)30 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)25 ModelName (com.google.cloud.automl.v1.ModelName)24 Model (com.google.cloud.aiplatform.v1.Model)16 Model (com.google.cloud.automl.v1.Model)16 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)16 LocationName (com.google.cloud.aiplatform.v1.LocationName)14 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)14 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)14 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)14 InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)13 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)13 OperationMetadata (com.google.cloud.automl.v1.OperationMetadata)12 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)11 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)11 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)11 TimestampSplit (com.google.cloud.aiplatform.v1.TimestampSplit)11 Status (com.google.rpc.Status)11 Model (com.microsoft.z3.Model)11