Search in sources :

Example 1 with Uncertainty

use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.

the class UncertaintyTableTest method createUncertainty.

private Uncertainty createUncertainty() {
    Uncertainty uncertainty = Uncertainty.triangle(1, 2, 3);
    uncertainty.formula1 = "0.5 * 2";
    uncertainty.formula2 = "4 / 2";
    uncertainty.formula3 = "4 / 2";
    return uncertainty;
}
Also used : Uncertainty(org.openlca.core.model.Uncertainty)

Example 2 with Uncertainty

use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.

the class UncertaintyTableTest method testForExchange.

@Test
public void testForExchange() throws Exception {
    Exchange exchange = new Exchange();
    Uncertainty uncertainty = createUncertainty();
    exchange.uncertainty = uncertainty;
    Process process = new Process();
    process.exchanges.add(exchange);
    ProcessDao dao = new ProcessDao(database);
    dao.insert(process);
    Set<Long> set = new HashSet<>();
    set.add(process.id);
    List<CalcExchange> exchanges = cache.getExchangeCache().get(process.id);
    checkExchange(exchanges.get(0));
    dao.delete(process);
}
Also used : Exchange(org.openlca.core.model.Exchange) CalcExchange(org.openlca.core.matrix.CalcExchange) Uncertainty(org.openlca.core.model.Uncertainty) CalcExchange(org.openlca.core.matrix.CalcExchange) ProcessDao(org.openlca.core.database.ProcessDao) Process(org.openlca.core.model.Process) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with Uncertainty

use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.

the class ParameterReferencesTest method testImpactFactorUncertainty.

@Test
public void testImpactFactorUncertainty() {
    Parameter p1 = createParameter("p1", null, null, null);
    Parameter p1Intern = createParameter("p1", null, ParameterScope.PROCESS, null);
    Parameter p2 = createParameter("p2", null, null, null);
    Uncertainty u1 = createUncertainty("1", "2", "3*p2");
    Uncertainty u2 = createUncertainty("p1", "2*p1", "3*p2");
    ImpactFactor f1 = createImpactFactor("2", u1);
    ImpactFactor f2 = createImpactFactor("2", u2);
    ImpactCategory impact = createImpactCategory(new ImpactFactor[] { f1, f2 }, new Parameter[] { p1Intern });
    with((store) -> {
        JsonExport export = new JsonExport(db, store);
        export.write(impact);
        assertNotNull(store.get(ModelType.IMPACT_CATEGORY, impact.refId));
        assertNull(store.get(ModelType.PARAMETER, p1.refId));
        assertNull(store.get(ModelType.PARAMETER, p1Intern.refId));
        assertNotNull(store.get(ModelType.PARAMETER, p2.refId));
    });
}
Also used : Uncertainty(org.openlca.core.model.Uncertainty) ImpactFactor(org.openlca.core.model.ImpactFactor) Parameter(org.openlca.core.model.Parameter) ImpactCategory(org.openlca.core.model.ImpactCategory) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Example 4 with Uncertainty

use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.

the class ParameterReferencesTest method testParameterUncertainty.

@Test
public void testParameterUncertainty() {
    Uncertainty u2 = createUncertainty("1", "2", "3*p4");
    Uncertainty u4 = createUncertainty("p1", "2*p1", "3*p2");
    Parameter p1 = createParameter("p1", null, null, null);
    Parameter p2 = createParameter("p2", "2*2", null, u2);
    Parameter p3 = createParameter("p3", null, null, null);
    Parameter p4 = createParameter("p4", "2*2", null, u4);
    with((store) -> {
        JsonExport export = new JsonExport(db, store);
        export.write(p4);
        assertNotNull(store.get(ModelType.PARAMETER, p1.refId));
        assertNotNull(store.get(ModelType.PARAMETER, p2.refId));
        assertNull(store.get(ModelType.PARAMETER, p3.refId));
        assertNotNull(store.get(ModelType.PARAMETER, p4.refId));
    });
}
Also used : Uncertainty(org.openlca.core.model.Uncertainty) Parameter(org.openlca.core.model.Parameter) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Example 5 with Uncertainty

use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.

the class ParameterReferencesTest method createUncertainty.

private Uncertainty createUncertainty(String f1, String f2, String f3) {
    if (f3 == null) {
        Uncertainty u = Uncertainty.logNormal(1, 1);
        u.formula1 = f1;
        u.formula2 = f2;
        return u;
    }
    Uncertainty u = Uncertainty.triangle(1, 1, 1);
    u.formula1 = f1;
    u.formula2 = f2;
    u.formula3 = f3;
    return u;
}
Also used : Uncertainty(org.openlca.core.model.Uncertainty)

Aggregations

Uncertainty (org.openlca.core.model.Uncertainty)17 Test (org.junit.Test)7 Parameter (org.openlca.core.model.Parameter)7 AbstractZipTest (org.openlca.jsonld.AbstractZipTest)5 Process (org.openlca.core.model.Process)4 Exchange (org.openlca.core.model.Exchange)3 ImpactFactor (org.openlca.core.model.ImpactFactor)3 Flow (org.openlca.core.model.Flow)2 FlowPropertyFactor (org.openlca.core.model.FlowPropertyFactor)2 ImpactCategory (org.openlca.core.model.ImpactCategory)2 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 M (org.openlca.app.M)1 Database (org.openlca.app.db.Database)1 FlowDao (org.openlca.core.database.FlowDao)1