Forum Stats

  • 3,814,398 Users
  • 2,258,870 Discussions
  • 7,892,696 Comments

Discussions

Resource allocation problem

Suneesh Raman-Oracle
Suneesh Raman-Oracle Member Posts: 249 Employee
edited Apr 2, 2018 7:50PM in Java Programming

Hi Experts ,
I do have complex scenario to be solved using Java .I have n arrays of resource availability. Out of that I need to get best 5 resource allocation.

For example : 

a[105]= [0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]

a[111]=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]

a[119]=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]

a[105] represents the resource id 105.Each if this array represents resource availability . 0 - means resource is not available and 1 means resource available. Each node represents half an hour
duration . I need to get 5 best possibilities where resource(s) who can work on 6 hours.
- My first preference will be resources can work continues 6 hours.
- My second preference will be resource minimum number of resources to work 6 hours
- I need to get 5 possibilities to display .

Answers

  • Unknown
    edited Apr 2, 2018 7:11PM

    Thanks for trying to provide sample data but that doesn't appear to be a complete set of requirements.

    1. the arrays don't even represent an even number of days

    2. doesn't it matter at all what time of day the resource is available?

    3. doesn't it matter at all what time of day you actually want the resource to be available?

    4. doesn't it matter at all how many resources are selected?

    5. doesn't it matter at all whether multiple resources work at the same time or at different times?

    Typically a use case like this would have additional requirements:

    1. Project requires 7 hours of time

    2. Project work must be done between START DATE and END DATE - for example during a 5 day window

    3. Resource must be available to work between 5am and 2pm (example only - but a time window is usually provided

    4. No more than N resources can be selected - that is for 7 hours you can't select 14 resources for 1/2 hour each

    Please complete the requirements so we can help you find possible solutions.

  • morgalr
    morgalr Member Posts: 457
    edited Apr 2, 2018 7:50PM

    Homework I would suspect; but basically you need to put the arrays into a form Java will understand, if you have them as ints, then you need to separate them by commas.

    Processing them as a string would be a lot easier, you could use a pattern match.

    If you need to do the arrays as ints, then start from 0 to n-1, and check to see if it is a 0 or a 1, if it is a 1, then check to see if you can get 11 more 1's before the end of the array.

    Note: if you have 14 1's in a row, that is 3 time periods 1-12, 2-13, 3-14.

This discussion has been closed.