Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reasonable value improvements #2614

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/drasil-docLang/Drasil/DocDecl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ data SCSSub where
-- | Instance models.
IMs :: [Sentence] -> Fields -> DL.DerivationDisplay -> SCSSub
-- | Constraints.
Constraints :: (HasUncertainty c, Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) => Sentence -> [c] -> SCSSub
Constraints :: (HasUncertainty c, Quantity c, Constrained c, HasReasVal c, MayHaveReasVal c, MayHaveUnit c) => Sentence -> [c] -> SCSSub
-- | Properties of a correct solution.
CorrSolnPpties :: (Quantity c, Constrained c) => [c] -> [Contents] -> SCSSub

Expand Down
2 changes: 1 addition & 1 deletion code/drasil-docLang/Drasil/DocumentLanguage/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ data SCSSub where
-- | Instance Models.
IMs :: [Sentence] -> Fields -> [InstanceModel] -> DerivationDisplay -> SCSSub
-- | Constraints.
Constraints :: (HasUncertainty c, Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) => Sentence -> [c] -> SCSSub
Constraints :: (HasUncertainty c, Quantity c, Constrained c, HasReasVal c, MayHaveReasVal c, MayHaveUnit c) => Sentence -> [c] -> SCSSub
-- Sentence -> [LabelledContent] Fields -> [UncertainWrapper] -> [ConstrainedChunk] -> SCSSub --FIXME: temporary definition?
--FIXME: Work in Progress ^
-- | Properties of a correct solution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module Drasil.Sections.SpecificSystemDescription
import Language.Drasil hiding (variable)
import Utils.Drasil
import qualified Utils.Drasil.Sentence as S

