Explore all Edge Computing open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Edge Computing

No Popular Releases are available at this moment for Edge Computing

Popular Libraries in Edge Computing

No Trending Libraries are available at this moment for Edge Computing

Trending New libraries in Edge Computing

No Trending Libraries are available at this moment for Edge Computing

Top Authors in Edge Computing

No Top Authors are available at this moment for Edge Computing.

Trending Kits in Edge Computing

No Trending Kits are available at this moment for Edge Computing

Trending Discussions on Edge Computing

Skooma input validator

How do I create a Near Edge computing system? (Send sensor data with Raspberry Pi/DHT11 sensor)

What is the time complexity of this peudo code?

QUESTION

Skooma input validator

Asked 2022-Feb-03 at 15:35

I was given a task to implement an input validator with the Skooma library https://github.com/bobfp/skooma#validators

The general concept is pretty clear, but for some inputs I have a list of "legal" words, and I have zero clue on how to implement the validation for this case. Hence why I came here, I wanted to ask if you know any examples / projects that used this library? I googled but didn't find anything. Of if you have any other tipps just let me know! 🙂 This is the example:

my schema:

1schema = %{
2:titel => :string, 
3:category => :string, 
4:high_level_category => :string, 
5:description => :string, 
6:potential_impacts => :string, 
7:affected_assets => :string, 
8:rating => :string }
9

The legal inputs for category:

1schema = %{
2:titel => :string, 
3:category => :string, 
4:high_level_category => :string, 
5:description => :string, 
6:potential_impacts => :string, 
7:affected_assets => :string, 
8:rating => :string }
9category = %{core: 'Core network threats', access: 'Access network threats', multi: 'Multi edge computing threats',
10virtualisation: 'Virtualisation threats', phyiscal: 'Physical infrastructure threats', generic: 'Generic threats'}
11

I tried it with a normal list as well, such as

1schema = %{
2:titel => :string, 
3:category => :string, 
4:high_level_category => :string, 
5:description => :string, 
6:potential_impacts => :string, 
7:affected_assets => :string, 
8:rating => :string }
9category = %{core: 'Core network threats', access: 'Access network threats', multi: 'Multi edge computing threats',
10virtualisation: 'Virtualisation threats', phyiscal: 'Physical infrastructure threats', generic: 'Generic threats'}
11category = ['Core network threats', 'Access network threats', 'Multi edge computing threats' .......]
12

But I just cant get my head around how to check if the :category is present in the category list.

ANSWER

Answered 2022-Jan-31 at 00:05

You need a custom validator function, here's an example:

1schema = %{
2:titel => :string, 
3:category => :string, 
4:high_level_category => :string, 
5:description => :string, 
6:potential_impacts => :string, 
7:affected_assets => :string, 
8:rating => :string }
9category = %{core: 'Core network threats', access: 'Access network threats', multi: 'Multi edge computing threats',
10virtualisation: 'Virtualisation threats', phyiscal: 'Physical infrastructure threats', generic: 'Generic threats'}
11category = ['Core network threats', 'Access network threats', 'Multi edge computing threats' .......]
12alias Skooma.Validators
13
14@valid_categories [
15  "Access network threats",
16  "Core network threats",
17  "Generic threats",
18  "Multi edge computing threats",
19  "Physical infrastructure threats",
20  "Virtualisation threats"
21]
22
23def valid?(data), do: Skooma.valid?(data, schema())
24
25defp schema,
26  do: %{
27    :category => [:string, inclusion(@valid_categories)],
28    ... # rest of the schema
29  }
30
31# copied from:
32# https://github.com/bobfp/skooma/blob/master/lib/validators.ex#L38-L48
33defp inclusion(values_list) when is_list(values_list) do
34  fn data ->
35    bool = data in values_list
36
37    if bool do
38      :ok
39    else
40      {:error, "Value is not included in the options: #{inspect(values_list)}"}
41    end
42  end
43end
44

You can replace the inclusion function with Validators.inclusion/1. In this case, you'll need to install Skooma from Github because it has not been published as speaking today (31 Jan 2022).

Source https://stackoverflow.com/questions/70913797

QUESTION

How do I create a Near Edge computing system? (Send sensor data with Raspberry Pi/DHT11 sensor)

Asked 2021-Jan-22 at 10:01

I am working on edge computing for IoT applications and expected to create a system that acts as a near edge computer with the use of a raspberry pi hooked up to a dht11 sensor. How do I send this data over to a computer that is at the edge? Ideally I want to use my PC as this device but I have no clue how to send this data over in real time.

So far I have created the circuit and can view the temperature and humidity readings on the raspberry pi in python. Unsure of what the next steps are - I don't want to send this data over to the cloud just yet.

Side note: I believe i may be missing knowledge regarding this but is the raspberry pi an edge device because it is hooked up to the sensor directly?

Any help is greatly appreciated.

ANSWER

Answered 2021-Jan-22 at 10:01

You need to think this through a bit more. What will you do with the temperature and humidity data that you receive?

For example, if you're just experimenting and want to just see the readings in a console on your PC, you can use netcat to send the console output of your Python program from the RPi to PC. No SW development needed, they just have to be in the same network. Not particularly useful for anything else, either.

Otherwise you need to set up some client-server solution between the RPi and your PC. There's a ton of possible solutions, all depending on what you plan to do with the data. You can use MQTT, HTTP, a straight database connection (MySQL, PostgreSQL), etc. You have to supply both sides of the connection. The Python code on client side which connects and sends data; and the server side thing that accepts the samples and stores them somewhere. Plus all the networking, authentication etc.

Or you can just download the Python client libraries for your favourite cloud solution and set that up according to a tutorial. TBH, this sounds a lot less work to me.

Source https://stackoverflow.com/questions/65835920

QUESTION

What is the time complexity of this peudo code?

Asked 2020-Jun-21 at 12:16

I don't have a lot of knowledge computing the complexity. Can you help estimate the complexity of the following pseudo-codes?

Algorithm 1:

1Input: V1, V2 and V3 and another vector C// Vectors of size n
2Output: response..
3V_f = f(V1, V2, 3) // function performs simple multiplication and additions on the vector
4for i in range(0,n) // loop over element in the vector
5     if V_f(i) != C(i) 
6              // sort the V1(i), V2(i) and V3(i) and retrieve the middle value
7              // if the middle value is in a range of certain values then launch Algorithm 2  
8             // Over the result of Algorithm 2 (using if expressions), print the response
9// end and return result
10

Algorithm 2

1Input: V1, V2 and V3 and another vector C// Vectors of size n
2Output: response..
3V_f = f(V1, V2, 3) // function performs simple multiplication and additions on the vector
4for i in range(0,n) // loop over element in the vector
5     if V_f(i) != C(i) 
6              // sort the V1(i), V2(i) and V3(i) and retrieve the middle value
7              // if the middle value is in a range of certain values then launch Algorithm 2  
8             // Over the result of Algorithm 2 (using if expressions), print the response
9// end and return result
10Input: Sorted
11
12 Values C{1}, C{2} and C{3} and the vector C
13
14Output: Response:
15
16for i in range (o,n) // loop over the elements 
17       // According to the values of C and C{i}, perform additions (using if expressions)
18// end and return result
19

The operations inside the loops are just additions or simple tests. Also, Algorithm 2 is executed withing Algorithm1, which means I have a loop inside a loop (right?):

1Input: V1, V2 and V3 and another vector C// Vectors of size n
2Output: response..
3V_f = f(V1, V2, 3) // function performs simple multiplication and additions on the vector
4for i in range(0,n) // loop over element in the vector
5     if V_f(i) != C(i) 
6              // sort the V1(i), V2(i) and V3(i) and retrieve the middle value
7              // if the middle value is in a range of certain values then launch Algorithm 2  
8             // Over the result of Algorithm 2 (using if expressions), print the response
9// end and return result
10Input: Sorted
11
12 Values C{1}, C{2} and C{3} and the vector C
13
14Output: Response:
15
16for i in range (o,n) // loop over the elements 
17       // According to the values of C and C{i}, perform additions (using if expressions)
18// end and return result
19for i in range (n)
20// operations
21// for j in range (n)
22// operations
23

So does this mean the time complexity of this algorithm is O(n^2)? where n is the size of of the vector?

Also as a general question, if Algorithm 1 and algorithm 2 are executed in parallel, what is the overall complexity? is it the sum or the max of the complexity of each algorithm?

ANSWER

Answered 2020-Jun-21 at 11:50
Algorithm1
  1. The algorithm1 will first perform simple multiplication and addition on vectors. Assuming that it loops from start to end on each vector and performs some calculations, the number of iterations made would be 3*N which would be considered O(N)

