Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dunixir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
teaching
dunixir
Commits
4aaf36e8
Commit
4aaf36e8
authored
4 years ago
by
x18zhan2
Browse files
Options
Downloads
Patches
Plain Diff
implements:
#87
-TODO: complete test file
parent
23792ee3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#1330
failed
4 years ago
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/dunixir/constants.ex
+1
-0
1 addition, 0 deletions
lib/dunixir/constants.ex
lib/local_augmentation_example.ex
+76
-15
76 additions, 15 deletions
lib/local_augmentation_example.ex
test/block/augmentation/head_unitbase_test.exs
+6
-0
6 additions, 0 deletions
test/block/augmentation/head_unitbase_test.exs
with
83 additions
and
15 deletions
lib/dunixir/constants.ex
+
1
−
0
View file @
4aaf36e8
...
...
@@ -10,6 +10,7 @@ defmodule Constants do
def
sigValidity
,
do
:
10
def
sigPeriod
,
do
:
10
def
sigReplay
,
do
:
10
def
nbDigitsUD
,
do
:
4
end
defmodule
Constants
.
Contract
do
...
...
This diff is collapsed.
Click to expand it.
lib/local_augmentation_example.ex
+
76
−
15
View file @
4aaf36e8
defmodule
Index
.
Augmentation
do
defmodule
BIndex
do
def
conf
,
do
:
ConfDTO
.
mockConfDTO
()
## BR_G01
def
number
(
global_bindex
,
local_bindex
)
do
key
=
:ets
.
first
(
local_bindex
)
...
...
@@ -125,35 +126,29 @@ defmodule Index.Augmentation do
end
end
## BR_G11
part 1
## BR_G11
def
udTime
(
global_bindex
,
local_bindex
)
do
# UD production
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
conf
=
ConfDTO
.
mockConfDTO
()
if
head
.
number
==
0
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udTime:
conf
.
udTime0
})})
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udTime:
conf
()
.
udTime0
})})
else
[[
head_1_id
]]
=
:dets
.
match
(
global_bindex
,
{
:"$1"
,
%{
number:
head
.
number
-
1
}})
[{
_key_1
,
head_1
}]
=
:dets
.
lookup
(
global_bindex
,
head_1_id
)
if
head_1
.
udTime
<=
head
.
medianTime
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udTime:
head_1
.
udTime
+
conf
.
dt
})})
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udTime:
head_1
.
udTime
+
conf
()
.
dt
})})
else
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udTime:
head_1
.
udTime
})})
end
end
udReevalTime
(
global_bindex
,
local_bindex
)
end
## BR_G11 part 2
def
udReevalTime
(
global_bindex
,
local_bindex
)
do
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
conf
=
ConfDTO
.
mockConfDTO
()
# update head
[{
key
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
key
)
if
head
.
number
==
0
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udReevalTime:
conf
.
udReevalTime0
})})
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udReevalTime:
conf
()
.
udReevalTime0
})})
else
[[
head_1_id
]]
=
:dets
.
match
(
global_bindex
,
{
:"$1"
,
%{
number:
head
.
number
-
1
}})
[{
_key_1
,
head_1
}]
=
:dets
.
lookup
(
global_bindex
,
head_1_id
)
...
...
@@ -161,7 +156,7 @@ defmodule Index.Augmentation do
if
head_1
.
udReevalTime
<=
head
.
medianTime
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udReevalTime:
head_1
.
udReevalTime
+
conf
.
dtReeval
})}
{
key
,
Map
.
merge
(
head
,
%{
udReevalTime:
head_1
.
udReevalTime
+
conf
()
.
dtReeval
})}
)
else
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
udReevalTime:
head_1
.
udReevalTime
})})
...
...
@@ -169,7 +164,7 @@ defmodule Index.Augmentation do
end
end
## BR_G12
part 1
## BR_G12
def
unitBaseBR_G12
(
global_bindex
,
local_bindex
)
do
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
...
...
@@ -183,6 +178,69 @@ defmodule Index.Augmentation do
end
end
## BR_G13
def
dividend
(
global_bindex
,
local_bindex
)
do
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
# UD re-evaluation
if
head
.
number
==
0
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
dividend:
conf
()
.
ud0
})})
else
[[
head_1_id
]]
=
:dets
.
match
(
global_bindex
,
{
:"$1"
,
%{
number:
head
.
number
-
1
}})
[{
_key_1
,
head_1
}]
=
:dets
.
lookup
(
global_bindex
,
head_1_id
)
if
head
.
udReevalTime
!=
head_1
.
udReevalTime
do
previousUB
=
head_1
.
unitBase
dividend
=
Float
.
ceil
(
head_1
.
dividend
+
:math
.
pow
(
conf
()
.
c
,
2
)
*
Float
.
ceil
(
head_1
.
massReeval
/
:math
.
pow
(
10
,
previousUB
))
/
head
.
membersCount
/
(
conf
()
.
dtReeval
/
conf
()
.
dt
)
)
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
dividend:
dividend
})})
else
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
dividend:
head_1
.
dividend
})})
end
end
[{
key
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
key
)
# UD creation
if
head
.
number
==
0
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
new_dividend:
nil
})})
else
[[
head_1_id
]]
=
:dets
.
match
(
global_bindex
,
{
:"$1"
,
%{
number:
head
.
number
-
1
}})
[{
_key_1
,
head_1
}]
=
:dets
.
lookup
(
global_bindex
,
head_1_id
)
if
head
.
udTime
!=
head_1
.
udTime
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
new_dividend:
head
.
dividend
})})
else
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
new_dividend:
nil
})})
end
end
end
## BR_G14
def
unitBase
(
local_bindex
)
do
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
if
head
.
dividend
>=
:math
.
pow
(
10
,
Constants
.
nbDigitsUD
())
do
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
dividend:
Float
.
ceil
(
head
.
dividend
/
10
)})}
)
[{
key
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
key
)
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
new_dividend:
head
.
dividend
})})
:ets
.
insert
(
local_bindex
,
{
key
,
Map
.
merge
(
head
,
%{
unitBase:
head
.
unitBase
+
1
})})
end
end
## BR_G99
def
currency
(
global_bindex
,
local_bindex
)
do
[{
key
,
head
}]
=
find_first_local_bindex_entry
(
local_bindex
)
...
...
@@ -247,7 +305,10 @@ defmodule Index.Augmentation do
end
)
)
:ets
.
insert
(
local_iindex
,
{
key
,
Map
.
merge
(
entry
,
%{
excludedIsMember:
excludedIsMember
})})
:ets
.
insert
(
local_iindex
,
{
key
,
Map
.
merge
(
entry
,
%{
excludedIsMember:
excludedIsMember
})}
)
end
end
...
...
This diff is collapsed.
Click to expand it.
test/block/augmentation/head_unitbase_test.exs
+
6
−
0
View file @
4aaf36e8
...
...
@@ -12,6 +12,7 @@ defmodule Block.Augmentation.Head.UnitBaseTest do
:file
.
delete
(
"test/global_bindex"
)
{
:ok
,
global_bindex
}
=
:dets
.
open_file
(
:"test/global_bindex"
,
type:
:set
)
################## TEST FOR unitBaseBR_G12 #####################
Index
.
Augmentation
.
BIndex
.
unitBaseBR_G12
(
global_bindex
,
local_bindex
)
[{
0
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
0
)
unit_base0
=
head
.
unitBase
...
...
@@ -23,6 +24,11 @@ defmodule Block.Augmentation.Head.UnitBaseTest do
[{
0
,
head
}]
=
:ets
.
lookup
(
local_bindex
,
0
)
unit_base1
=
head
.
unitBase
################## TEST FOR dividend #####################
# :ets.insert(local_bindex, {0, %{number: 0, }})
# :dets.insert(global_bindex, {0, %{number: 0, unitBase: 5}})
:dets
.
close
(
global_bindex
)
:file
.
delete
(
"test/global_bindex"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment