Nurse-scheduling: Largest sequence of no-shifts in N days must be > X - or-tools

I'm experimenting with the nurse scheduling example, https://developers.google.com/optimization/scheduling/employee_scheduling#nurse_scheduling, and trying to figure out how to model the following constraint:
In a sliding 6 week window, each nurse must have at least 14 consecutive days with no shifts (i.e., be assigned to shift O).
add_soft_sequence_constraint isn't the right tool (I think, if I've understood properly) because that will try and enforce that all sequences of no shifts are 14 days, and I want to enforce that there is at least one sequence of no shifts that is 14 days long.
Any suggestions for how to model this would be gratefully received.

Related

Anylogic: How to block a line by a probability?

So I'm modelling a production line (simple, with 5 processes which I modelled as Services). I'm simulating for 1 month, and during this one month, my line stops approximately 50 times (due to a machine break down). This stop can last between 3 to 60 min and the avg = 12 min (depending on a triangular probability). How could I implement this to the model? I'm trying to create an event but can't figure out what type of trigger I should use.
Have your services require a resource. If they are already seizing a resource like labor, that is ok, they can require more than one. On the resourcePool, there is an area called "Shifts, breaks, failures, maintenance..." Check "Failures/repairs:" and enter your downtime distribution there.
If you want to use a triangular, you need min/MODE/max, not min/AVERAGE/max. If you really wanted an average of 12 minutes with a minimum of 3 and maximum of 60; then this is not a triangular distribution. There is no mode that would give you an average of 12.
Average from triangular, where X is the mode:
( 3 + X + 60 ) / 3 = 12
Means X would have to be negative - not possible for there to be a negative delay time for the mode.
Look at using a different distribution. Exponential is used often for time between failures (or poisson for failures per hour).

Find and Rank Time Series MATLAB

I know there must be a simple way that I can learn to do this but I cannot imagine how to start. I am tasked with finding a top 10 matching daily wind power time series in a 30-day plus/minus window from the first day in the time series (Jan 1st) matching a single daily wind power time series and it is out of my level of experience in MATLAB. I have successfully done this matching a single time series of the current year with the exact calendar days from previous years, but I need a more robust searching method to find the best correlated time series in a +/- window of time. For example, I'm comparing a 120 day time series (without leap years) with 25 previous years during the same 120-day period (Jan-Apr). The end result will show me the top 10 time series with the years and Julian day or cumulative day listed and a correlation or RMSE value associated with it. My data looks like this arranged in a 365 (days) X 25 (years) array and I thank you very much for your help!
1182573 470528 1638232 2105034 1070466 478257 1096999
879997 715531 1111498 1004556 1894202 1372178 1707984
636173 937769 2119436 742710 1625931 1275567 1228515
967360 1103082 2218855 1643898 1822868 554769 1325642

In MATLAB, is there a simple way to shift the X-axis by a constant offset in bar graphs?

I am generating a bar graph of something vs time of day (i.e., 24 hours). Later, my supervisor tells me that in the dataset, the time is offset by 8 hours, so 7 PM needs to become 3 AM, 12 midnight needs to become 8 AM, etc. In other words, the two axes should remain unaffected. Only the plots in the graph need to be made to shift towards the right by 8 hours (i.e., in a circular kind of pattern, where each value is offset by 8). So, is there a simple, single line function or something to do this in MATLAB? Thanks.
This is my code:
a=str2num(datestr(n(:,1)/86400,'HH'));
bar(histc(a,unique(a)))

I can not guess what happen in this two scenarios regarding Shift left?

Following two questions regarding the Shift Left is confusing me.
How many times would a suitable binary number be multiplied by if a Shift Left operation is performed on it five times?
Answer is 32.
How many times would a suitable number be
multiplied by if a Shift Left operation is performed on
it five times?
Answer is 16
Can some one please explain??
The answer is 32.
For example 2 (binary 10) shifted 5 times is 1000000 which is 64.

Sum last 52 elements without loop

Say I have a data set that has x-sections of country (US, CANADA) and then state/province then year then week. My data stack has 2 countries, 57 states/provinces, 3 years, and 52 weeks. I wanto to create a variable revenue that for each week, sums the last 52 weeks within the x-section.
Right now i have a loop but its very, very slow.
for each countries,
for each state,
for the last 2 years,
for each week,
sum the last 52 elements
Does anyone know how I can do this with vectorization?
You might want to look into using the function s=sum(X,DIM). Without more info about your dataset (please provide example), we cannot go into great detail.
For weighted sums over rolling window, filter() can work well.