{-# 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.IntegerParameterRange
-- 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.IntegerParameterRange where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.HyperParameterScalingType

-- | For a hyperparameter of the integer type, specifies the range that a
-- hyperparameter tuning job searches.
--
-- /See:/ 'newIntegerParameterRange' smart constructor.
data IntegerParameterRange = IntegerParameterRange'
  { -- | The scale that hyperparameter tuning uses to search the hyperparameter
    -- range. For information about choosing a hyperparameter scale, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
    -- One of the following values:
    --
    -- [Auto]
    --     Amazon SageMaker hyperparameter tuning chooses the best scale for
    --     the hyperparameter.
    --
    -- [Linear]
    --     Hyperparameter tuning searches the values in the hyperparameter
    --     range by using a linear scale.
    --
    -- [Logarithmic]
    --     Hyperparameter tuning searches the values in the hyperparameter
    --     range by using a logarithmic scale.
    --
    --     Logarithmic scaling works only for ranges that have only values
    --     greater than 0.
    IntegerParameterRange -> Maybe HyperParameterScalingType
scalingType :: Prelude.Maybe HyperParameterScalingType,
    -- | The name of the hyperparameter to search.
    IntegerParameterRange -> Text
name :: Prelude.Text,
    -- | The minimum value of the hyperparameter to search.
    IntegerParameterRange -> Text
minValue :: Prelude.Text,
    -- | The maximum value of the hyperparameter to search.
    IntegerParameterRange -> Text
maxValue :: Prelude.Text
  }
  deriving (IntegerParameterRange -> IntegerParameterRange -> Bool
(IntegerParameterRange -> IntegerParameterRange -> Bool)
-> (IntegerParameterRange -> IntegerParameterRange -> Bool)
-> Eq IntegerParameterRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntegerParameterRange -> IntegerParameterRange -> Bool
$c/= :: IntegerParameterRange -> IntegerParameterRange -> Bool
== :: IntegerParameterRange -> IntegerParameterRange -> Bool
$c== :: IntegerParameterRange -> IntegerParameterRange -> Bool
Prelude.Eq, ReadPrec [IntegerParameterRange]
ReadPrec IntegerParameterRange
Int -> ReadS IntegerParameterRange
ReadS [IntegerParameterRange]
(Int -> ReadS IntegerParameterRange)
-> ReadS [IntegerParameterRange]
-> ReadPrec IntegerParameterRange
-> ReadPrec [IntegerParameterRange]
-> Read IntegerParameterRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IntegerParameterRange]
$creadListPrec :: ReadPrec [IntegerParameterRange]
readPrec :: ReadPrec IntegerParameterRange
$creadPrec :: ReadPrec IntegerParameterRange
readList :: ReadS [IntegerParameterRange]
$creadList :: ReadS [IntegerParameterRange]
readsPrec :: Int -> ReadS IntegerParameterRange
$creadsPrec :: Int -> ReadS IntegerParameterRange
Prelude.Read, Int -> IntegerParameterRange -> ShowS
[IntegerParameterRange] -> ShowS
IntegerParameterRange -> String
(Int -> IntegerParameterRange -> ShowS)
-> (IntegerParameterRange -> String)
-> ([IntegerParameterRange] -> ShowS)
-> Show IntegerParameterRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntegerParameterRange] -> ShowS
$cshowList :: [IntegerParameterRange] -> ShowS
show :: IntegerParameterRange -> String
$cshow :: IntegerParameterRange -> String
showsPrec :: Int -> IntegerParameterRange -> ShowS
$cshowsPrec :: Int -> IntegerParameterRange -> ShowS
Prelude.Show, (forall x. IntegerParameterRange -> Rep IntegerParameterRange x)
-> (forall x. Rep IntegerParameterRange x -> IntegerParameterRange)
-> Generic IntegerParameterRange
forall x. Rep IntegerParameterRange x -> IntegerParameterRange
forall x. IntegerParameterRange -> Rep IntegerParameterRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IntegerParameterRange x -> IntegerParameterRange
$cfrom :: forall x. IntegerParameterRange -> Rep IntegerParameterRange x
Prelude.Generic)

