Skip to content
Snippets Groups Projects
Commit 01d5fcf9 authored by Stefano Borini's avatar Stefano Borini
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
class DataSource():
"""Base class that performs calculation or extraction of information
"""
__metaclass__ = abc.ABCMeta
def __init__(self, name):
self.name = name
@abstractclassmethod
def provides(cls):
return [CUBA.key]
def execute(self, parameters):
"""Performs the evaluation and returns a list of Result.
"""
class Simulator(DataSource):
pass
class Database(DataSource):
pass
# Represents the result of a simulator.
# It contains the resulting cuba key, the associated uncertainty and the
# originating simulator.
# Difference between uncertainty and quality: uncertainty is a numerical value
# of the value, as in the case of an experimental simulation.
# quality is the level of accuracy of the (e.g.c omputational) method, as
# the importance and reliability of that value. It should be an enumeration
# value such as HIGH, MEDIUM, POOR
Result = namedtuple("Result", "cuba_key value uncertainty originator quality")
class KPICalculator():
"""Base class that defines the equaation to compute the KPIs values from
the results of the simulators
input: a list of SimulatorResult
output: a list of KPIs.
"""
__metaclass__ = abc.ABCMeta
def execute(self, datasource_results)
"""Returns the KPIResult"""
KPIResult = namedtuple("KPIResult", "name cuba_key value uncertainty quality")
from force import *
wf=Workflow()
wf.set_mco(Dakota())
wf.set_datasources([
ViscositySimulator(),
CostExtractor(),
])
wf.objectives([
Objective(),
Objective()
])
wf.set_parameters({
"material_1": {
CUBA.FORMULA: "H2O",
CUBA.CONCENTRATION: Range(0, 100)
},
"material_2": {
CUBA.FORMULA: "glycol",
CUBA.CONCENTRATION: Formula("material_1",
lambda material_1: 100 - material_1[CUBA.CONCENTRATION])
}
})
wf.set_result_callback(callback)
# constraints vs computed value
# e.g. constraint = value from 0 to 100
# computed value = 100 - other value
# TODO: Study dakota better to understand how it works and what kind of
# interface it expects
pareto_front = wf.execute()
plot(pareto_front)
class MCO():
"""Receives a list of KPIResult to decide the next step in the parameter
space"""
__metaclass__ = abc.ABCMeta
starting_point
variable_constraints
objectives
def get_next_parameters(kpi_results):
pass
class Dakota(MCO):
def __init__(self, options):
pass
class DakotaInput():
"""Read the parameters from the dakota input file and returns
the parameters for further consumption"""
def parse(filename):
"""Returns the parameters"""
class DakotaOutput():
"""Writes the KPIs to the file for consumption by Dakota"""
# This is a prototype for the Workflow in FORCE
import abc
class Workflow():
# calculates the KPIs from the list of the cuba keys coming from the
# simulators
mco = None
data_sources = None
class ViscosityCalculator(Simulator):
pass
class CostExtractor(Database):
provides_kpi = []
class Objective()
kpi = None
optimization_type = MAXIMIZE
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment