Skip to content

Commit

Permalink
improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
msakai committed Jun 25, 2024
1 parent 05243be commit b83c28a
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions numeric-optimization/src/Numeric/Optimization.hs
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,31 @@ instance Exception OptimizationException
--
-- Laws that should be satisfied:
--
-- * @'VS.length' . 'toVector' prob = 'dim' prob@
-- * @'VS.length' . 'toVector' proxy = 'dim' proxy@
--
-- * @'updateFromVector' prob a ('toVector' prob a) = a@
-- * @'updateFromVector' proxy a ('toVector' proxy a) = a@
--
-- * @'updateFromVector' prob ('updateFromVector' prob a v1) v2 = 'updateFromVector' prob a v2@
-- * @'updateFromVector' proxy ('updateFromVector' proxy a v1) v2 = 'updateFromVector' proxy a v2@
--
-- ==== Design note
--
-- Note that 'Domain'-manipulation functions ('dim', 'toVector',
-- 'writeToMVector', and 'updateFromVector') cannot be factored out to
-- a parent class like
--
-- @
-- class ToVector ('Domain' prob) => 'IsProblem' prob
-- @
--
-- because how values of the domain are converted to/from vectors
-- depends on the 'IsProblem' instance.
--
-- For example, @(1, 2) :: (Double, Double)@ is usually viewed as a
-- two-dimensional vector, while
-- [ad](https://hackage.haskell.org/package/ad) package uses
-- 'Traversable' instance of a functor @(a,)@ and considers
-- @(a, 2) :: (a, Double)@ as a one-dimensional vector (!), thus
-- ad-based problem definition need to use the latter view.
class IsProblem prob where
-- | Type of input values and gradients
--
Expand Down Expand Up @@ -412,6 +432,10 @@ class IsProblem prob where

-- | Bounds
--
-- The bounds are specified as a pair of the lower and upper bounds
-- of feasible region. For example, if the domain is 'VS.Vector' and
-- the feasible region is a unit cube, the bounds are
-- @Just ('VG.fromList' [0, 0, 0], 'VG.fromList' [1, 1 ,1])@.
bounds :: prob -> Maybe (Domain prob, Domain prob)
bounds _ = Nothing

Expand Down

0 comments on commit b83c28a

Please sign in to comment.