Condor

https://github.com/nasa/simupy-flight/actions/workflows/docs.yml/badge.svg https://img.shields.io/badge/License-NOSA-green.svg https://img.shields.io/github/release/nasa/condor.svg

Condor is a new mathematical modeling framework for Python, developed at NASA’s Ames Research Center. Initial development began in April 2023 to address model implementation challenges for aircraft synthesis and robust orbital trajectory design. The goal is for Condor to help evaluate numerical models and then get out of the way.

One key aspect to achieve this goal was to create an API that looked as much like the mathematical description as possible with as little distraction from programming cruft as possible. To best understand this approach, we can consider a simple benchmark problem which consists of a set of coupled algebraic expressions. This can be represented as a system of algebraic equations:

import condor as co

class Coupling(co.AlgebraicSystem):
    x = parameter(shape=3)
    y1 = variable(initializer=1.)
    y2 = variable(initializer=1.)

    residual(y1 == x[0] ** 2 + x[1] + x[2] - 0.2 * y2)
    residual(y2 == y1**0.5 + x[0] + x[1])

This parametric model can be evaluated by providing the values for the parameters; the resulting object has values for its inputs and outputs bound, so the solved values for y1 and y2 can be accessed easily:

coupling = Coupling([5., 2., 1]) # evaluate the model numerically
print(coupling.y1, coupling.y2) # individual elements are bound numerically
print(coupling.variable) # fields are bound as a dataclass

Models can also be seamlessly built-up, with parent models accessing any input or output of models embedded within them. For example, we can optimize this system of algebraic equations by embedding it within an optimization problem:

from condor.backend import operators as ops

class Sellar(co.OptimizationProblem):
    x = variable(shape=3, lower_bound=0, upper_bound=10)
    coupling = Coupling(x)
    y1, y2 = coupling

    objective = x[2]**2 + x[1] + y1 + ops.exp(-y2)
    constraint(y1 >= 3.16)
    constraint(24. >= y2)

After the model is solved, the embedded model can be accessed directly:

Sellar.set_initial(x=[5,2,1])
sellar = Sellar()
print(sellar.objective) # scalar value
print(sellar.constraint) # field
print(sellar.coupling.y1) # sub-model element

NASA’s Condor is a framework for mathematical modeling of engineering systems in Python, written for engineers with deadlines.

Installation

Condor is available on PyPI, so you can install with pip:

pip install condor

Optionally, you can include the dependencies to run the examples:

pip install condor[examples]

Documentation

The documentation is organized as follows:

  • Tutorials have several small examples that show you the basics of translating a mathematical model into condor code, evaluating the model, and using it other scientific python tools. Start here if you’re new to condor.

  • Topic guides discuss key topics and concepts at a fairly high level and provide useful background information and explanation.

  • API docs contain technical reference for APIs and other aspects of Condor’s machinery. They describe how it works and how to use it but assume that you have a basic understanding of key concepts.

  • How-to guides are recipes. They guide you through the steps involved in addressing key problems and use-cases. They are more advanced than tutorials and assume some knowledge of how Condor works.

  • Examples provide demonstrations with fewer annotations, as a reference for users and test of functionality in CI.

Indices and tables