Skip to main content
deleted 7 characters in body; edited tags
Source Link
toolic
  • 15.9k
  • 6
  • 29
  • 217

I'm using a function to determine if resources can be used again or not. This is the numpynumpy array I'm using.

So this is main idea behind my function, the. The problem here is that it takes more than 60% of the whole program runtime, and I would appreciate any advice about how to make it more efficient/faster. Thank you.

I'm using a function to determine if resources can be used again or not. This is the numpy array I'm using.

So this is main idea behind my function, the problem here is that it takes more than 60% of the whole program runtime and I would appreciate any advice about how to make it more efficient/faster. Thank you.

I'm using a function to determine if resources can be used again or not. This is the numpy array I'm using.

So this is main idea behind my function. The problem here is that it takes more than 60% of the whole program runtime, and I would appreciate any advice about how to make it more efficient/faster.

added 6 characters in body
Source Link
Reinderien
  • 71.1k
  • 5
  • 76
  • 256

I'm using a function to determine if resources can be used again or not. This is the numpy array i'mI'm using.

  1. First step is to find all resource available on a date, for example (2019-05-16 from 8:30 to 17:30). To achieve this iI used np.wherenp.where like the example below:

     av_resource_np = resource_availability_np[np.where(
     (resource_availability_np[:,1] <= '2019-05-16')
     & (resource_availability_np[:,2] >= '2019-05-16')
     & (resource_availability_np[:,3] <= '17:30:00') 
     & (resource_availability_np[:,4] >= '08:30:00'))]
    
  2. Here iI try to find unique resource ids and the sum of their overload factor using np.unique()np.unique():

     unique_id, count_nb = np.unique(av_resource_np[:,(0,5)], axis=0, return_counts=True)
     availability_mat = np.column_stack((unique_id, count_nb ))
    

Which yields the followigfollowing results:

So this is main idea behind my function, the problem here is that it takes more than 60% of the whole program runtime and iI would appreciate any advice about how to make it more efficient/faster. Thank you.

I'm using a function to determine if resources can be used again or not. This is the numpy array i'm using.

  1. First step is to find all resource available on a date, for example (2019-05-16 from 8:30 to 17:30). To achieve this i used np.where like the example below:

     av_resource_np = resource_availability_np[np.where(
     (resource_availability_np[:,1] <= '2019-05-16')
     & (resource_availability_np[:,2] >= '2019-05-16')
     & (resource_availability_np[:,3] <= '17:30:00') 
     & (resource_availability_np[:,4] >= '08:30:00'))]
    
  2. Here i try to find unique resource ids and the sum of their overload factor using np.unique()

     unique_id, count_nb = np.unique(av_resource_np[:,(0,5)], axis=0, return_counts=True)
     availability_mat = np.column_stack((unique_id, count_nb ))
    

Which yields the followig results:

So this is main idea behind my function, the problem here is that it takes more than 60% of the whole program runtime and i would appreciate any advice about how to make it more efficient/faster. Thank you.

I'm using a function to determine if resources can be used again or not. This is the numpy array I'm using.

  1. First step is to find all resource available on a date, for example (2019-05-16 from 8:30 to 17:30). To achieve this I used np.where like the example below:

     av_resource_np = resource_availability_np[np.where(
     (resource_availability_np[:,1] <= '2019-05-16')
     & (resource_availability_np[:,2] >= '2019-05-16')
     & (resource_availability_np[:,3] <= '17:30:00') 
     & (resource_availability_np[:,4] >= '08:30:00'))]
    
  2. Here I try to find unique resource ids and the sum of their overload factor using np.unique():

     unique_id, count_nb = np.unique(av_resource_np[:,(0,5)], axis=0, return_counts=True)
     availability_mat = np.column_stack((unique_id, count_nb ))
    

Which yields the following results:

So this is main idea behind my function, the problem here is that it takes more than 60% of the whole program runtime and I would appreciate any advice about how to make it more efficient/faster. Thank you.

Changed title.
Source Link

Optimizing python function using numpy. where and numpy.unique to find availabilities Resource reservation system

Optimizing python function using numpy. where and numpy.unique to find availabilities Resource reservation system

Optimizing python function using numpy. where and numpy.unique to find availabilities

Resource reservation system

Source Link
Loading