Skip to content

Commit

Permalink
Rewrite of domains class
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrey-hokanson committed Dec 10, 2018
1 parent fca63c6 commit 27187f3
Show file tree
Hide file tree
Showing 23 changed files with 1,298 additions and 595 deletions.
17 changes: 17 additions & 0 deletions docs/source/dim_reduction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
==================================
Subspace-based Dimension Reduction
==================================

Here our goal is to find a subspace along which our quantity of interest varies the most,
for various definitions of *most*.


Active Subspace
===============



Lipschitz Matrix
================


89 changes: 80 additions & 9 deletions docs/source/domain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,90 @@ Domain
======




Design Considerations
----------------------
The subclasses of :code:`Domain` all specify *convex* domains.
We restrict our attention to this class of domains
as we want all domains to have certain primative operations to be convex programs:
In order to use dimension reduction for practical algorithms,
we need be able to solve three problems:

========================= ==============================================================================================
Problem Mathematical statement
========================= ==============================================================================================
extent :math:`\displaystyle \max_{\alpha \ge 0} \alpha \text{ such that } \mathbf{x}_0+\alpha \mathbf{p}\in \mathcal{D}`
closest point :math:`\displaystyle \min_{\mathbf x \in \mathcal D} \| \mathbf L (\mathbf x - \mathbf y)\|_2`
furthest point (corner) :math:`\displaystyle \max_{\mathbf x \in \mathcal D} \mathbf p^\top \mathbf x`
constrained least squares :math:`\displaystyle \min_{\mathbf x \in \mathcal D} \| \mathbf A \mathbf x - \mathbf b \|_2`
========================= ==============================================================================================

With these three operations, we can, for example,
implement hit-and-run sampling.


- Closest point :math:`\min_{\mathbf x \in \mathcal D} \| \mathbf L (\mathbf x - \mathbf y)\|_2`
- Projected closest point :math:`\min_{\mathbf x \in \mathcal D} \| \mathbf A \mathbf x - \mathbf b \|_2`
- The furthest point in a direction, a *corner* :math:`\max_{\mathbf x \in \mathcal D} \mathbf p^\top \mathbf x`

With these three operations we can then perform many operations
Abstract Base Class
-------------------

All domains implement a similar interface that provides these operations.

.. autoclass:: psdr.Domain
:members:


Deterministic Domains
---------------------
Here we use deterministic domains to describe domains
whose main function is to specify a series of constraints.
These classes do have a :code:`sample` method,
but this sampling is simply random with uniform probability over the domain.
The classes below are in the nesting order;
i.e., a :code:`BoxDomain` is a subset of a :code:`LinIneqDomain`.
These distinctions are important as we can often use less expensive algorithms
for each of the subclasses.


.. autoclass:: psdr.LinQuadDomain

.. autoclass:: psdr.LinIneqDomain

.. autoclass:: psdr.ConvexHullDomain

.. autoclass:: psdr.BoxDomain

.. autoclass:: psdr.PointDomain




Random Domains
--------------
An alternative function of domains is to provide
samples from an associate sampling measure on some domain :math:`\mathcal{D}`.



.. autoclass:: psdr.UniformDomain

.. autoclass:: psdr.NormalDomain

.. autoclass:: psdr.LogNormalDomain


Tensor Product Domain
---------------------
As part of the operations on domains,
one goal is to compose a tensor product of sub-domains;
i.e., given :math:`\mathcal{D}_1` and :math:`\mathcal{D}_2`
to form:

.. math::
\mathcal{D} := \mathcal{D}_1 \otimes \mathcal{D}_2.
.. autoclass:: psdr.TensorProductDomain


Domain Operations
-----------------



28 changes: 28 additions & 0 deletions docs/source/function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Function Class
==============

The function class provides a wrapper around
a function :math:`f`
posed on some domain :math:`\mathcal{D} \subset \mathbb{R}^m`.


Design Considerations
---------------------

Often-times functions coming from engineering applications
come in *application units*, e.g., in meters, Pascals, etc.
The trouble is that these units are often poorly scaled with respect
to each other, causing numerical issues.
Hence, one of the first steps is to restate the problem on the *normalized domain*:
an affine transform of :math:`\mathcal{D}` into the unit box :math:`[-1,1]^m`.
One of the roles of the :code:`Function` class is to transparently handle
working in the normalized domain so that no changes are needed for the functions provided.



Function Class API
------------------

.. autoclass:: psdr.Function


8 changes: 7 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ Welcome to Parameter Space Dimension Reduction's documentation!
:caption: Contents:

domain

function
pools
samplers
dim_reduction
surrogate
opt
util

Indices and tables
==================
Expand Down
6 changes: 6 additions & 0 deletions docs/source/opt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Optimizers
==========




26 changes: 26 additions & 0 deletions docs/source/pools.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Computational Pools
===================


Design Philosophy
-----------------
There are a wide variety of approaches for working with parallelism
in this context.
For example,....

Here we take a simple perspective: all functions are black-boxes
so all we need to pass the coordinate to evaluate the function at
and (optionally) the number of derivatives to compute.



Abstract Base Class
-------------------

.. autoclass:: psdr.Pool
:members:





18 changes: 18 additions & 0 deletions docs/source/samplers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Samplers
========

Samplers are classes that provide an interface to *design of computer experiments* methods
for sampling a function's domain in some sense.

