{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Forecast.Types.ContinuousParameterRange where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Forecast.Types.ScalingType
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
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]
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
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.
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'
      { $sel:scalingType:ContinuousParameterRange' :: Maybe ScalingType
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 :: Lens' ContinuousParameterRange (Maybe ScalingType)
continuousParameterRange_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 :: Lens' ContinuousParameterRange Text
continuousParameterRange_name = 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 :: Lens' ContinuousParameterRange Double
continuousParameterRange_maxValue = 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 :: Lens' ContinuousParameterRange Double
continuousParameterRange_minValue = 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 Data.FromJSON ContinuousParameterRange where
  parseJSON :: Value -> Parser ContinuousParameterRange
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContinuousParameterRange"
      ( \Object
x ->
          Maybe ScalingType
-> Text -> Double -> Double -> ContinuousParameterRange
ContinuousParameterRange'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ScalingType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MaxValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MinValue")
      )

instance Prelude.Hashable ContinuousParameterRange where
  hashWithSalt :: Int -> ContinuousParameterRange -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScalingType
scalingType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
maxValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
minValue

instance Prelude.NFData ContinuousParameterRange where
  rnf :: ContinuousParameterRange -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ScalingType
scalingType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
maxValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
minValue

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ScalingType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ScalingType
scalingType,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"MaxValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
maxValue),
            forall a. a -> Maybe a
Prelude.Just (Key
"MinValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
minValue)
          ]
      )