Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TULIP-CPS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NUI
TULIP-CPS
Commits
a439fabe
Commit
a439fabe
authored
Apr 07, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added isolation mode to equations. Better support for datatypes in
Python Executor
parent
05795c44
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
5 deletions
+38
-5
CPS/src/lu/list/itis/dkd/tui/cps/system/Equation.java
CPS/src/lu/list/itis/dkd/tui/cps/system/Equation.java
+19
-2
CPS/src/lu/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
...u/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
+10
-0
CPS/src/lu/list/itis/dkd/tui/cps/system/LinearEquationSystem.java
...lu/list/itis/dkd/tui/cps/system/LinearEquationSystem.java
+0
-2
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
...list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
+4
-1
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
...lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
+1
-0
CPS/src/lu/list/itis/dkd/tui/cps/utility/Externalization.java
...src/lu/list/itis/dkd/tui/cps/utility/Externalization.java
+3
-0
CPS/src/lu/list/itis/dkd/tui/cps/utility/externalization.properties
.../list/itis/dkd/tui/cps/utility/externalization.properties
+1
-0
No files found.
CPS/src/lu/list/itis/dkd/tui/cps/system/Equation.java
View file @
a439fabe
...
...
@@ -52,6 +52,7 @@ public class Equation {
@Nullable
private
Executor
scriptExecutor
;
private
String
script
;
private
boolean
isolated
;
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Equation
.
class
.
getSimpleName
());
...
...
@@ -70,6 +71,7 @@ public class Equation {
this
.
mapping
=
mapping
;
this
.
lockedMapping
=
mapping
;
this
.
script
=
script
;
this
.
isolated
=
false
;
}
/**
...
...
@@ -81,6 +83,16 @@ public class Equation {
return
mapping
;
}
/**
* Allows to isolate this equation. An isolated equation will not notify dependent equations
* when evaluation entailed changes in results.
*
* @param isolateIt
*/
public
void
setIsolated
(
boolean
isolateIt
)
{
this
.
isolated
=
isolateIt
;
}
/**
* Method called to evaluate the script of the equation with the variables provided by the
* mapping.
...
...
@@ -100,7 +112,8 @@ public class Equation {
scriptExecutor
.
eval
(
this
.
script
);
}
catch
(
Exception
exception
)
{
LOGGER
.
error
(
"Error while evaluating script {}"
,
this
.
script
,
exception
);
//$NON-NLS-1$
LOGGER
.
error
(
"Error while evaluating script {}"
,
this
.
script
);
//$NON-NLS-1$
LOGGER
.
error
(
"Engine threw an exception"
,
exception
);
//$NON-NLS-1$
}
dependentVariables
=
mapping
.
getDependentVariables
();
...
...
@@ -121,7 +134,11 @@ public class Equation {
variable
.
suspendListenerNotification
(
false
);
}
if
(
consolidated
&&
consolidatedListeners
!=
null
)
{
if
(
isolated
&&
LOGGER
.
isInfoEnabled
())
{
LOGGER
.
info
(
"Equation {} evaluated in isolated mode! Dependent variables won't trigger dependent equations!"
,
this
.
name
);
//$NON-NLS-1$
}
if
(!
isolated
&&
consolidated
&&
consolidatedListeners
!=
null
)
{
for
(
InputChangeListener
listener
:
consolidatedListeners
.
keySet
())
{
Variable
<?>
variable
=
consolidatedListeners
.
get
(
listener
);
listener
.
inputChanged
(
new
InputEvent
(
variable
));
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/EquationSystemBuilder.java
View file @
a439fabe
...
...
@@ -555,12 +555,14 @@ public class EquationSystemBuilder {
private
void
addDependencies
(
Element
equation
)
throws
EquationSystemException
{
String
periodicity
=
equation
.
getAttributeValue
(
Externalization
.
PERIODIC_ATTRIBUTE
);
boolean
periodic
=
false
;
if
(!
Strings
.
isNullOrEmpty
(
periodicity
))
{
Matcher
regex
=
booleanPattern
.
matcher
(
periodicity
);
periodic
=
regex
.
matches
();
}
addParameterDependencies
(
equation
);
addResultDependencies
(
equation
);
...
...
@@ -582,6 +584,7 @@ public class EquationSystemBuilder {
LinkedHashSet
<
Variable
<?>>
equationInputs
=
new
LinkedHashSet
<>();
LinkedHashSet
<
Variable
<?>>
equationOutputs
=
new
LinkedHashSet
<>();
boolean
lockToNesting
=
true
;
String
periodicity
=
equation
.
getAttributeValue
(
Externalization
.
PERIODIC_ATTRIBUTE
);
boolean
periodic
=
false
;
...
...
@@ -590,6 +593,12 @@ public class EquationSystemBuilder {
periodic
=
regex
.
matches
();
}
String
mode
=
equation
.
getAttributeValue
(
Externalization
.
MODE_ATTRIBUTE
);
boolean
isolated
=
false
;
if
(!
Strings
.
isNullOrEmpty
(
mode
))
{
isolated
=
Externalization
.
ISOLATED_VALUE
.
equals
(
mode
);
}
for
(
String
identifier
:
equationParameters
.
get
(
equationName
))
{
if
(
independentVariables
.
containsKey
(
identifier
))
{
...
...
@@ -637,6 +646,7 @@ public class EquationSystemBuilder {
final
LinearEquationSystem
equationSystem
=
new
LinearEquationSystem
(
lockToNesting
);
Equation
newEquation
=
new
Equation
(
equationName
,
variableMapping
,
script
);
newEquation
.
setExecutor
(
executors
.
get
(
executor
));
newEquation
.
setIsolated
(
isolated
);
equationSystem
.
addEquation
(
newEquation
);
if
(!
periodic
)
{
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/LinearEquationSystem.java
View file @
a439fabe
...
...
@@ -58,9 +58,7 @@ public class LinearEquationSystem extends System {
public
LinearEquationSystem
(
boolean
lockToNesting
)
{
super
();
equations
=
new
ConcurrentHashMap
<>();
// scriptEngine = new ScriptEngineManager().getEngineByName("js"); //$NON-NLS-1$
this
.
lockSystemForNesting
=
lockToNesting
;
// assert scriptEngine != null : "Script engine cannot be null;"; //$NON-NLS-1$
}
/**
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
View file @
a439fabe
...
...
@@ -52,7 +52,7 @@ public class PythonExecutor extends Executor {
@Override
public
void
set
(
Variable
<?>
variable
)
{
if
(
variable
instanceof
VectorVariable
)
{
VectorVariable
<?>
vector
=
(
VectorVariable
<
Double
>)
variable
;
VectorVariable
<?>
vector
=
(
VectorVariable
<
?
>)
variable
;
if
(!
vector
.
isEmpty
())
{
PyArray
array
=
null
;
...
...
@@ -84,6 +84,9 @@ public class PythonExecutor extends Executor {
LOGGER
.
info
(
"Parameter -> {} = {}"
,
variable
.
getName
(),
list
.
toString
());
//$NON-NLS-1$
}
}
}
else
{
LOGGER
.
warn
(
"Empty Vector {}"
,
variable
.
getName
());
//$NON-NLS-1$
engine
.
set
(
variable
.
getName
(),
new
PyArray
(
Object
.
class
,
0
));
}
}
else
{
...
...
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/SqlExecutor.java
View file @
a439fabe
...
...
@@ -373,6 +373,7 @@ public class SqlExecutor extends Executor {
// Suspend notification of input change listeners while populating vector
variable
.
suspendListenerNotification
(
true
);
vector
.
clear
();
for
(
Object
[]
values
:
columnValues
)
{
Object
value
=
values
[
index
];
vector
.
add
(
value
);
...
...
CPS/src/lu/list/itis/dkd/tui/cps/utility/Externalization.java
View file @
a439fabe
...
...
@@ -42,6 +42,7 @@ public class Externalization extends NLS {
public
static
String
VECTOR_VARIABLE_CLASS
;
public
static
String
EQUATION_ELEMENT
;
public
static
String
MODE_ATTRIBUTE
;
public
static
String
EQUATIONS_ELEMENT
;
public
static
String
INVOKE_ELEMENT
;
public
static
String
EXECUTOR_ATTRIBUTE
;
...
...
@@ -75,6 +76,8 @@ public class Externalization extends NLS {
public
static
final
String
TEXT_TYPE
=
"text"
;
public
static
final
String
VECTOR_TYPE
=
"vector"
;
public
static
final
String
ISOLATED_VALUE
=
"isolated"
;
static
{
// initialize resource bundle
...
...
CPS/src/lu/list/itis/dkd/tui/cps/utility/externalization.properties
View file @
a439fabe
...
...
@@ -11,6 +11,7 @@ EXECUTOR_POSTFIX=Executor
EQUATIONS_ELEMENT
=
equations
EQUATION_ELEMENT
=
equation
MODE_ATTRIBUTE
=
mode
INVOKE_ELEMENT
=
invoke
EXECUTOR_ATTRIBUTE
=
executor
NAME_ATTRIBUTE
=
name
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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