Skip to content

Commit

Permalink
Merge conflicts resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth-T-Moore committed Sep 24, 2014
2 parents 7a9e9be + 65a9001 commit c3cd270
Show file tree
Hide file tree
Showing 25 changed files with 850 additions and 792 deletions.
499 changes: 490 additions & 9 deletions config/systests.cfg

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions openmdao.lib/src/openmdao/lib/drivers/brent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from scipy.optimize import brentq

from openmdao.main.driver import Driver
from openmdao.main.cyclicflow import CyclicWorkflow
from openmdao.main.interfaces import IHasParameters, IHasEqConstraints, \
ISolver, implements
from openmdao.main.hasparameters import HasParameters
Expand Down Expand Up @@ -55,7 +54,6 @@ class Brent(Driver):

def __init__(self):
super(Brent, self).__init__()
self.workflow = CyclicWorkflow()
self.xstar = None

def _eval(self, x):
Expand Down
3 changes: 1 addition & 2 deletions openmdao.lib/src/openmdao/lib/drivers/broydensolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def norm(a, ord=None):
# pylint: disable-msg=E0611,F0401
from openmdao.main.datatypes.api import Float, Int, Enum

from openmdao.main.api import Driver, CyclicWorkflow
from openmdao.main.driver import Driver
from openmdao.main.exceptions import RunStopped
from openmdao.main.hasparameters import HasParameters
from openmdao.main.hasconstraints import HasEqConstraints
Expand Down Expand Up @@ -78,7 +78,6 @@ class BroydenSolver(Driver):
def __init__(self):

super(BroydenSolver, self).__init__()
self.workflow = CyclicWorkflow()

self.xin = numpy.zeros(0, 'd')
self.F = numpy.zeros(0, 'd')
Expand Down
20 changes: 14 additions & 6 deletions openmdao.lib/src/openmdao/lib/drivers/iterate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
from numpy.linalg import norm

from openmdao.main.datatypes.api import Float, Int, Bool, Enum
from openmdao.main.api import Driver, CyclicWorkflow
from openmdao.main.driver import Driver
from openmdao.util.decorators import add_delegate
from openmdao.main.hasstopcond import HasStopConditions
from openmdao.main.hasparameters import HasParameters
from openmdao.main.hasconstraints import HasEqConstraints
from openmdao.main.interfaces import IHasParameters, IHasEqConstraints, \
ISolver, implements
from networkx.algorithms.components import strongly_connected_components

@add_delegate(HasParameters, HasEqConstraints, HasStopConditions)
class FixedPointIterator(Driver):
Expand All @@ -41,7 +42,6 @@ class FixedPointIterator(Driver):
def __init__(self):
super(FixedPointIterator, self).__init__()
self.current_iteration = 0
self.workflow = CyclicWorkflow()
self.normval = 1.e99
self.norm0 = 1.e99

Expand Down Expand Up @@ -75,8 +75,15 @@ def start_iteration(self):
def run_iteration(self):
self.current_iteration += 1
system = self.workflow._system
system.vec['u'].array += system.vec['f'].array[:]
system.run(self.workflow._iterbase())
uvec = system.vec['u']
fvec = system.vec['f']

cycle_vars = self.workflow._cycle_vars
for name in uvec.keys():
if name not in cycle_vars:
uvec[name] += fvec[name]

self.workflow.run(ffd_order=self.ffd_order)

def continue_iteration(self):
return not self.should_stop() and \
Expand Down Expand Up @@ -117,8 +124,9 @@ def check_config(self, strict=False):

# Check to make sure we don't have a null problem.
if n_dep == 0:
self.workflow._get_topsort()
if len(self.workflow._severed_edges) == 0:
cgraph = self.parent._depgraph.component_graph().subgraph([c.name for c in self.workflow])
strong = strongly_connected_components(cgraph)
if not ((strong and len(strong[0]) > 1) or self._get_param_constraint_pairs()):
msg = "FixedPointIterator requires a cyclic workflow, or a " \
"parameter/constraint pair."
self.raise_exception(msg, RuntimeError)
Expand Down
15 changes: 1 addition & 14 deletions openmdao.lib/src/openmdao/lib/drivers/newton_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def norm(a, order=None):
return npnorm(numpy.asarray_chkfinite(a), ord=order)

# pylint: disable=E0611, F0401
from openmdao.main.api import Driver, CyclicWorkflow
from openmdao.main.driver import Driver
from openmdao.main.datatypes.api import Float, Int
from openmdao.main.hasparameters import HasParameters
from openmdao.main.hasconstraints import HasEqConstraints
Expand Down Expand Up @@ -51,19 +51,6 @@ class NewtonSolver(Driver):
alpha = Float(1.0, iotype='in', low=0.0, high=1.0,
desc='Initial over-relaxation factor')

def __init__(self):

super(NewtonSolver, self).__init__()
self.workflow = CyclicWorkflow()

def check_config(self, strict=False):
""" This solver requires a CyclicWorkflow. """

super(NewtonSolver, self).check_config(strict=strict)

if not isinstance(self.workflow, CyclicWorkflow):
msg = "The NewtonSolver requires a CyclicWorkflow workflow."
self.raise_exception(msg, RuntimeError)

def execute(self):
""" General Newton's method. """
Expand Down
1 change: 0 additions & 1 deletion openmdao.main/src/openmdao/main/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from openmdao.main.workflow import Workflow
from openmdao.main.dataflow import Dataflow
from openmdao.main.sequentialflow import SequentialWorkflow
from openmdao.main.cyclicflow import CyclicWorkflow
from openmdao.main.variable import Variable

from openmdao.main.exceptions import ConstraintError
Expand Down
40 changes: 28 additions & 12 deletions openmdao.main/src/openmdao/main/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def __init__(self):
# constraints/objectives. This is the starting graph for
# all later transformations.
self._depgraph = DependencyGraph()
self._reduced_graph = nx.DiGraph()

for name, trait in self.class_traits().items():
if trait.iotype: # input or output
Expand Down Expand Up @@ -760,8 +761,9 @@ def _set_failed(self, path, value, index=None, force=False):

def execute(self):
"""Runs driver and updates our boundary variables."""
for system in self._system.local_subsystems():
system.pre_run()
# for system in self._system.local_subsystems():
# system.pre_run()
self._system.vec['u'].set_from_scope(self)
self._system.run(self.itername, ffd_order=self.ffd_order,
case_uuid=self._case_uuid)

Expand Down Expand Up @@ -1374,8 +1376,8 @@ def get_system(self):
@rbac(('owner', 'user'))
def setup_systems(self):
added = set()

rgraph = self._reduced_graph

# create systems for all simple components
for node, data in rgraph.nodes_iter(data=True):
if 'comp' in data:
Expand Down Expand Up @@ -1521,7 +1523,7 @@ def setup_graph(self, inputs=None, outputs=None):

self.name2collapsed = map_collapsed_nodes(collapsed_graph)

if calc_relevant: # add paramcomps for inputs and outvarcomps for outputs
if calc_relevant: # add ParamSystems for inputs and OutVarSystems for outputs
for param in inputs:
collapsed_graph.add_node(param, comp='param')
collapsed_graph.add_edge(param, self.name2collapsed[param])
Expand All @@ -1533,14 +1535,15 @@ def setup_graph(self, inputs=None, outputs=None):
# add InVarSystems and OutVarSystems for boundary vars
for node, data in collapsed_graph.nodes_iter(data=True):
if 'boundary' in data and collapsed_graph.degree(node) > 0:
if collapsed_graph.in_degree(node) == 0: # input boundary node
collapsed_graph.add_node(node[0], comp='invar')
collapsed_graph.add_edge(node[0], node)
elif collapsed_graph.out_degree(node) == 0: # output bndry node
collapsed_graph.add_node(node[1][0], comp='outvar')
collapsed_graph.add_edge(node, node[1][0])


if data.get('iotype') == 'in' and collapsed_graph.in_degree(node) == 0: # input boundary node
collapsed_graph.add_node(node[0].split('[',1)[0], comp='invar')
collapsed_graph.add_edge(node[0].split('[',1)[0], node)
elif data.get('iotype') == 'out' and collapsed_graph.out_degree(node) == 0: # output bndry node
collapsed_graph.add_node(node[1][0].split('[',1)[0], comp='outvar')
collapsed_graph.add_edge(node, node[1][0].split('[',1)[0])

#collapsed_graph = self._add_driver_subvar_conns(dgraph, collapsed_graph)

# translate kept nodes to collapsed form
coll_keep = set([self.name2collapsed.get(k,k) for k in keep])

Expand All @@ -1553,6 +1556,19 @@ def setup_graph(self, inputs=None, outputs=None):
for comp in self.get_comps():
comp.setup_graph()

def _add_driver_subvar_conns(self, depgraph, collapsed):
"""Connect any var nodes with subvar sources that don't have an upstream component
to their basevar's upstream component.
"""
for node, data in collapsed.nodes_iter(data=True):
if 'basevar' in data and collapsed.in_degree(node) == 0:
base = self.name2collapsed[data['basevar']]
if base in collapsed:
preds = collapsed.predecessors(base)
if preds:
collapsed.add_edge(preds[0], node)
return collapsed

def _explode_vartrees(self, depgraph):
"""Given a depgraph, take all connected variable nodes corresponding
to VariableTrees and replace them with a variable node for each
Expand Down
9 changes: 9 additions & 0 deletions openmdao.main/src/openmdao/main/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ def __setstate__(self, state):
if trait.iotype == 'in':
self._set_input_callback(name)

@rbac(('owner', 'user'))
def is_differentiable(self):
"""Return True if analytical derivatives can be
computed for this Component.
"""
if self.force_fd:
return False

return hasattr(self, 'provideJ')

@rbac(('owner', 'user'))
def get_req_default(self, self_required=None):
Expand Down
Loading

0 comments on commit c3cd270

Please sign in to comment.