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

import qualified Amazonka.Core as Core
import Amazonka.Forecast.Types.ScalingType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies an integer hyperparameter and it\'s range of tunable values.
-- This object is part of the ParameterRanges object.
--
-- /See:/ 'newIntegerParameterRange' smart constructor.
data IntegerParameterRange = IntegerParameterRange'
  { -- | The scale that hyperparameter tuning uses to search the hyperparameter
    -- range. Valid values:
    --
    -- [Auto]
    --     Amazon Forecast 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 values greater
    --     than 0.
    --
    -- [ReverseLogarithmic]
    --     Not supported for @IntegerParameterRange@.
    --
    --     Reverse logarithmic scaling works only for ranges that are entirely
    --     within the range 0 \<= x \< 1.0.
    --
    -- For information about choosing a hyperparameter scale, see
    -- <http://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
    -- One of the following values:
    IntegerParameterRange -> Maybe ScalingType
scalingType :: Prelude.Maybe ScalingType,
    -- | The name of the hyperparameter to tune.
    IntegerParameterRange -> Text
name :: Prelude.Text,
    -- | The maximum tunable value of the hyperparameter.
    IntegerParameterRange -> Int
maxValue :: Prelude.Int,
    -- | The minimum tunable value of the hyperparameter.
    IntegerParameterRange -> Int
minValue :: Prelude.Int
  }
  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. Valid values:
--
-- [Auto]
--     Amazon Forecast 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 values greater
--     than 0.
--
-- [ReverseLogarithmic]
--     Not supported for @IntegerParameterRange@.
--
--     Reverse logarithmic scaling works only for ranges that are entirely
--     within the range 0 \<= x \< 1.0.
--
-- For information about choosing a hyperparameter scale, see
-- <http://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
-- One of the following values:
--
-- 'name', 'integerParameterRange_name' - The name of the hyperparameter to tune.
--
-- 'maxValue', 'integerParameterRange_maxValue' - The maximum tunable value of the hyperparameter.
--
-- 'minValue', 'integerParameterRange_minValue' - The minimum tunable value of the hyperparameter.
newIntegerParameterRange ::
  -- | 'name'
  Prelude.Text ->
  -- | 'maxValue'
  Prelude.Int ->
  -- | 'minValue'
  Prelude.Int ->
  IntegerParameterRange
newIntegerParameterRange :: Text -> Int -> Int -> IntegerParameterRange
newIntegerParameterRange Text
pName_ Int
pMaxValue_ Int
pMinValue_ =
  IntegerParameterRange' :: Maybe ScalingType -> Text -> Int -> Int -> IntegerParameterRange
IntegerParameterRange'
    { $sel:scalingType:IntegerParameterRange' :: Maybe ScalingType
scalingType =
        Maybe ScalingType
forall a. Maybe a
Prelude.Nothing,
      $sel:name:IntegerParameterRange' :: Text
name = Text
pName_,
      $sel:maxValue:IntegerParameterRange' :: Int
maxValue = Int
pMaxValue_,
      $sel:minValue:IntegerParameterRange' :: Int
minValue = Int
pMinValue_
    }

-- | The scale that hyperparameter tuning uses to search the hyperparameter
-- range. Valid values:
--
-- [Auto]
--     Amazon Forecast 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 values greater
--     than 0.
--
-- [ReverseLogarithmic]
--     Not supported for @IntegerParameterRange@.
--
--     Reverse logarithmic scaling works only for ranges that are entirely
--     within the range 0 \<= x \< 1.0.
--
-- For information about choosing a hyperparameter scale, see
-- <http://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type Hyperparameter Scaling>.
-- One of the following values:
integerParameterRange_scalingType :: Lens.Lens' IntegerParameterRange (Prelude.Maybe ScalingType)
integerParameterRange_scalingType :: (Maybe ScalingType -> f (Maybe ScalingType))
-> IntegerParameterRange -> f IntegerParameterRange
integerParameterRange_scalingType = (IntegerParameterRange -> Maybe ScalingType)
-> (IntegerParameterRange
    -> Maybe ScalingType -> IntegerParameterRange)
-> Lens
     IntegerParameterRange
     IntegerParameterRange
     (Maybe ScalingType)
     (Maybe ScalingType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterRange' {Maybe ScalingType
scalingType :: Maybe ScalingType
$sel:scalingType:IntegerParameterRange' :: IntegerParameterRange -> Maybe ScalingType
scalingType} -> Maybe ScalingType
scalingType) (\s :: IntegerParameterRange
s@IntegerParameterRange' {} Maybe ScalingType
a -> IntegerParameterRange
s {$sel:scalingType:IntegerParameterRange' :: Maybe ScalingType
scalingType = Maybe ScalingType
a} :: IntegerParameterRange)

-- | The name of the hyperparameter to tune.
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 maximum tunable value of the hyperparameter.
integerParameterRange_maxValue :: Lens.Lens' IntegerParameterRange Prelude.Int
integerParameterRange_maxValue :: (Int -> f Int) -> IntegerParameterRange -> f IntegerParameterRange
integerParameterRange_maxValue = (IntegerParameterRange -> Int)
-> (IntegerParameterRange -> Int -> IntegerParameterRange)
-> Lens IntegerParameterRange IntegerParameterRange Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterRange' {Int
maxValue :: Int
$sel:maxValue:IntegerParameterRange' :: IntegerParameterRange -> Int
maxValue} -> Int
maxValue) (\s :: IntegerParameterRange
s@IntegerParameterRange' {} Int
a -> IntegerParameterRange
s {$sel:maxValue:IntegerParameterRange' :: Int
maxValue = Int
a} :: IntegerParameterRange)

-- | The minimum tunable value of the hyperparameter.
integerParameterRange_minValue :: Lens.Lens' IntegerParameterRange Prelude.Int
integerParameterRange_minValue :: (Int -> f Int) -> IntegerParameterRange -> f IntegerParameterRange
integerParameterRange_minValue = (IntegerParameterRange -> Int)
-> (IntegerParameterRange -> Int -> IntegerParameterRange)
-> Lens IntegerParameterRange IntegerParameterRange Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntegerParameterRange' {Int
minValue :: Int
$sel:minValue:IntegerParameterRange' :: IntegerParameterRange -> Int
minValue} -> Int
minValue) (\s :: IntegerParameterRange
s@IntegerParameterRange' {} Int
a -> IntegerParameterRange
s {$sel:minValue:IntegerParameterRange' :: Int
minValue = Int
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 ScalingType -> Text -> Int -> Int -> IntegerParameterRange
IntegerParameterRange'
            (Maybe ScalingType -> Text -> Int -> Int -> IntegerParameterRange)
-> Parser (Maybe ScalingType)
-> Parser (Text -> Int -> Int -> IntegerParameterRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ScalingType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ScalingType")
            Parser (Text -> Int -> Int -> IntegerParameterRange)
-> Parser Text -> Parser (Int -> Int -> 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 (Int -> Int -> IntegerParameterRange)
-> Parser Int -> Parser (Int -> IntegerParameterRange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxValue")
            Parser (Int -> IntegerParameterRange)
-> Parser Int -> Parser IntegerParameterRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MinValue")
      )

instance Prelude.Hashable IntegerParameterRange

instance Prelude.NFData IntegerParameterRange

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