Skip to content

Commit

Permalink
checking if lower and upper in const
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed Nov 24, 2020
1 parent aa1ae0a commit 871339b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"julia.environmentPath": "y:\\SimSolver.jl"
}
6 changes: 6 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@
"type": "shell",
"command": "heta build cases/16-d-switcher",
"group": "test"
},
{
"label": "case-18",
"type": "shell",
"command": "heta build cases/18-julia-fitting",
"group": "test"
}
]
}
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
- use > instead of >= in SBML and Simbio events to support run at start
- add `atStart` prop to `_Switcher`
- extend julia format
- minor bug fixes
- rename #export Julia to SimSolver
- add properties to @Const: scale, lower, upper
- minor bug fixes

## 0.5.14

Expand Down
33 changes: 33 additions & 0 deletions src/core/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,45 @@ class Const extends _Size { // implicit extend Numeric
? this.num.toString() + '.0'
: this.num.toString();
}
// Actually this is not bind but just checking after loading all components
// It checks lower<=num<=upper, 0<num if scale=='log', 0<num<1 if scale=='logit'
bind(namespace){
super.bind(namespace);
let logger = this.namespace.container.logger;

// should be: lower <= num
if (this.lower !== undefined && this.lower > this.num) {
let msg = `Constant "${this.index}" is outside of borders: ${this.num}(num) < ${this.lower}(lower)`;
logger.error(msg, {type: 'BindingError', space: this.space});
}
// should be: num <= upper
if (this.upper !== undefined && this.upper < this.num) {
let msg = `Constant "${this.index}" is outside of borders: ${this.num}(num) > ${this.upper}(upper)`;
logger.error(msg, {type: 'BindingError', space: this.space});
}
// for scale=='log' should be: num > 0
if ((this.scale === 'log' || this.scale === 'logit') && this.num <= 0) {
let msg = `Constant "${this.index}" ${this.num}(num) is not positive that is not allowed for "log" and "logit" scale`;
logger.error(msg, {type: 'BindingError', space: this.space});
}
// for scale=='logit' should be: num < 0
if (this.scale === 'logit' && this.num >= 1) {
let msg = `Constant "${this.index}" ${this.num}(num) is not less than 1 that is not allowed for "logit" scale`;
logger.error(msg, {type: 'BindingError', space: this.space});
}
}
clone(){
let clonedComponent = super.clone();
if (typeof this.num !== 'undefined')
clonedComponent.num = this.num;
if (typeof this.free !== 'undefined')
clonedComponent.free = this.free;
if (typeof this.scale !== 'undefined')
clonedComponent.scale = this.scale;
if (typeof this.lower !== 'undefined')
clonedComponent.lower = this.lower;
if (typeof this.upper !== 'undefined')
clonedComponent.upper = this.upper;

return clonedComponent;
}
Expand Down

0 comments on commit 871339b

Please sign in to comment.