{-# 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.ContinuousParameterRange
-- 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.ContinuousParameterRange 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 a continuous hyperparameter and it\'s range of tunable values.
-- This object is part of the ParameterRanges object.
--
-- /See:/ 'newContinuousParameterRange' smart constructor.
data ContinuousParameterRange = ContinuousParameterRange'
  { -- | 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]
    --     hyperparameter tuning searches the values in the hyperparameter
    --     range by using a reverse logarithmic scale.
    --
    --     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:
    ContinuousParameterRange -> Maybe ScalingType
scalingType :: Prelude.Maybe ScalingType,
    -- | The name of the hyperparameter to tune.
    ContinuousParameterRange -> Text
name :: Prelude.Text,
    -- | The maximum tunable value of the hyperparameter.
    ContinuousParameterRange -> Double
maxValue :: Prelude.Double,
    -- | The minimum tunable value of the hyperparameter.
    ContinuousParameterRange -> Double
minValue :: Prelude.Double
  }
  deriving (ContinuousParameterRange -> ContinuousParameterRange -> Bool
(ContinuousParameterRange -> ContinuousParameterRange -> Bool)
-> (ContinuousParameterRange -> ContinuousParameterRange -> Bool)
-> Eq ContinuousParameterRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContinuousParameterRange -> ContinuousParameterRange -> Bool
$c/= :: ContinuousParameterRange -> ContinuousParameterRange -> Bool
== :: ContinuousParameterRange -> ContinuousParameterRange -> Bool
$c== :: ContinuousParameterRange -> ContinuousParameterRange -> Bool
Prelude.Eq, ReadPrec [ContinuousParameterRange]
ReadPrec ContinuousParameterRange
Int -> ReadS ContinuousParameterRange
ReadS [ContinuousParameterRange]
(Int -> ReadS ContinuousParameterRange)
-> ReadS [ContinuousParameterRange]
-> ReadPrec ContinuousParameterRange
-> ReadPrec [ContinuousParameterRange]
-> Read ContinuousParameterRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContinuousParameterRange]
$creadListPrec :: ReadPrec [ContinuousParameterRange]
readPrec :: ReadPrec ContinuousParameterRange
$creadPrec :: ReadPrec ContinuousParameterRange
readList :: ReadS [ContinuousParameterRange]
$creadList :: ReadS [ContinuousParameterRange]
readsPrec :: Int -> ReadS ContinuousParameterRange
$creadsPrec :: Int -> ReadS ContinuousParameterRange
Prelude.Read, Int -> ContinuousParameterRange -> ShowS
[ContinuousParameterRange] -> ShowS
ContinuousParameterRange -> String
(Int -> ContinuousParameterRange -> ShowS)
-> (ContinuousParameterRange -> String)
-> ([ContinuousParameterRange] -> ShowS)
-> Show ContinuousParameterRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContinuousParameterRange] -> ShowS
$cshowList :: [ContinuousParameterRange] -> ShowS
show :: ContinuousParameterRange -> String
$cshow :: ContinuousParameterRange -> String
showsPrec :: Int -> ContinuousParameterRange -> ShowS
$cshowsPrec :: Int -> ContinuousParameterRange -> ShowS
Prelude.Show, (forall x.
 ContinuousParameterRange -> Rep ContinuousParameterRange x)
-> (forall x.
    Rep ContinuousParameterRange x -> ContinuousParameterRange)
-> Generic ContinuousParameterRange
forall x.
Rep ContinuousParameterRange x -> ContinuousParameterRange
forall x.
ContinuousParameterRange -> Rep ContinuousParameterRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContinuousParameterRange x -> ContinuousParameterRange
$cfrom :: forall x.
ContinuousParameterRange -> Rep ContinuousParameterRange x
Prelude.Generic)

-- |
-- Create a value of 'ContinuousParameterRange' 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', 'continuousParameterRange_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]
--     hyperparameter tuning searches the values in the hyperparameter
--     range by using a reverse logarithmic scale.
--
--     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', 'continuousParameterRange_name' - The name of the hyperparameter to tune.
--
-- 'maxValue', 'continuousParameterRange_maxValue' - The maximum tunable value of the hyperparameter.
--
-- 'minValue', 'continuousParameterRange_minValue' - The minimum tunable value of the hyperparameter.
newContinuousParameterRange ::
  -- | 'name'
  Prelude.Text ->
  -- | 'maxValue'
  Prelude.Double ->
  -- | 'minValue'
  Prelude.Double ->
  ContinuousParameterRange
newContinuousParameterRange :: Text -> Double -> Double -> ContinuousParameterRange
newContinuousParameterRange
  Text
pName_
  Double
pMaxValue_
  Double
pMinValue_ =
    ContinuousParameterRange' :: Maybe ScalingType