.. autoclass:: psdr.Sampler
:members:

Particular Sampling Strategies
------------------------------

.. autoclass:: psdr.RandomSampler

.. autoclass:: psdr.UniformSampler

.. autoclass:: psdr.RidgeSampler

11 changes: 11 additions & 0 deletions docs/source/surrogate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
=================
Response Surfaces
=================
Response surfaces are inexpensive surroagates for expensive computational models.


Polynomial Ridge Approximation
==============================

.. autoclass:: psdr.PolynomialRidgeApproximation

9 changes: 9 additions & 0 deletions docs/source/util.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=========
Utilities
=========


Linear Programs
===============

.. autofunction:: psdr.opt.linprog
3 changes: 2 additions & 1 deletion psdr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import util
import opt
from domains import *
from function import Function
from poly_ridge import *
from gp import *
from sample import *
from lipschitz import scalar_lipschitz, multivariate_lipschitz, check_lipschitz
from redis_pool import RedisJob, RedisPool, RedisWorker
from opt.shared import LinProgException, InfeasibleConstraints
from pool import SequentialJob, SequentialPool
from pool import Pool, SequentialJob, SequentialPool
from sample import maximin_sample
6 changes: 3 additions & 3 deletions psdr/demos/_multif_domains3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# https://stackoverflow.com/questions/6323860/sibling-package-imports
import sys, os
sys.path.insert(0, os.path.abspath('../../'))
from psdr import LinIneqDomain, UniformDomain, LogNormalDomain, ComboDomain
from psdr import LinIneqDomain, UniformDomain, LogNormalDomain, TensorProductDomain

def buildDesignDomain(output='verbose'):

Expand Down Expand Up @@ -245,7 +245,7 @@ def buildDesignDomain(output='verbose'):

# -------------------------------- FULL CONSTRAINTS --------------------------

design_domain = ComboDomain([inner_wall_domain, thermal_layer_domain,
design_domain = TensorProductDomain([inner_wall_domain, thermal_layer_domain,
air_gap_domain, load_layer_inner_domain,
load_layer_middle_domain,
load_layer_outer_domain, stringers_domain,
Expand Down Expand Up @@ -338,4 +338,4 @@ def buildRandomDomain(output='verbose', clip = None, normalization = 'linear'):
LogNormalDomain(2.5090, 0.2285, clip = clip, normalization = normalization),
]

return ComboDomain(random_domains)
return TensorProductDomain(random_domains)
2 changes: 1 addition & 1 deletion psdr/demos/borehole.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://stackoverflow.com/questions/6323860/sibling-package-imports
import sys, os
sys.path.insert(0, os.path.abspath('../../'))
from psdr import BoxDomain, NormalDomain, ComboDomain
from psdr import BoxDomain, NormalDomain


__all__ = ['build_borehole_domain', 'borehole']
Expand Down
4 changes: 2 additions & 2 deletions psdr/demos/golinski.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://stackoverflow.com/questions/6323860/sibling-package-imports
import sys, os
sys.path.insert(0, os.path.abspath('../../'))
from psdr import BoxDomain, NormalDomain, ComboDomain
from psdr import BoxDomain, NormalDomain, TensorProductDomain


__all__ = ['golinski_volume',
Expand Down Expand Up @@ -299,7 +299,7 @@ def build_golinski_design_domain():
return BoxDomain([2.6,0.7, 7.3, 7.3, 2.9, 5.0], [3.6, 0.8, 8.3, 8.3, 3.9, 5.5])
# Taken from table 3 of Hu, Zhou, Chen, Parks, 2017 in AIAA journal
def build_golinski_random_domain(clip = None):
return ComboDomain([NormalDomain(0,21e-4**2, clip = clip),
return TensorProductDomain([NormalDomain(0,21e-4**2, clip = clip),
NormalDomain(0, 1e-4**2, clip = clip),
NormalDomain(0, 30e-4**2, clip = clip),
NormalDomain(0, 30e-4**2, clip = clip),
Expand Down
6 changes: 3 additions & 3 deletions psdr/demos/oas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://stackoverflow.com/questions/6323860/sibling-package-imports
import sys, os
sys.path.insert(0, os.path.abspath('../../'))
from psdr import BoxDomain, ComboDomain, UniformDomain
from psdr import BoxDomain, TensorProductDomain, UniformDomain


def build_oas_design_domain(n_cp = 3):
Expand All @@ -17,7 +17,7 @@ def build_oas_design_domain(n_cp = 3):
# Taper ratio
domain_taper_ratio = BoxDomain(0.75, 1.25)

return ComboDomain([domain_twist, domain_thick, domain_root_chord, domain_taper_ratio])
return TensorProductDomain([domain_twist, domain_thick, domain_root_chord, domain_taper_ratio])

def build_oas_robust_domain():
# alpha - Angle of Attack
Expand All @@ -27,7 +27,7 @@ def build_oas_random_domain():
E = UniformDomain(0.8*70e9, 1.2*70e9)
G = UniformDomain(0.8*30e9, 1.2*30e9)
rho = UniformDomain(0.8*3e3, 1.2*3e3)
return ComboDomain([E,G,rho])
return TensorProductDomain([E,G,rho])


def oas(x, version = 'v1'):
Expand Down

0 comments on commit 27187f3

Please sign in to comment.