Optimisation Problem: Given some data calculate the correct value

Clash Royale CLAN TAG #URR8PPP up vote 0 down vote favorite I have a real world problem that I would like to solve. I think this problem is an optimisation one. But I am not sure, and I have never work with optimisation algorithms or formulas. I have 8 records of data: Start Date End Date Monday, Tuesday ... Sunday Values in milligrams Y So a single record is a range of dates that a patient took some medicine. The patient takes every day his medicine as indicated by the data above (3rd point). For example, 01/08/2018 15/08/2018 Monday: 4.5 milligram, Tuesday: 4.5 milligram, Wednesday: 5.0 milligram .... Sunday: 5.5 milligram. 2.46 Given the above data, start date, end date, milligram per day, this yields to the value of Y. I would like to calculate the milligram per day given a start, end dates and desired Y value. Although programmatically I was able to represent the problem and also to calculate the total medicine in milligram given the range of dates etc, I am strugglin...