{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SageMaker.Types.ParameterRanges
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.ParameterRanges where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.CategoricalParameterRange
import Amazonka.SageMaker.Types.ContinuousParameterRange
import Amazonka.SageMaker.Types.IntegerParameterRange

-- | Specifies ranges of integer, continuous, and categorical hyperparameters
-- that a hyperparameter tuning job searches. The hyperparameter tuning job
-- launches training jobs with hyperparameter values within these ranges to
-- find the combination of values that result in the training job with the
-- best performance as measured by the objective metric of the
-- hyperparameter tuning job.
--
-- You can specify a maximum of 20 hyperparameters that a hyperparameter
-- tuning job can search over. Every possible value of a categorical
-- parameter range counts against this limit.
--
-- /See:/ 'newParameterRanges' smart constructor.
data ParameterRanges = ParameterRanges'
  { -- | The array of CategoricalParameterRange objects that specify ranges of
    -- categorical hyperparameters that a hyperparameter tuning job searches.
    ParameterRanges -> Maybe [CategoricalParameterRange]
categoricalParameterRanges :: Prelude.Maybe [CategoricalParameterRange],
    -- | The array of IntegerParameterRange objects that specify ranges of
    -- integer hyperparameters that a hyperparameter tuning job searches.
    ParameterRanges -> Maybe [IntegerParameterRange]
integerParameterRanges :: Prelude.Maybe [IntegerParameterRange],
    -- | The array of ContinuousParameterRange objects that specify ranges of
    -- continuous hyperparameters that a hyperparameter tuning job searches.
    ParameterRanges -> Maybe [ContinuousParameterRange]
continuousParameterRanges :: Prelude.Maybe [ContinuousParameterRange]
  }
  deriving (ParameterRanges -> ParameterRanges -> Bool
(ParameterRanges -> ParameterRanges -> Bool)
-> (ParameterRanges -> ParameterRanges -> Bool)
-> Eq ParameterRanges
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterRanges -> ParameterRanges -> Bool
$c/= :: ParameterRanges -> ParameterRanges -> Bool
== :: ParameterRanges -> ParameterRanges -> Bool
$c== :: ParameterRanges -> ParameterRanges -> Bool
Prelude.Eq, ReadPrec [ParameterRanges]
ReadPrec ParameterRanges
Int -> ReadS ParameterRanges
ReadS [ParameterRanges]
(Int -> ReadS ParameterRanges)
-> ReadS [ParameterRanges]
-> ReadPrec ParameterRanges
-> ReadPrec [ParameterRanges]
-> Read ParameterRanges
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterRanges]
$creadListPrec :: ReadPrec [ParameterRanges]
readPrec :: ReadPrec ParameterRanges
$creadPrec :: ReadPrec ParameterRanges
readList :: ReadS [ParameterRanges]
$creadList :: ReadS [ParameterRanges]
readsPrec :: Int -> ReadS ParameterRanges
$creadsPrec :: Int -> ReadS ParameterRanges
Prelude.Read, Int -> ParameterRanges -> ShowS
[ParameterRanges] -> ShowS
ParameterRanges -> String
(Int -> ParameterRanges -> ShowS)
-> (ParameterRanges -> String)
-> ([ParameterRanges] -> ShowS)
-> Show ParameterRanges
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterRanges] -> ShowS
$cshowList :: [ParameterRanges] -> ShowS
show :: ParameterRanges -> String
$cshow :: ParameterRanges -> String
showsPrec :: Int -> ParameterRanges -> ShowS
$cshowsPrec :: Int -> ParameterRanges -> ShowS
Prelude.Show, (forall x. ParameterRanges -> Rep ParameterRanges x)
-> (forall x. Rep ParameterRanges x -> ParameterRanges)
-> Generic ParameterRanges
forall x. Rep ParameterRanges x -> ParameterRanges
forall x. ParameterRanges -> Rep ParameterRanges x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParameterRanges x -> ParameterRanges
$cfrom :: forall x. ParameterRanges -> Rep ParameterRanges x
Prelude.Generic)

-- |
-- Create a value of 'ParameterRanges' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'categoricalParameterRanges', 'parameterRanges_categoricalParameterRanges' - The array of CategoricalParameterRange objects that specify ranges of
-- categorical hyperparameters that a hyperparameter tuning job searches.
--
-- 'integerParameterRanges', 'parameterRanges_integerParameterRanges' - The array of IntegerParameterRange objects that specify ranges of
-- integer hyperparameters that a hyperparameter tuning job searches.
--
-- 'continuousParameterRanges', 'parameterRanges_continuousParameterRanges' - The array of ContinuousParameterRange objects that specify ranges of
-- continuous hyperparameters that a hyperparameter tuning job searches.
newParameterRanges ::
  ParameterRanges
newParameterRanges :: ParameterRanges
newParameterRanges =
  ParameterRanges' :: Maybe [CategoricalParameterRange]
-> Maybe [IntegerParameterRange]
-> Maybe [ContinuousParameterRange]
-> ParameterRanges
ParameterRanges'
    { $sel:categoricalParameterRanges:ParameterRanges' :: Maybe [CategoricalParameterRange]
categoricalParameterRanges =
        Maybe [CategoricalParameterRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:integerParameterRanges:ParameterRanges' :: Maybe [IntegerParameterRange]
integerParameterRanges = Maybe [IntegerParameterRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:continuousParameterRanges:ParameterRanges' :: Maybe [ContinuousParameterRange]
continuousParameterRanges = Maybe [ContinuousParameterRange]
forall a. Maybe a
Prelude.Nothing
    }

-- | The array of CategoricalParameterRange objects that specify ranges of
-- categorical hyperparameters that a hyperparameter tuning job searches.
parameterRanges_categoricalParameterRanges :: Lens.Lens' ParameterRanges (Prelude.Maybe [CategoricalParameterRange])
parameterRanges_categoricalParameterRanges :: (Maybe [CategoricalParameterRange]
 -> f (Maybe [CategoricalParameterRange]))
-> ParameterRanges -> f ParameterRanges
parameterRanges_categoricalParameterRanges = (ParameterRanges -> Maybe [CategoricalParameterRange])
-> (ParameterRanges
    -> Maybe [CategoricalParameterRange] -> ParameterRanges)
-> Lens
     ParameterRanges
     ParameterRanges
     (Maybe [CategoricalParameterRange])
     (Maybe [CategoricalParameterRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterRanges' {Maybe [CategoricalParameterRange]
categoricalParameterRanges :: Maybe [CategoricalParameterRange]
$sel:categoricalParameterRanges:ParameterRanges' :: ParameterRanges -> Maybe [CategoricalParameterRange]
categoricalParameterRanges} -> Maybe [CategoricalParameterRange]
categoricalParameterRanges) (\s :: ParameterRanges
s@ParameterRanges' {} Maybe [CategoricalParameterRange]
a -> ParameterRanges
s {$sel:categoricalParameterRanges:ParameterRanges' :: Maybe [CategoricalParameterRange]
categoricalParameterRanges = Maybe [CategoricalParameterRange]
a} :: ParameterRanges) ((Maybe [CategoricalParameterRange]
  -> f (Maybe [CategoricalParameterRange]))
 -> ParameterRanges -> f ParameterRanges)
-> ((Maybe [CategoricalParameterRange]
     -> f (Maybe [CategoricalParameterRange]))
    -> Maybe [CategoricalParameterRange]
    -> f (Maybe [CategoricalParameterRange]))
-> (Maybe [CategoricalParameterRange]
    -> f (Maybe [CategoricalParameterRange]))
-> ParameterRanges
-> f ParameterRanges
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CategoricalParameterRange]
  [CategoricalParameterRange]
  [CategoricalParameterRange]
  [CategoricalParameterRange]
-> Iso
     (Maybe [CategoricalParameterRange])
     (Maybe [CategoricalParameterRange])
     (Maybe [CategoricalParameterRange])
     (Maybe [CategoricalParameterRange])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [CategoricalParameterRange]
  [CategoricalParameterRange]
  [CategoricalParameterRange]
  [CategoricalParameterRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The array of IntegerParameterRange objects that specify ranges of
-- integer hyperparameters that a hyperparameter tuning job searches.
parameterRanges_integerParameterRanges :: Lens.Lens' ParameterRanges (Prelude.Maybe [IntegerParameterRange])
parameterRanges_integerParameterRanges :: (Maybe [IntegerParameterRange]
 -> f (Maybe [IntegerParameterRange]))
-> ParameterRanges -> f ParameterRanges
parameterRanges_integerParameterRanges = (ParameterRanges -> Maybe [IntegerParameterRange])
-> (ParameterRanges
    -> Maybe [IntegerParameterRange] -> ParameterRanges)
-> Lens
     ParameterRanges
     ParameterRanges
     (Maybe [IntegerParameterRange])
     (Maybe [IntegerParameterRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterRanges' {Maybe [IntegerParameterRange]
integerParameterRanges :: Maybe [IntegerParameterRange]
$sel:integerParameterRanges:ParameterRanges' :: ParameterRanges -> Maybe [IntegerParameterRange]
integerParameterRanges} -> Maybe [IntegerParameterRange]
integerParameterRanges) (\s :: ParameterRanges
s@ParameterRanges' {} Maybe [IntegerParameterRange]
a -> ParameterRanges
s {$sel:integerParameterRanges:ParameterRanges' :: Maybe [IntegerParameterRange]
integerParameterRanges = Maybe [IntegerParameterRange]
a} :: ParameterRanges) ((Maybe [IntegerParameterRange]
  -> f (Maybe [IntegerParameterRange]))
 -> ParameterRanges -> f ParameterRanges)
-> ((Maybe [IntegerParameterRange]
     -> f (Maybe [IntegerParameterRange]))
    -> Maybe [IntegerParameterRange]
    -> f (Maybe [IntegerParameterRange]))
-> (Maybe [IntegerParameterRange]
    -> f (Maybe [IntegerParameterRange]))
-> ParameterRanges
-> f ParameterRanges
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [IntegerParameterRange]
  [IntegerParameterRange]
  [IntegerParameterRange]
  [IntegerParameterRange]
-> Iso
     (Maybe [IntegerParameterRange])
     (Maybe [IntegerParameterRange])
     (Maybe [IntegerParameterRange])
     (Maybe [IntegerParameterRange])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [IntegerParameterRange]
  [IntegerParameterRange]
  [IntegerParameterRange]
  [IntegerParameterRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The array of ContinuousParameterRange objects that specify ranges of
-- continuous hyperparameters that a hyperparameter tuning job searches.
parameterRanges_continuousParameterRanges :: Lens.Lens' ParameterRanges (Prelude.Maybe [ContinuousParameterRange])
parameterRanges_continuousParameterRanges :: (Maybe [ContinuousParameterRange]
 -> f (Maybe [ContinuousParameterRange]))
-> ParameterRanges -> f ParameterRanges
parameterRanges_continuousParameterRanges = (ParameterRanges -> Maybe [ContinuousParameterRange])
-> (ParameterRanges
    -> Maybe [ContinuousParameterRange] -> ParameterRanges)
-> Lens
     ParameterRanges
     ParameterRanges
     (Maybe [ContinuousParameterRange])
     (Maybe [ContinuousParameterRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterRanges' {Maybe [ContinuousParameterRange]
continuousParameterRanges :: Maybe [ContinuousParameterRange]
$sel:continuousParameterRanges:ParameterRanges' :: ParameterRanges -> Maybe [ContinuousParameterRange]
continuousParameterRanges} -> Maybe [ContinuousParameterRange]
continuousParameterRanges) (\s :: ParameterRanges
s@ParameterRanges' {} Maybe [ContinuousParameterRange]
a -> ParameterRanges
s {$sel:continuousParameterRanges:ParameterRanges' :: Maybe [ContinuousParameterRange]
continuousParameterRanges = Maybe [ContinuousParameterRange]
a} :: ParameterRanges) ((Maybe [ContinuousParameterRange]
  -> f (Maybe [ContinuousParameterRange]))
 -> ParameterRanges -> f ParameterRanges)
-> ((Maybe [ContinuousParameterRange]
     -> f (Maybe [ContinuousParameterRange]))
    -> Maybe [ContinuousParameterRange]
    -> f (Maybe [ContinuousParameterRange]))
-> (Maybe [ContinuousParameterRange]
    -> f (Maybe [ContinuousParameterRange]))
-> ParameterRanges
-> f ParameterRanges
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ContinuousParameterRange]
  [ContinuousParameterRange]
  [ContinuousParameterRange]
  [ContinuousParameterRange]
-> Iso
     (Maybe [ContinuousParameterRange])
     (Maybe [ContinuousParameterRange])
     (Maybe [ContinuousParameterRange])
     (Maybe [ContinuousParameterRange])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ContinuousParameterRange]
  [ContinuousParameterRange]
  [ContinuousParameterRange]
  [ContinuousParameterRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ParameterRanges where
  parseJSON :: Value -> Parser ParameterRanges
parseJSON =
    String
-> (Object -> Parser ParameterRanges)
-> Value
-> Parser ParameterRanges
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ParameterRanges"
      ( \Object
x ->
          Maybe [CategoricalParameterRange]
-> Maybe [IntegerParameterRange]
-> Maybe [ContinuousParameterRange]
-> ParameterRanges
ParameterRanges'
            (Maybe [CategoricalParameterRange]
 -> Maybe [IntegerParameterRange]
 -> Maybe [ContinuousParameterRange]
 -> ParameterRanges)
-> Parser (Maybe [CategoricalParameterRange])
-> Parser
     (Maybe [IntegerParameterRange]
      -> Maybe [ContinuousParameterRange] -> ParameterRanges)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [CategoricalParameterRange]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CategoricalParameterRanges"
                            Parser (Maybe (Maybe [CategoricalParameterRange]))
-> Maybe [CategoricalParameterRange]
-> Parser (Maybe [CategoricalParameterRange])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CategoricalParameterRange]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [IntegerParameterRange]
   -> Maybe [ContinuousParameterRange] -> ParameterRanges)
-> Parser (Maybe [IntegerParameterRange])
-> Parser (Maybe [ContinuousParameterRange] -> ParameterRanges)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [IntegerParameterRange]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IntegerParameterRanges"
                            Parser (Maybe (Maybe [IntegerParameterRange]))
-> Maybe [IntegerParameterRange]
-> Parser (Maybe [IntegerParameterRange])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [IntegerParameterRange]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [ContinuousParameterRange] -> ParameterRanges)
-> Parser (Maybe [ContinuousParameterRange])
-> Parser ParameterRanges
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ContinuousParameterRange]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ContinuousParameterRanges"
                            Parser (Maybe (Maybe [ContinuousParameterRange]))
