Assign event to technician - optaplanner

I am using optaplanner.I have One technician and 3 events .Technician working time is morning 8 to evening 6 ,1st event start time is 10 am and 2nd event time is 11am and 3rd event time is 9am to 1pm between,all event duration is 30 minitus .So my problem is how can assign and calculate best score for technician in time range .
i want 3rd event assigned technician 9 to 9.3o and 1st event aasigned 10 am and 2nd event aasigned 11am.

The best way to define your score funcion is to take this input problem and put a number of possible resulting states on paper (preferably in a spreadsheet). Then figure out a way to score those different combinations such as the "best solution" has the best score. For example by doing load balancing (= see docs section "fairness") of the gaps between 2 starting time.

Related

Interval of one month back not working on the 31st?

Essentially, I have a query that is responsible for fetching all records (with specific filters) within the last month. I'm using Oracle's interval keyword and all was working great until today (December 31st, 2009). The code I'm using is
select (sysdate - interval '1' month) from dual
and the error I get it
ORA-01839: date not valid for month specified
How can I use the interval keyword to be compatible with any date? Or if anyone has a better way of approaching the issue, I'm all ears.
Thank you.
try
select add_months(sysdate,-1) from dual
Being pedantic...
The requirements are not quite specified perfectly unambiguously. What does the business mean by "within the last month"? Most people would take that to mean "within the current calendar month" in which case I'd use:
TRUNC(SYSDATE,'MM')
Otherwise, perhaps they want an arbitrary period of 1 month prior to the current date - but then how do you define that? As you've found, INTERVAL '1' MONTH simply subtracts one from the month portion of the date - e.g. 15-JAN-2009 - INTERVAL '1' MONTH returns 15-DEC-1999. For some dates, this results in an invalid date because not all months have the same number of days.
ADD_MONTHS resolves this by returning the last day in the month, e.g. ADD_MONTHS(31-DEC-2009,-1) returns 30-NOV-2009.
Another possibility is that the business actually wants to use an average month period - e.g. 365/12 which is approximately 30.4. They might want you to use SYSDATE-30, although of course twelve iterations of this will only cover 360 days of the year.

Calculated field in Data Studio that increments number based on conditions

I want to create 2 new fields to show the max continuous day that we made sales and the previous record for the max continuous day. This is very identical to "accident-free days" dashboard in factories.
E.g
Today's date is 04/03/2019 and for 3 days we make continuous sales, i.e., there is no day for 3 days we didn't make sales. So, the first metric on the dashboard would be:
This company has worked 3 days with continuous sales.
The previous record was 6 day which means we made continuous sales 6 days in a row. So, the second metric on the dashboard would be:
The best previous record was 6 days.
I had a look at the function list on Data Studio. However, I didn't come across a function that helps me to increment the number based on this condition.
Data is fetched from MySQL. I guess, this condition is based on the date:
Every time a record in sales table is created, this means we made sales. The date attribute in this table is called "created_at". So, if the difference between two created_at record is greater than 1, it is reset to 0, if not it should be incremented. Moreover, this value shall be compared with the previous maximum record. If it is greater than the maximum record, the maximum record would be replaced with this one.
P.S. I don't know if this is even possible in Data Studio. If not, any other alternative solution is much appreciated.

Record by record timestamp difference calculation

I am working on a logic to find the consecutive time difference between two timestamps in the streaming layer(spark) by comparing the previous time and current time and storing the value in the database.
For eg:
2017-08-01 11:00:00
2017-08-01 11:05:00
2017-08-01 11:07:00
So according to the above timestamps my consecutive diff will be 5 mins(11:00:00 - 11:05:00) and 2 mins respectively and when i sum the difference I will get 7 mins(5+2) which will be actual time difference.. Now the real challenge is when I receive delayed timestamp.
For eg:
2017-08-01 11:00:00
2017-08-01 11:05:00
2017-08-01 11:07:00
2017-08-01 11:02:00
Here when i calculate the difference it will be 5 mins,2 mins,5 mins respectively and now sum of the difference I will get 12 mins(5+2+5) which will be greater than the actual time difference(7 mins).which is wrong
please help me to find a workaround to handle this delayed timestamp in record by record time difference calculation.
What you are experiencing is the difference between 'event time' and 'processing time'. In the best case, processing time will be nearly identical to event time, but sometimes, an input record is delayed, so the difference will be larger.
When you process streaming data, you define (explicitly or implicitly) a window of records that you look at. If you process records individually, this window has size 1. In your case, your window has size 2. But you could also have a window that is based on time, i.e. you can look at all records that have been received in the last 10 minutes.
If you want to process delayed records in-order, you need to wait before the delayed records have arrived and then sort the records within the window. The problem then becomes, how long do you wait? The delayed records may show up 2 days later! How long to wait is a subjective question and depends on your application and its requirements.
Note that if your window is time-based, you will need to handle the case where no previous record is available.
I highly recommend this article: https://www.oreilly.com/ideas/the-world-beyond-batch-streaming-101 to get to grips with streaming terminology and windows.

Are the weekly numbers on my dashboard calculating data from the past week or up to the next week?

Are the 83 signups showing for March 18th calculating the signups between March 11 - March 18 or are these the number of signups that happened from March 18 - March 25?
Screenshot of dashboard
Gotcha, thanks for the screenshot of your analysis run on the Keen IO Explorer. You have a weekly interval, combined with a "this_3_months" timeframe. The "this" timeframes are inclusive of the current time, so this is going to be "up till right now". This, means that the final datapoint on the chart is the current week (which is still in progress). The result for that number is going to keep growing if new data comes in. And once you leave this week, and start a new week, that will be the second to last data point. Only when that happens, will that datapoint be unchanging.
Here's a link to more information about using timeframes in Keen. There's a chart which describes how you can use relative timeframes like 'this' or 'previous' here: chart.

Finding the Min & Max Times for Multiple Individuals

For work I have a report where I compile the number of calls, emails, and texts a person makes each day. Along with this I need to pick out the earliest (Min) and the latest (max) times for each of those actions. I'm wondering if there isn't an easier way to me to pull this data from the date column rather than scrolling down for each person and finding the information.
You are right, there is definitely an easier way. What we need to rely on is that Excel stores times as the number of days since 0th January 1900 (so 1st January 1900 is day 1). Therefore, finding the earliest and latest times is simple a matter of finding the min and max values within a specific day.
I'm assuming that your data is set out as in the following. If it isn't, you can just edit my formula as appropriate.
A B C D
1 Person Date Time
2 Steve Monday 14:00
3 Steve Monday 14:05
4 Sharon Monday 12:00
5 Steve Tuesday 09:00
6 Sharon Tuesday 15:00
What we need to do is find the minimum time for Steve, given that date = Monday. We need to use an array formula. Array formulas let us 'look up' against more than one cell at the same time. The formula I would use is:
=MIN(IF(A2:A6="Steve",IF(B2:B6="Monday",C2:C6)))
Instead of clicking 'Enter' when you use this formula, you need to click Ctrl+Shift+Enter i.e., you enter the formula above and click Ctrl+Shift+Enter and Excel will return:
={MIN(IF(A2:A6="Steve",IF(B2:B6="Monday",C2:C6)))}
Can you see how to add more constraints to the look up? I've included an example screenshot below, where I've made a bigger table and also made the 'Steve' and 'Monday' references refer out to a cell, rather than just being hardcoded into the formula.

Resources