-- |
-- Create a value of 'IntegerParameterRange' 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:
--
-- 'scalingType', 'integerParameterRange_scalingType' - The scale that hyperparameter tuning uses to search the hyperparameter
-- range. For information about choosing a hyperparameter scale, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
-- One of the following values:
--
-- [Auto]
--     Amazon SageMaker hyperparameter tuning chooses the best scale for
--     the hyperparameter.
--
-- [Linear]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a linear scale.
--
-- [Logarithmic]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a logarithmic scale.
--
--     Logarithmic scaling works only for ranges that have only values
--     greater than 0.
--
-- 'name', 'integerParameterRange_name' - The name of the hyperparameter to search.
--
-- 'minValue', 'integerParameterRange_minValue' - The minimum value of the hyperparameter to search.
--
-- 'maxValue', 'integerParameterRange_maxValue' - The maximum value of the hyperparameter to search.
newIntegerParameterRange ::
  -- | 'name'
  Prelude.Text ->
  -- | 'minValue'
  Prelude.Text ->
  -- | 'maxValue'
  Prelude.Text ->
  IntegerParameterRange
newIntegerParameterRange :: Text -> Text -> Text -> IntegerParameterRange
newIntegerParameterRange Text
pName_ Text
pMinValue_ Text
pMaxValue_ =
  IntegerParameterRange' :: Maybe HyperParameterScalingType
-> Text -> Text -> Text -> IntegerParameterRange
IntegerParameterRange'
    { $sel:scalingType:IntegerParameterRange' :: Maybe HyperParameterScalingType
scalingType =
        Maybe HyperParameterScalingType
forall a. Maybe a
Prelude.Nothing,
      $sel:name:IntegerParameterRange' :: Text
name = Text
pName_,
      $sel:minValue:IntegerParameterRange' :: Text
minValue = Text
pMinValue_,
      $sel:maxValue:IntegerParameterRange' :: Text
maxValue = Text
pMaxValue_
    }

-- | The scale that hyperparameter tuning uses to search the hyperparameter
-- range. For information about choosing a hyperparameter scale, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
-- One of the following values:
--
-- [Auto]
--     Amazon SageMaker hyperparameter tuning chooses the best scale for
--     the hyperparameter.
--
-- [Linear]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a linear scale.
--
-- [Logarithmic]
--     Hyperparameter tuning searches the values in the hyperparameter
--     range by using a logarithmic scale.
--
--     Logarithmic scaling works only for ranges that have only values
--     greater than 0.
integerParameterRange_scalingType :: Lens.Lens' IntegerParameterRange (Prelude.Maybe HyperParameterScalingType)
integerParameterRange_scalingType :: (Maybe HyperParameterScalingType
 -> f (Maybe HyperParameterScalingType))
-> IntegerParameterRange -> f IntegerParameterRange
integerParameterRange_scalingType = (IntegerParameterRange -> Maybe HyperParameterScalingType)
-> (IntegerParameterRange
    -> Maybe HyperParameterScalingType -> IntegerParameterRange)
-> Lens
     IntegerParameterRange
     IntegerParameterRange
     (Maybe HyperParameterScalingType)
     (Maybe HyperParameterScalingType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterRange' {Maybe HyperParameterScalingType
scalingType :: Maybe HyperParameterScalingType
$sel:scalingType:IntegerParameterRange' :: IntegerParameterRange -> Maybe HyperParameterScalingType
scalingType} -> Maybe HyperParameterScalingType
scalingType) (\s :: IntegerParameterRange
s@IntegerParameterRange' {} Maybe HyperParameterScalingType
a -> IntegerParameterRange
s {$sel:scalingType:IntegerParameterRange' :: Maybe HyperParameterScalingType
scalingType = Maybe HyperParameterScalingType
a} :: IntegerParameterRange)

-- | The name of the hyperparameter to search.
integerParameterRange_name :: Lens.Lens' IntegerParameterRange Prelude.Text
integerParameterRange_name :: (Text -> f Text)
-> IntegerParameterRange -> f IntegerParameterRange
integerParameterRange_name = (IntegerParameterRange -> Text)
-> (IntegerParameterRange -> Text -> IntegerParameterRange)
-> Lens IntegerParameterRange IntegerParameterRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterRange' {Text
name :: Text
$sel:name:IntegerParameterRange' :: IntegerParameterRange -> Text
name} -> Text
name) (\s :: IntegerParameterRange
s@IntegerParameterRange' {} Text
a -> IntegerParameterRange
s {$sel:name:IntegerParameterRange' :: Text
name = Text
a} :: IntegerParameterRange)