import Data.Drasil.Concepts.Documentation (assumption, column, constraint, corSol,
datum, datumConstraint, inDatumConstraint, outDatumConstraint, definition, element, general, goalStmt, information,
input_, limitation, model, output_, physical, physicalConstraint, physicalSystem,
Expand Down Expand Up @@ -157,7 +156,7 @@ inModelIntro r1 r2 r3 r4 = foldlSP [S "This", phrase section_,
makeRef2S r4]

-- | Constructor for Data Constraints section. Takes a trailing 'Sentence' (use 'EmptyS' if none) and data constraints.
datConF :: (HasUncertainty c, Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) =>
datConF :: (HasUncertainty c, Quantity c, Constrained c, MayHaveReasVal c, MayHaveUnit c) =>
Sentence -> [c] -> Section
datConF _ [] = SRS.datCon [mkParagraph (S "There are no" +:+. plural datumConstraint)] []
datConF t c = SRS.datCon [dataConstraintParagraph t, LlC $ inDataConstTbl c] []
Expand Down Expand Up @@ -210,7 +209,7 @@ mkDataConstraintTable col ref lab = llcc (makeTabRef ref) $ uncurry Table
(mkTableFromColumns col) lab True

-- | Creates the input Data Constraints Table.
inDataConstTbl :: (HasUncertainty c, Quantity c, Constrained c, HasReasVal c, MayHaveUnit c) =>
inDataConstTbl :: (HasUncertainty c, Quantity c, Constrained c, MayHaveReasVal c, MayHaveUnit c) =>
[c] -> LabelledContent
inDataConstTbl qlst = mkDataConstraintTable [(S "Var", map ch $ sortBySymbol qlst),
(titleize' physicalConstraint, map fmtPhys $ sortBySymbol qlst),
Expand All @@ -219,7 +218,7 @@ inDataConstTbl qlst = mkDataConstraintTable [(S "Var", map ch $ sortBySymbol qls
(short typUnc, map typUncr $ sortBySymbol qlst)] (inDatumConstraint ^. uid) $
titleize' inDatumConstraint
where
getRVal c = fromMaybe (error $ "getRVal found no Expr for " ++ (c ^. uid)) (c ^. reasVal)
getRVal c = fromMaybe (error $ "getRVal found no Expr for " ++ (c ^. uid)) (maybeReasVal c)

-- | Creates the output Data Constraints Table.
outDataConstTbl :: (Quantity c, Constrained c) => [c] -> LabelledContent
Expand Down
33 changes: 15 additions & 18 deletions code/drasil-example/Drasil/GlassBR/Unitals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import Language.Drasil.Display (Symbol(..))
import Language.Drasil.ShortHands
import Utils.Drasil
import Utils.Drasil.Concepts

import Prelude hiding (log)

import Data.Drasil.Concepts.Math (xComp, yComp, zComp)
import Data.Drasil.Constraints (gtZeroConstr, probConstr)
import Data.Drasil.Quantities.Physics (subMax, subMin, subX, subY, subZ)
import Data.Drasil.SI_Units (kilogram, metre, millimetre, pascal, second)

import Drasil.GlassBR.Concepts (aR, annealed, fullyT, glaPlane, glassTypeFac,
heatS, iGlass, lGlass, lResistance, lShareFac, loadDurFactor, nFL, responseTy,
stdOffDist)
Expand All @@ -32,20 +29,20 @@ modElas = uc' "modElas" (nounPhraseSP "modulus of elasticity of glass")

{--}

constrained :: [ConstrainedChunk]
constrained :: [ConstrReasQDef]
constrained = map cnstrw inputDataConstraints ++
[cnstrw probBr, cnstrw probFail, cnstrw stressDistFac]

plateLen, plateWidth, aspectRatio, charWeight, standOffDist :: UncertQ
pbTol, tNT :: UncertainChunk
nomThick :: ConstrainedChunk
nomThick :: ConstrReasQDef
glassTypeCon :: ConstrConcept

{--}

inputs :: [QuantityDict]
inputs = map qw inputsWUnitsUncrtn ++ map qw inputsWUncrtn ++
map qw inputsNoUncrtn ++ map qw sdVector
inputsNoUncrtn ++ map qw sdVector

--inputs with units and uncertainties
inputsWUnitsUncrtn :: [UncertQ]
Expand All @@ -64,8 +61,8 @@ derivedInsWUncrtn :: [UncertQ]
derivedInsWUncrtn = [aspectRatio]

--inputs with no uncertainties
inputsNoUncrtn :: [ConstrainedChunk]
inputsNoUncrtn = [cnstrw glassTypeCon, nomThick]
inputsNoUncrtn ::[QuantityDict]
inputsNoUncrtn = [qw glassTypeCon, qw nomThick]

inputDataConstraints :: [UncertainChunk]
inputDataConstraints = map uncrtnw inputsWUnitsUncrtn ++
Expand Down Expand Up @@ -105,7 +102,7 @@ standOffDist = uq (constrained' (dqd sD (variable "SD") Real metre)
[ gtZeroConstr,
sfwrc $ Bounded (Inc, sy sdMin) (Inc, sy sdMax)] (exactDbl 45)) defaultUncrt

nomThick = cuc "nomThick"
nomThick = constrReasQD "nomThick"
(nounPhraseSent $ S "nominal thickness" +:+ displayDblConstrntsAsSet
nomThick nominalThicknesses)
lT millimetre {-Discrete nominalThicknesses, but not implemented-} Rational
Expand All @@ -122,21 +119,21 @@ outputs = map qw [isSafePb, isSafeLR] ++ map qw [probBr] ++ map qw [stressDistFa
tmSymbols :: [QuantityDict]
tmSymbols = map qw [probFail, pbTolfail] ++ map qw [isSafeProb, isSafeLoad]

probBr, probFail, pbTolfail, stressDistFac :: ConstrainedChunk
probBr = cvc "probBr" (nounPhraseSP "probability of breakage")
probBr, probFail, pbTolfail, stressDistFac :: ConstrReasQDef
probBr = constrReasQDNU "probBr" (nounPhraseSP "probability of breakage")
(sub cP lBreak) Rational
[probConstr] (Just $ dbl 0.4)
[probConstr] (dbl 0.4)

stressDistFac = cvc "stressDistFac" (nounPhraseSP "stress distribution factor (Function)")
cJ Real [physc $ Bounded (Inc, sy stressDistFacMin) (Inc, sy stressDistFacMax)] (Just $ exactDbl 15)
stressDistFac = constrReasQDNU "stressDistFac" (nounPhraseSP "stress distribution factor (Function)")
cJ Real [physc $ Bounded (Inc, sy stressDistFacMin) (Inc, sy stressDistFacMax)] (exactDbl 15)

probFail = cvc "probFail" (nounPhraseSP "probability of failure")
probFail = constrReasQDNU "probFail" (nounPhraseSP "probability of failure")
(sub cP lFail) Rational
[probConstr] (Just $ dbl 0.4)
[probConstr] (dbl 0.4)

pbTolfail = cvc "pbTolfail" (nounPhraseSP "tolerable probability of failure")
pbTolfail = constrReasQDNU "pbTolfail" (nounPhraseSP "tolerable probability of failure")
(sub cP (Concat [lFail, lTol])) Real
[probConstr] (Just $ dbl 0.008)
[probConstr] (dbl 0.008)


--FIXME: no typical value!
Expand Down
7 changes: 4 additions & 3 deletions code/drasil-lang/Language/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module Language.Drasil (
, HasUnitSymbol(usymb)
, HasReference(getReferences)
, HasReasVal(reasVal)
, MayHaveReasVal(maybeReasVal)
, HasDerivation(derivations)
, Idea(getA)
, Definition(defn)
Expand Down Expand Up @@ -70,9 +71,9 @@ module Language.Drasil (
, physc, sfwrc, enumc , isPhysC, isSfwrC
, Constraint(..), ConstraintReason(..)
-- Chunk.Constrained
, ConstrainedChunk(..), ConstrConcept(..)
, ConstrainedChunk(..), ConstrConcept(..), ReasonableValueQDef(..), ConstrainedQDef(..), ConstrReasQDef(..)
, cuc, cvc, constrained', cuc', cuc'', constrainedNRV'
, cnstrw, cnstrw'
, cnstrw, cnstrw', constrReasQD, constrReasQDNU
-- Chunk.Eq
, QDefinition, fromEqn, fromEqn', fromEqnSt, fromEqnSt', equat
, mkQDefSt, mkQuantDef, mkQuantDef', ec
Expand Down Expand Up @@ -225,7 +226,7 @@ import Language.Drasil.Classes.Core2 (HasShortName(shortname))
import Language.Drasil.Classes (NamedIdea(term), Idea(getA),
Definition(defn), ConceptDomain(cdom), Concept, HasUnitSymbol(usymb),
IsUnit(getUnits), CommonIdea(abrv), HasAdditionalNotes(getNotes), Constrained(constraints),
HasReasVal(reasVal), HasDerivation(derivations),
HasReasVal(reasVal), MayHaveReasVal(maybeReasVal), HasDerivation(derivations),
HasReference(getReferences), HasSpace(typ),
DefiningExpr(defnExpr), Quantity, HasUncertainty(unc), Callable,
IsArgumentName, Display(..))
Expand Down
Loading