-> Text -> Double -> Double -> ContinuousParameterRange
ContinuousParameterRange'
      { $sel:scalingType:ContinuousParameterRange' :: Maybe ScalingType
scalingType =
          Maybe ScalingType
forall a. Maybe a
Prelude.Nothing,
        $sel:name:ContinuousParameterRange' :: Text
name = Text
pName_,
        $sel:maxValue:ContinuousParameterRange' :: Double
maxValue = Double
pMaxValue_,
        $sel:minValue:ContinuousParameterRange' :: Double
minValue = Double
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]
--     hyperparameter tuning searches the values in the hyperparameter
--     range by using a reverse logarithmic scale.
--
--     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:
continuousParameterRange_scalingType :: Lens.Lens' ContinuousParameterRange (Prelude.Maybe ScalingType)
continuousParameterRange_scalingType :: (Maybe ScalingType -> f (Maybe ScalingType))
-> ContinuousParameterRange -> f ContinuousParameterRange
continuousParameterRange_scalingType = (ContinuousParameterRange -> Maybe ScalingType)
-> (ContinuousParameterRange
    -> Maybe ScalingType -> ContinuousParameterRange)
-> Lens
     ContinuousParameterRange
     ContinuousParameterRange
     (Maybe ScalingType)
     (Maybe ScalingType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousParameterRange' {Maybe ScalingType
scalingType :: Maybe ScalingType
$sel:scalingType:ContinuousParameterRange' :: ContinuousParameterRange -> Maybe ScalingType
scalingType} -> Maybe ScalingType
scalingType) (\s :: ContinuousParameterRange
s@ContinuousParameterRange' {} Maybe ScalingType
a -> ContinuousParameterRange
s {$sel:scalingType:ContinuousParameterRange' :: Maybe ScalingType
scalingType = Maybe ScalingType
a} :: ContinuousParameterRange)

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

-- | The maximum tunable value of the hyperparameter.
continuousParameterRange_maxValue :: Lens.Lens' ContinuousParameterRange Prelude.Double
continuousParameterRange_maxValue :: (Double -> f Double)
-> ContinuousParameterRange -> f ContinuousParameterRange
continuousParameterRange_maxValue = (ContinuousParameterRange -> Double)
-> (ContinuousParameterRange -> Double -> ContinuousParameterRange)
-> Lens
     ContinuousParameterRange ContinuousParameterRange Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousParameterRange' {Double
maxValue :: Double
$sel:maxValue:ContinuousParameterRange' :: ContinuousParameterRange -> Double
maxValue} -> Double
maxValue) (\s :: ContinuousParameterRange
s@ContinuousParameterRange' {} Double
a -> ContinuousParameterRange
s {$sel:maxValue:ContinuousParameterRange' :: Double
maxValue = Double
a} :: ContinuousParameterRange)

-- | The minimum tunable value of the hyperparameter.
continuousParameterRange_minValue :: Lens.Lens' ContinuousParameterRange Prelude.Double
continuousParameterRange_minValue :: (Double -> f Double)
-> ContinuousParameterRange -> f ContinuousParameterRange
continuousParameterRange_minValue = (ContinuousParameterRange -> Double)
-> (ContinuousParameterRange -> Double -> ContinuousParameterRange)
-> Lens
     ContinuousParameterRange ContinuousParameterRange Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousParameterRange' {Double
minValue :: Double
$sel:minValue:ContinuousParameterRange' :: ContinuousParameterRange -> Double
minValue} -> Double
minValue) (\s :: ContinuousParameterRange
s@ContinuousParameterRange' {} Double
a -> ContinuousParameterRange
s {$sel:minValue:ContinuousParameterRange' :: Double
minValue = Double
a} :: ContinuousParameterRange)

instance Core.FromJSON ContinuousParameterRange where
  parseJSON :: Value -> Parser ContinuousParameterRange
parseJSON =
    String
-> (Object -> Parser ContinuousParameterRange)
-> Value
-> Parser ContinuousParameterRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContinuousParameterRange"
      ( \Object
x ->
          Maybe ScalingType
-> Text -> Double -> Double -> ContinuousParameterRange
ContinuousParameterRange'
            (Maybe ScalingType
 -> Text -> Double -> Double -> ContinuousParameterRange)
-> Parser (Maybe ScalingType)
-> Parser (Text -> Double -> Double -> ContinuousParameterRange)
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 -> Double -> Double -> ContinuousParameterRange)
-> Parser Text
-> Parser (Double -> Double -> ContinuousParameterRange)
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 (Double -> Double -> ContinuousParameterRange)
-> Parser Double -> Parser (Double -> ContinuousParameterRange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxValue")
            Parser (Double -> ContinuousParameterRange)
-> Parser Double -> Parser ContinuousParameterRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MinValue")
      )

instance Prelude.Hashable ContinuousParameterRange

instance Prelude.NFData ContinuousParameterRange

instance Core.ToJSON ContinuousParameterRange where
  toJSON :: ContinuousParameterRange -> Value
toJSON ContinuousParameterRange' {Double
Maybe ScalingType
Text
minValue :: Double
maxValue :: Double
name :: Text
scalingType :: Maybe ScalingType
$sel:minValue:ContinuousParameterRange' :: ContinuousParameterRange -> Double
$sel:maxValue:ContinuousParameterRange' :: ContinuousParameterRange -> Double
$sel:name:ContinuousParameterRange' :: ContinuousParameterRange -> Text
$sel:scalingType:ContinuousParameterRange' :: ContinuousParameterRange -> 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 -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
maxValue),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MinValue" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
minValue)
          ]
      )