1Input: V1, V2 and V3 and another vector C// Vectors of size n
2Output: response..
3V_f = f(V1, V2, 3) // function performs simple multiplication and additions on the vector
4for i in range(0,n) // loop over element in the vector
5     if V_f(i) != C(i) 
6              // sort the V1(i), V2(i) and V3(i) and retrieve the middle value
7              // if the middle value is in a range of certain values then launch Algorithm 2  
8             // Over the result of Algorithm 2 (using if expressions), print the response
9// end and return result
10Input: Sorted
11
12 Values C{1}, C{2} and C{3} and the vector C
13
14Output: Response:
15
16for i in range (o,n) // loop over the elements 
17       // According to the values of C and C{i}, perform additions (using if expressions)
18// end and return result
19for i in range (n)
20// operations
21// for j in range (n)
22// operations
23V_f = f(V1, V2, 3)          #Time complexity will be O(N)
24
  • The next statement in first algorithm will also loop from 0 to N. Assuming that in each case V_f(i) != C(i) , you will have to sort V1[i], V2[i], V3[i] which will take constant O(1) time.

  • 1Input: V1, V2 and V3 and another vector C// Vectors of size n
    2Output: response..
    3V_f = f(V1, V2, 3) // function performs simple multiplication and additions on the vector
    4for i in range(0,n) // loop over element in the vector
    5     if V_f(i) != C(i) 
    6              // sort the V1(i), V2(i) and V3(i) and retrieve the middle value
    7              // if the middle value is in a range of certain values then launch Algorithm 2  
    8             // Over the result of Algorithm 2 (using if expressions), print the response
    9// end and return result
    10Input: Sorted
    11
    12 Values C{1}, C{2} and C{3} and the vector C
    13
    14Output: Response:
    15
    16for i in range (o,n) // loop over the elements 
    17       // According to the values of C and C{i}, perform additions (using if expressions)
    18// end and return result
    19for i in range (n)
    20// operations
    21// for j in range (n)
    22// operations
    23V_f = f(V1, V2, 3)          #Time complexity will be O(N)
    24for i in range(0,n) // loop over element in the vector
    25    if V_f(i) != C(i) 
    26

    In the next statement, You are checking is the middle value of above sorted elements is in a particular range - // if the middle value is in a range of certain values then launch Algorithm 2 , now the time complexity of this depends on how the checking is done and how big the range is. I will assume that you need to check in a continous range from a to b and so this step will take O(1) only. Now Algorithm2 will be called.

    Algorithm2
    1. Algorithm 2 -

    1Input: V1, V2 and V3 and another vector C// Vectors of size n
    2Output: response..
    3V_f = f(V1, V2, 3) // function performs simple multiplication and additions on the vector
    4for i in range(0,n) // loop over element in the vector
    5     if V_f(i) != C(i) 
    6              // sort the V1(i), V2(i) and V3(i) and retrieve the middle value
    7              // if the middle value is in a range of certain values then launch Algorithm 2  
    8             // Over the result of Algorithm 2 (using if expressions), print the response
    9// end and return result
    10Input: Sorted
    11
    12 Values C{1}, C{2} and C{3} and the vector C
    13
    14Output: Response:
    15
    16for i in range (o,n) // loop over the elements 
    17       // According to the values of C and C{i}, perform additions (using if expressions)
    18// end and return result
    19for i in range (n)
    20// operations
    21// for j in range (n)
    22// operations
    23V_f = f(V1, V2, 3)          #Time complexity will be O(N)
    24for i in range(0,n) // loop over element in the vector
    25    if V_f(i) != C(i) 
    26 for i in range (o,n) // loop over the elements 
    27        // According to the values of C and C{i}, perform additions (using if expressions)
    28 // end and return result
    29

    Here, you will again be looping from 0 to N and performing some calculation in each iteration which will take O(1). So total time complexity would be O(N) for the whole algorithm2.


    So does this mean the time complexity of this algorithm is O(n^2)?

    Now, assuming the worst-case , you will have to run algorithm 2 in every iteration inside the algorthm1's loop. So, the time complexity would be O(N^2) as you said. Note that this will also depend on how simple the calculations are, how the checking in a range of certain values is done and would contribute to the constant in our final time complexity. But assuming, they aren't more than O(N), your overall time complexity would be O(N^2)

    Source https://stackoverflow.com/questions/62497868

    Community Discussions contain sources that include Stack Exchange Network

    Tutorials and Learning Resources in Edge Computing

    Tutorials and Learning Resources are not available at this moment for Edge Computing

    Share this Page

    share link

    Get latest updates on Edge Computing