-> Maybe [ContinuousParameterRange]
-> Parser (Maybe [ContinuousParameterRange])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ContinuousParameterRange]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ParameterRanges

instance Prelude.NFData ParameterRanges

instance Core.ToJSON ParameterRanges where
  toJSON :: ParameterRanges -> Value
toJSON ParameterRanges' {Maybe [CategoricalParameterRange]
Maybe [ContinuousParameterRange]
Maybe [IntegerParameterRange]
continuousParameterRanges :: Maybe [ContinuousParameterRange]
integerParameterRanges :: Maybe [IntegerParameterRange]
categoricalParameterRanges :: Maybe [CategoricalParameterRange]
$sel:continuousParameterRanges:ParameterRanges' :: ParameterRanges -> Maybe [ContinuousParameterRange]
$sel:integerParameterRanges:ParameterRanges' :: ParameterRanges -> Maybe [IntegerParameterRange]
$sel:categoricalParameterRanges:ParameterRanges' :: ParameterRanges -> Maybe [CategoricalParameterRange]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CategoricalParameterRanges" Text -> [CategoricalParameterRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([CategoricalParameterRange] -> Pair)
-> Maybe [CategoricalParameterRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CategoricalParameterRange]
categoricalParameterRanges,
            (Text
"IntegerParameterRanges" Text -> [IntegerParameterRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([IntegerParameterRange] -> Pair)
-> Maybe [IntegerParameterRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [IntegerParameterRange]
integerParameterRanges,
            (Text
"ContinuousParameterRanges" Text -> [ContinuousParameterRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ContinuousParameterRange] -> Pair)
-> Maybe [ContinuousParameterRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ContinuousParameterRange]
continuousParameterRanges
          ]
      )