-- | The minimum value of the hyperparameter to search.
integerParameterRange_minValue :: Lens.Lens' IntegerParameterRange Prelude.Text
integerParameterRange_minValue :: (Text -> f Text)
-> IntegerParameterRange -> f IntegerParameterRange
integerParameterRange_minValue = (IntegerParameterRange -> Text)
-> (IntegerParameterRange -> Text -> IntegerParameterRange)
-> Lens IntegerParameterRange IntegerParameterRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterRange' {Text
minValue :: Text
$sel:minValue:IntegerParameterRange' :: IntegerParameterRange -> Text
minValue} -> Text
minValue) (\s :: IntegerParameterRange
s@IntegerParameterRange' {} Text
a -> IntegerParameterRange
s {$sel:minValue:IntegerParameterRange' :: Text
minValue = Text
a} :: IntegerParameterRange)

-- | The maximum value of the hyperparameter to search.
integerParameterRange_maxValue :: Lens.Lens' IntegerParameterRange Prelude.Text
integerParameterRange_maxValue :: (Text -> f Text)
-> IntegerParameterRange -> f IntegerParameterRange
integerParameterRange_maxValue = (IntegerParameterRange -> Text)
-> (IntegerParameterRange -> Text -> IntegerParameterRange)
-> Lens IntegerParameterRange IntegerParameterRange Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterRange' {Text
maxValue :: Text
$sel:maxValue:IntegerParameterRange' :: IntegerParameterRange -> Text
maxValue} -> Text
maxValue) (\s :: IntegerParameterRange
s@IntegerParameterRange' {} Text
a -> IntegerParameterRange
s {$sel:maxValue:IntegerParameterRange' :: Text
maxValue = Text
a} :: IntegerParameterRange)

instance Core.FromJSON IntegerParameterRange where
  parseJSON :: Value -> Parser IntegerParameterRange
parseJSON =
    String
-> (Object -> Parser IntegerParameterRange)
-> Value
-> Parser IntegerParameterRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IntegerParameterRange"
      ( \Object
x ->
          Maybe HyperParameterScalingType
-> Text -> Text -> Text -> IntegerParameterRange
IntegerParameterRange'
            (Maybe HyperParameterScalingType
 -> Text -> Text -> Text -> IntegerParameterRange)
-> Parser (Maybe HyperParameterScalingType)
-> Parser (Text -> Text -> Text -> IntegerParameterRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe HyperParameterScalingType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ScalingType")
            Parser (Text -> Text -> Text -> IntegerParameterRange)
-> Parser Text -> Parser (Text -> Text -> IntegerParameterRange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser (Text -> Text -> IntegerParameterRange)
-> Parser Text -> Parser (Text -> IntegerParameterRange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MinValue")
            Parser (Text -> IntegerParameterRange)
-> Parser Text -> Parser IntegerParameterRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxValue")
      )

instance Prelude.Hashable IntegerParameterRange

instance Prelude.NFData IntegerParameterRange

instance Core.ToJSON IntegerParameterRange where
  toJSON :: IntegerParameterRange -> Value
toJSON IntegerParameterRange' {Maybe HyperParameterScalingType
Text
maxValue :: Text
minValue :: Text
name :: Text
scalingType :: Maybe HyperParameterScalingType
$sel:maxValue:IntegerParameterRange' :: IntegerParameterRange -> Text
$sel:minValue:IntegerParameterRange' :: IntegerParameterRange -> Text
$sel:name:IntegerParameterRange' :: IntegerParameterRange -> Text
$sel:scalingType:IntegerParameterRange' :: IntegerParameterRange -> Maybe HyperParameterScalingType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ScalingType" Text -> HyperParameterScalingType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HyperParameterScalingType -> Pair)
-> Maybe HyperParameterScalingType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HyperParameterScalingType
scalingType,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MinValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
minValue),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MaxValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
maxValue)
          ]
      )