Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
af3
AF3
Commits
32c4805c
Commit
32c4805c
authored
Nov 24, 2022
by
Simon Barner
Browse files
Revert "Ensure decomposed ASILs are integer"
This reverts commit
111a591a
.
parent
111a591a
Changes
3
Hide whitespace changes
Inline
Side-by-side
org.fortiss.af3.exploration.smt/src/org/fortiss/af3/exploration/smt/modeltransformation/.ratings
View file @
32c4805c
...
...
@@ -3,7 +3,7 @@ BasicDeploymentConstraint.java 8ce74d977b6d3c38ad3f374598d328b26c0107dc RED
BasicScheduleConstraint.java 283ff31c28bb5a566b91886361a5b4a7b0e9dc5d GREEN
ConstraintTransformationAdapter.java 8806164d71491c7d1af665990dd154f2275cad8c GREEN
DSMLTransformationService.java cca088c06222e01d84c54eea31b55f8c62171b41 GREEN
DSMLtoSMTTransformator.java c
06ed6637cd538cbf9198656306327897546eb4b RED
DSMLtoSMTTransformator.java c
135bb98ad8c4a0fa617920fcc16f3974a3781cd YELLOW
DefaultExpressionTransformator.java e6770ca556bf6deeb7a286223cdbdd919362fbe4 GREEN
EnergyConstraintDefinition.java f394e4195ed678ae294b48dbe3c39c783f9c927d GREEN
ExpressionTransformator.java a380d7ffb5ce76c4c0fac10944cc13802a057b7a GREEN
...
...
@@ -12,4 +12,3 @@ MemoryUtilizationObjective.java cc8bba805c6e69906e808822b1e0833a392a826f RED
NonQuantifiedExpressionTransformator.java 9ee437aeaf518d94b81e34a275cd01b87cfca1bf GREEN
QuantifiedExpressionTransformator.java 01e7162b24d16adb23f646cf02340879e8a18205 GREEN
TaskCouplingObjective.java 49a9135426cd1ef817ba51c4c507f2279410419e YELLOW
TaskReferenceVisitor.java 60ee2c7d0d82026b256c389721b8c1f6cd4299dc RED
org.fortiss.af3.exploration.smt/src/org/fortiss/af3/exploration/smt/modeltransformation/DSMLtoSMTTransformator.java
View file @
32c4805c
...
...
@@ -43,8 +43,6 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import
static
org
.
fortiss
.
tooling
.
kernel
.
utils
.
LoggingUtils
.
error
;
import
static
org
.
fortiss
.
tooling
.
kernel
.
utils
.
LoggingUtils
.
warning
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
...
...
@@ -68,7 +66,6 @@ import org.fortiss.af3.exploration.dseml.model.function.AllocationTypeEnum;
import
org.fortiss.af3.exploration.dseml.model.function.Deploy
;
import
org.fortiss.af3.exploration.dseml.model.function.Maximize
;
import
org.fortiss.af3.exploration.dseml.model.function.Minimize
;
import
org.fortiss.af3.exploration.lang.IExplorationExpressionVisitor
;
import
org.fortiss.af3.exploration.model.ExplorationSpecification
;
import
org.fortiss.af3.exploration.model.IExplorationConstraint
;
import
org.fortiss.af3.exploration.model.IExplorationObjective
;
...
...
@@ -498,13 +495,6 @@ public class DSMLtoSMTTransformator {
FuncDecl
silFunc
=
getSafetyIntegrityLevelDecl
(
model
);
Map
<
IExplorationTarget
<?>,
BigDecimal
>
remainderMap
=
new
HashMap
<>();
for
(
IExplorationTarget
<?>
expr
:
transformedExpressions
.
keySet
())
{
if
(
expr
.
getName
().
contains
(
"asil decomposition"
))
{
remainderMap
.
put
(
expr
,
BigDecimal
.
ZERO
);
}
}
// Go through all allocation sources and find the calculated allocation destinations
for
(
EnumSort
enumSort
:
transformationService
.
getLeftSidesOfAllocations
())
{
FuncDecl
functionForLeftSideType
=
...
...
@@ -527,42 +517,9 @@ public class DSMLtoSMTTransformator {
if
(
silFunc
!=
null
)
{
Expr
silExpr
=
silFunc
.
apply
(
enumExpr
);
RatNum
silRat
=
(
RatNum
)
model
.
eval
(
silExpr
,
true
);
BigDecimal
sil
=
toDecimal
(
silRat
);
if
(
sil
.
compareTo
(
BigDecimal
.
ZERO
)
>=
0
)
{
BigDecimal
rounded
=
sil
.
setScale
(
0
,
RoundingMode
.
FLOOR
);
BigDecimal
frac
=
sil
.
subtract
(
rounded
);
// System.out.println(
// "SIL: " + sil + ", rounded: " + rounded + ", frac" + frac);
IExplorationExpressionVisitor
visitor
=
new
TaskReferenceVisitor
(
source
);
IExplorationTarget
<?>
remainderKey
=
null
;
for
(
IExplorationTarget
<?>
expr
:
remainderMap
.
keySet
())
{
try
{
if
(
expr
.
getExpression
().
accept
(
visitor
,
Boolean
.
class
))
{
remainderKey
=
expr
;
break
;
}
}
catch
(
Exception
e
)
{
// Ignore
}
}
BigDecimal
remainder
=
remainderMap
.
get
(
remainderKey
);
if
(
frac
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
remainder
=
remainder
.
add
(
frac
);
if
(
remainder
.
compareTo
(
BigDecimal
.
ONE
)
>=
0
)
{
sil
=
rounded
.
add
(
BigDecimal
.
ONE
);
remainder
=
remainder
.
subtract
(
BigDecimal
.
ONE
);
}
}
if
(
sil
.
compareTo
(
BigDecimal
.
ZERO
)
>=
0
)
{
int
silInt
=
sil
.
toBigInteger
().
intValue
();
System
.
out
.
println
(((
Task
)
source
).
getName
()
+
": "
+
silInt
+
" ("
+
silRat
.
toDecimalString
(
3
)
+
") remainder: "
+
remainder
.
toString
());
createIntegerAttributeSpec
(
alloc
,
silInt
);
}
int
sil
=
toDecimal
(
silRat
).
intValue
();
if
(
sil
>=
0
)
{
createIntegerAttributeSpec
(
alloc
,
sil
);
}
}
}
else
if
(
source
instanceof
Signal
&&
target
instanceof
Route
)
{
...
...
org.fortiss.af3.exploration.smt/src/org/fortiss/af3/exploration/smt/modeltransformation/TaskReferenceVisitor.java
deleted
100644 → 0
View file @
111a591a
/*-------------------------------------------------------------------------+
| Copyright 2022 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package
org.fortiss.af3.exploration.smt.modeltransformation
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.ArithmeticLiteral
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.ArithmeticPropertyLiteral
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.Count
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.Div
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.Maximum
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.Minimum
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.Minus
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.ModelElementPropertyLiteral
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.Mul
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.Plus
;
import
org.fortiss.af3.exploration.dseml.model.arithmetic.Sum
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.And
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.BooleanLiteral
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.BooleanPropertyLiteral
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.Exists
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.ForAll
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.Implies
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.Not
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.Or
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.allocation.Allocation
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.allocation.Dislocation
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.comparison.Equal
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.comparison.Greater
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.comparison.GreaterEqual
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.comparison.Less
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.comparison.LessEqual
;
import
org.fortiss.af3.exploration.dseml.model.booleanp.comparison.NotEqual
;
import
org.fortiss.af3.exploration.dseml.model.expression.ModelElementLiteral
;
import
org.fortiss.af3.exploration.dseml.model.function.Deploy
;
import
org.fortiss.af3.exploration.dseml.model.function.IsTask
;
import
org.fortiss.af3.exploration.dseml.model.function.MasterActive
;
import
org.fortiss.af3.exploration.dseml.model.function.Maximize
;
import
org.fortiss.af3.exploration.dseml.model.function.Minimize
;
import
org.fortiss.af3.exploration.dseml.model.function.StronglyCausal
;
import
org.fortiss.af3.exploration.lang.IExplorationExpressionVisitor
;
import
org.fortiss.tooling.base.model.element.IModelElement
;
/**
*/
public
class
TaskReferenceVisitor
implements
IExplorationExpressionVisitor
{
private
IModelElement
element
;
public
TaskReferenceVisitor
(
IModelElement
element
)
{
this
.
element
=
element
;
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
And
and
)
throws
Exception
{
return
and
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
and
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
ArithmeticLiteral
arithmeticLit
)
throws
Exception
{
return
false
;
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
BooleanLiteral
boolLit
)
throws
Exception
{
return
false
;
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Count
count
)
throws
Exception
{
if
(
count
.
getSet
().
getEntries
().
contains
(
element
))
{
return
true
;
}
return
count
.
getExpression
().
accept
(
this
,
Boolean
.
class
)
||
count
.
getTerms
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Div
div
)
throws
Exception
{
return
div
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
div
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Equal
equal
)
throws
Exception
{
return
equal
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
equal
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Exists
exists
)
throws
Exception
{
for
(
IModelElement
me
:
exists
.
getSet
().
getEntries
())
{
if
(
me
==
element
)
{
return
true
;
}
if
(
exists
.
getExpression
().
accept
(
this
,
Boolean
.
class
))
{
return
true
;
}
}
return
false
;
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
ForAll
forAll
)
throws
Exception
{
for
(
IModelElement
modelElement
:
forAll
.
getSet
().
getEntries
())
{
if
(
modelElement
==
element
)
{
return
true
;
}
if
(
forAll
.
getExpression
().
accept
(
this
,
Boolean
.
class
))
{
return
true
;
}
}
return
false
;
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Greater
greater
)
throws
Exception
{
return
greater
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
greater
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
GreaterEqual
grEqual
)
throws
Exception
{
return
grEqual
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
grEqual
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Less
less
)
throws
Exception
{
return
less
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
less
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
LessEqual
leEqual
)
throws
Exception
{
return
leEqual
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
leEqual
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Maximum
max
)
throws
Exception
{
for
(
IModelElement
me
:
max
.
getSet
().
getEntries
())
{
if
(
me
==
element
)
{
return
true
;
}
if
(
max
.
getTerms
().
accept
(
this
,
Boolean
.
class
))
{
return
true
;
}
}
return
false
;
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Minimum
min
)
throws
Exception
{
for
(
IModelElement
me
:
min
.
getSet
().
getEntries
())
{
if
(
me
==
element
)
{
return
true
;
}
if
(
min
.
getTerms
().
accept
(
this
,
Boolean
.
class
))
{
return
true
;
}
}
return
false
;
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Minus
minus
)
throws
Exception
{
return
minus
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
minus
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
ModelElementLiteral
meLiteral
)
throws
Exception
{
return
meLiteral
.
getSetReference
().
getEntries
().
contains
(
element
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Mul
mul
)
throws
Exception
{
return
mul
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
mul
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Not
not
)
throws
Exception
{
return
not
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
NotEqual
notEqual
)
throws
Exception
{
return
notEqual
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
notEqual
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Or
or
)
throws
Exception
{
return
or
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
or
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Plus
plus
)
throws
Exception
{
return
plus
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
plus
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Sum
sum
)
throws
Exception
{
for
(
IModelElement
element
:
sum
.
getSet
().
getEntries
())
{
if
(
element
==
this
.
element
)
{
return
true
;
}
if
(
sum
.
getExpression
().
accept
(
this
,
Boolean
.
class
))
{
return
true
;
}
}
return
sum
.
getTerms
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
StronglyCausal
strc
)
throws
Exception
{
return
strc
.
getArg0
().
accept
(
this
,
Boolean
.
class
)
||
strc
.
getArg1
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
IsTask
isTask
)
throws
Exception
{
// TODO (#3554): remove after DSML discussion.
return
isTask
.
getArg0
().
accept
(
this
,
Boolean
.
class
)
||
isTask
.
getArg1
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Allocation
alloc
)
throws
Exception
{
return
alloc
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
alloc
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Dislocation
disLoc
)
throws
Exception
{
return
disLoc
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
disLoc
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Implies
implies
)
throws
Exception
{
return
implies
.
getLeft
().
accept
(
this
,
Boolean
.
class
)
||
implies
.
getRight
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Maximize
max
)
throws
Exception
{
return
max
.
getArgs
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Minimize
min
)
throws
Exception
{
return
min
.
getArgs
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
MasterActive
masterActive
)
throws
Exception
{
return
masterActive
.
getFs
().
accept
(
this
,
Boolean
.
class
)
||
masterActive
.
getTask
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
Deploy
deploy
)
throws
Exception
{
return
deploy
.
getFs
().
accept
(
this
,
Boolean
.
class
)
||
deploy
.
getTask
().
accept
(
this
,
Boolean
.
class
)
||
deploy
.
getEcu
().
accept
(
this
,
Boolean
.
class
);
}
/** {@inheritDoc} */
@Override
public
<
T
extends
IModelElement
,
R
extends
Number
>
R
visit
(
ArithmeticPropertyLiteral
<
T
,
R
>
arithmeticPropLit
)
throws
Exception
{
// TODO Auto-generated method stub
return
null
;
}
/** {@inheritDoc} */
@Override
public
Object
visit
(
ModelElementPropertyLiteral
mePropLit
)
{
return
mePropLit
.
getSetReference
().
getEntries
().
contains
(
element
);
}
/** {@inheritDoc} */
@Override
public
<
T
extends
IModelElement
>
Boolean
visit
(
BooleanPropertyLiteral
<
T
>
mePropLiteral
)
throws
Exception
{
return
mePropLiteral
.
getSetReference
().
getEntries
().
contains
(
element
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment