{ From user Lonnie, Model Sum_between_challeng at 8-Apr-2016 2:44:39 PM, encoding="ascii" } SoftwareVersion 4.7.0 { System Variables with non-default values: } SampleSize := 1000 TypeChecking := 1 Checking := 1 SaveOptions := 2 SaveValues := 0 NodeInfo FormNode: 1,0,0,1,0,0,0,,0,0,,0,0 {!40700|AskAttribute CellFormatExpression,Variable,Yes} Model Sum_between_challeng Title: Sum-between challenge Description: In this challenge problem, you are to sum all the values in Daily_amount that occur on or between First_date and Last_date. The first and last dates, and the daily amounts, vary by person.~ ~ Your job is to fill in the one undefined variable with an expression that computes this sum.~ ~ You can view the result of Correct_solution to see if you've done it correctly. Author: Lonnie Date: Fri, Apr 8, 2016 2:13 PM SaveAuthor: Lonnie SaveDate: Fri, Apr 8, 2016 2:44 PM DiagState: 2,1,0,960,585,17 WindState: 2,683,429,720,350 FontStyle: Arial,15 FileInfo: 0,Model Sum_between_challeng,2,2,0,0,C:\Users\Lonnie\Documents\Analytica\Example Models\Sum-between challenge.ana Index Person Title: Person Definition: ['Alice','Bob','Carol','Dale','Enrique','Fred'] NodeLocation: 128,88,1 NodeSize: 48,24 {!40000|Att_PrevIndexValue: ['Alice','Bob','Carol','Dale','Enrique','Fred']} Variable First_date Title: First date Description: The date of the first daily amount to include in the sum. Definition: Table(Person)(1-Jan-2017,3-Feb-2017,8-Mar-2017,25-Apr-2017,22-Jun-2017,1-Aug-2017) NodeLocation: 248,88,1 NodeSize: 48,24 DefnState: 2,994,51,416,303,,DFNM DisplayOutputs: Variable Sum_between_first_an Index Date_idx Title: Date idx Description: All dates considered. Definition: Sequence(1-Jan-2017,31-Dec-2017) NodeLocation: 248,32,1 NodeSize: 48,24 DisplayOutputs: Variable Sum_between_first_an {!40000|Att_PrevIndexValue: [1-Jan-2017,2-Jan-2017,3-Jan-2017,4-Jan-2017,5-Jan-2017,6-Jan-2017,7-Jan-2017,8-Jan-2017,9-Jan-2017,10-Jan-2017,11-Jan-2017,12-Jan-2017,13-Jan-2017,14-Jan-2017,15-Jan-2017,16-Jan-2017,17-Jan-2017,18-Jan-2017,19-Jan-2017,20-Jan-2017,21-Jan-2017,22-Jan-2017,23-Jan-2017,24-Jan-2017,25-Jan-2017,26-Jan-2017,27-Jan-2017,28-Jan-2017,29-Jan-2017,30-Jan-2017,31-Jan-2017,1-Feb-2017,2-Feb-2017,3-Feb-2017,4-Feb-2017,5-Feb-2017,6-Feb-2017,7-Feb-2017,8-Feb-2017,9-Feb-2017,10-Feb-2017,11-Feb-2017,12-Feb-2017,13-Feb-2017,14-Feb-2017,15-Feb-2017,16-Feb-2017,17-Feb-2017,18-Feb-2017,19-Feb-2017,20-Feb-2017,21-Feb-2017,22-Feb-2017,23-Feb-2017,24-Feb-2017,25-Feb-2017,26-Feb-2017,27-Feb-2017,28-Feb-2017,1-Mar-2017,2-Mar-2017,3-Mar-2017,4-Mar-2017,5-Mar-2017,6-Mar-2017,7-Mar-2017,8-Mar-2017,9-Mar-2017,10-Mar-2017,11-Mar-2017,12-Mar-2017,13-Mar-2017,14-Mar-2017,15-Mar-2017,16-Mar-2017,17-Mar-2017,18-Mar-2017,19-Mar-2017,20-Mar-2017,21-Mar-2017,22-Mar-2017,23-Mar-2017,24-Mar-2017,25-Mar-2017,26-Mar-2017,27-Mar-2017,28-Mar-2017,29-Mar-2017,30-Mar-2017,31-Mar-2017,1-Apr-2017,2-Apr-2017,3-Apr-2017,4-Apr-2017,5-Apr-2017,6-Apr-2017,7-Apr-2017,8-Apr-2017,9-Apr-2017,10-Apr-2017,11-Apr-2017,12-Apr-2017,13-Apr-2017,14-Apr-2017,15-Apr-2017,16-Apr-2017,17-Apr-2017,18-Apr-2017,19-Apr-2017,20-Apr-2017,21-Apr-2017,22-Apr-2017,23-Apr-2017,24-Apr-2017,25-Apr-2017,26-Apr-2017,27-Apr-2017,28-Apr-2017,29-Apr-2017,30-Apr-2017,1-May-2017,2-May-2017,3-May-2017,4-May-2017,5-May-2017,6-May-2017,7-May-2017,8-May-2017,9-May-2017,10-May-2017,11-May-2017,12-May-2017,13-May-2017,14-May-2017,15-May-2017,16-May-2017,17-May-2017,18-May-2017,19-May-2017,20-May-2017,21-May-2017,22-May-2017,23-May-2017,24-May-2017,25-May-2017,26-May-2017,27-May-2017,28-May-2017,29-May-2017,30-May-2017,31-May-2017,1-Jun-2017,2-Jun-2017,3-Jun-2017,4-Jun-2017,5-Jun-2017,6-Jun-2017,7-Jun-2017,8-Jun-2017,9-Jun-2017,10-Jun-2017,11-Jun-2017,12-Jun-2017,13-Jun-2017,14-Jun-2017,15-Jun-2017,16-Jun-2017,17-Jun-2017,18-Jun-2017,19-Jun-2017,20-Jun-2017,21-Jun-2017,22-Jun-2017,23-Jun-2017,24-Jun-2017,25-Jun-2017,26-Jun-2017,27-Jun-2017,28-Jun-2017,29-Jun-2017,30-Jun-2017,1-Jul-2017,2-Jul-2017,3-Jul-2017,4-Jul-2017,5-Jul-2017,6-Jul-2017,7-Jul-2017,8-Jul-2017,9-Jul-2017,10-Jul-2017,11-Jul-2017,12-Jul-2017,13-Jul-2017,14-Jul-2017,15-Jul-2017,16-Jul-2017,17-Jul-2017,18-Jul-2017,19-Jul-2017,20-Jul-2017,21-Jul-2017,22-Jul-2017,23-Jul-2017,24-Jul-2017,25-Jul-2017,26-Jul-2017,27-Jul-2017,28-Jul-2017,29-Jul-2017,30-Jul-2017,31-Jul-2017,1-Aug-2017,2-Aug-2017,3-Aug-2017,4-Aug-2017,5-Aug-2017,6-Aug-2017,7-Aug-2017,8-Aug-2017,9-Aug-2017,10-Aug-2017,11-Aug-2017,12-Aug-2017,13-Aug-2017,14-Aug-2017,15-Aug-2017,16-Aug-2017,17-Aug-2017,18-Aug-2017,19-Aug-2017,20-Aug-2017,21-Aug-2017,22-Aug-2017,23-Aug-2017,24-Aug-2017,25-Aug-2017,26-Aug-2017,27-Aug-2017,28-Aug-2017,29-Aug-2017,30-Aug-2017,31-Aug-2017,1-Sep-2017,2-Sep-2017,3-Sep-2017,4-Sep-2017,5-Sep-2017,6-Sep-2017,7-Sep-2017,8-Sep-2017,9-Sep-2017,10-Sep-2017,11-Sep-2017,12-Sep-2017,13-Sep-2017,14-Sep-2017,15-Sep-2017,16-Sep-2017,17-Sep-2017,18-Sep-2017,19-Sep-2017,20-Sep-2017,21-Sep-2017,22-Sep-2017,23-Sep-2017,24-Sep-2017,25-Sep-2017,26-Sep-2017,27-Sep-2017,28-Sep-2017,29-Sep-2017,30-Sep-2017,1-Oct-2017,2-Oct-2017,3-Oct-2017,4-Oct-2017,5-Oct-2017,6-Oct-2017,7-Oct-2017,8-Oct-2017,9-Oct-2017,10-Oct-2017,11-Oct-2017,12-Oct-2017,13-Oct-2017,14-Oct-2017,15-Oct-2017,16-Oct-2017,17-Oct-2017,18-Oct-2017,19-Oct-2017,20-Oct-2017,21-Oct-2017,22-Oct-2017,23-Oct-2017,24-Oct-2017,25-Oct-2017,26-Oct-2017,27-Oct-2017,28-Oct-2017,29-Oct-2017,30-Oct-2017,31-Oct-2017,1-Nov-2017,2-Nov-2017,3-Nov-2017,4-Nov-2017,5-Nov-2017,6-Nov-2017,7-Nov-2017,8-Nov-2017,9-Nov-2017,10-Nov-2017,11-Nov-2017,12-Nov-2017,13-Nov-2017,14-Nov-2017,15-Nov-2017,16-Nov-2017,17-Nov-2017,18-Nov-2017,19-Nov-2017,20-Nov-2017,21-Nov-2017,22-Nov-2017,23-Nov-2017,24-Nov-2017,25-Nov-2017,26-Nov-2017,27-Nov-2017,28-Nov-2017,29-Nov-2017,30-Nov-2017,1-Dec-2017,2-Dec-2017,3-Dec-2017,4-Dec-2017,5-Dec-2017,6-Dec-2017,7-Dec-2017,8-Dec-2017,9-Dec-2017,10-Dec-2017,11-Dec-2017,12-Dec-2017,13-Dec-2017,14-Dec-2017,15-Dec-2017,16-Dec-2017,17-Dec-2017,18-Dec-2017,19-Dec-2017,20-Dec-2017,21-Dec-2017,22-Dec-2017,23-Dec-2017,24-Dec-2017,25-Dec-2017,26-Dec-2017,27-Dec-2017,28-Dec-2017,29-Dec-2017,30-Dec-2017,31-Dec-2017]} Variable Last_date Title: Last date Description: The last date of daily amount to include in the sum. Definition: Table(Person)(10-Aug-2017,1-Jun-2017,24-Mar-2017,31-Oct-2017,23-Nov-2017,20-Aug-2017) NodeLocation: 376,88,1 NodeSize: 48,24 DefnState: 2,1087,416,416,303,,DFNM DisplayOutputs: Variable Sum_between_first_an Variable Daily_amount Title: Daily amount Description: The amount on each day, which is to be partially summed. Definition: Table(Person,Date_idx)(~ 88,26,46,16,46,58,100,25,54,31,12,63,62,33,42,10,29,89,42,48,77,44,19,70,76,95,53,20,59,53,99,59,30,87,27,100,3,17,50,11,16,39,74,44,11,96,35,18,41,100,15,95,89,1,96,75,91,82,42,97,75,80,29,47,96,19,83,66,96,59,21,44,22,8,89,31,66,54,57,43,12,32,57,92,97,35,82,27,98,8,86,44,91,36,86,55,76,32,29,82,75,61,58,1,52,25,91,66,91,93,36,19,18,32,13,50,56,47,54,47,54,50,47,89,45,12,18,78,59,67,97,27,4,11,22,99,44,0,35,14,30,71,68,99,5,5,31,78,80,43,37,57,62,5,28,12,60,94,68,23,17,6,83,42,66,6,73,15,52,54,16,24,21,48,54,9,3,20,24,56,44,26,76,77,45,98,51,99,10,27,87,38,9,82,22,89,81,59,72,8,78,63,64,28,99,76,53,85,11,75,93,94,49,5,95,56,20,43,27,72,5,60,64,86,42,32,61,36,7,27,81,15,78,92,8,49,0,53,57,26,26,20,37,85,64,9,12,1,60,14,18,60,51,52,46,40,34,17,62,81,81,93,52,12,0,50,71,96,35,2,22,95,28,15,59,94,28,21,100,94,84,49,91,16,91,34,84,12,64,15,29,0,49,16,40,72,18,11,42,33,77,65,66,88,32,51,47,24,8,51,61,68,65,13,63,96,51,19,4,4,76,95,34,53,3,9,61,47,7,58,60,3,87,16,75,65,89,35,63,7,55,83,22,84,67,78,54,88,18,92,28,65,42,13,67,42,63,20,63,86,14,90,22,63,37,~ 66,33,66,33,82,95,14,5,90,24,22,47,43,62,12,39,39,30,93,52,6,16,43,65,93,20,58,71,56,92,43,87,19,79,7,31,48,87,91,85,9,4,82,48,25,12,0,91,16,53,70,70,45,6,64,20,38,26,15,58,69,64,49,80,78,48,54,98,16,33,71,9,47,91,52,88,79,75,99,42,77,25,30,15,33,76,47,15,79,94,45,15,48,52,24,100,93,60,40,21,90,36,75,96,27,77,17,14,95,54,60,13,48,70,16,94,25,37,82,93,40,65,89,67,78,97,49,16,72,72,31,50,88,14,46,83,84,41,17,3,0,74,52,61,76,33,97,97,52,31,28,42,49,26,41,5,39,30,61,6,36,47,77,83,31,85,12,85,44,25,81,92,74,10,5,74,64,58,74,81,5,34,40,77,21,43,22,4,79,27,52,96,59,50,21,31,13,10,32,10,94,62,39,95,99,78,100,27,60,83,50,92,74,38,25,92,2,64,9,41,40,48,55,78,94,81,76,63,39,56,41,13,17,97,98,97,69,24,96,31,11,86,90,10,61,45,1,0,6,42,20,49,57,73,17,85,71,34,73,83,46,38,75,25,26,93,75,56,59,1,1,61,31,69,58,56,39,24,26,19,36,66,66,96,39,4,46,43,56,47,64,66,56,5,99,76,63,15,17,59,63,47,22,29,66,1,42,87,78,12,89,77,27,9,90,92,95,41,75,63,11,58,69,99,46,61,98,33,14,61,39,59,20,40,89,59,30,13,63,0,69,3,32,73,36,0,80,11,34,48,73,50,29,47,89,52,87,47,17,30,23,62,52,67,22,~ 41,18,69,75,17,4,5,60,0,66,4,69,50,89,21,94,43,75,33,89,34,48,78,63,21,68,5,80,26,12,1,69,23,51,51,8,50,63,3,70,72,58,10,52,10,19,22,44,55,65,4,91,49,38,15,29,11,77,87,85,49,90,52,47,16,46,3,2,4,37,62,37,5,7,53,76,70,41,99,95,80,67,30,55,21,57,16,16,91,89,47,19,28,11,80,88,33,96,96,60,61,51,56,36,18,62,61,59,43,25,17,100,44,35,57,86,95,35,35,7,15,26,47,97,87,10,90,27,96,26,36,13,5,28,63,30,86,0,88,10,85,15,67,6,34,9,55,46,73,82,0,27,56,53,82,82,94,58,55,43,45,31,41,14,82,14,36,15,3,10,81,96,41,19,71,61,99,52,83,96,32,95,54,58,53,48,50,4,31,58,17,41,84,35,97,15,96,20,11,4,8,55,50,100,39,95,88,16,35,55,60,94,64,1,35,66,13,22,85,33,85,50,26,30,55,60,96,75,71,1,5,81,5,7,79,48,100,45,74,83,80,42,87,61,100,77,63,1,20,22,22,86,25,96,5,45,64,93,70,8,79,49,13,39,87,79,47,6,82,2,24,19,0,68,88,62,6,23,1,11,27,65,94,70,67,69,70,99,44,40,25,37,80,27,18,31,18,0,22,17,72,70,4,48,8,18,48,5,28,94,52,29,9,22,78,0,40,57,98,50,16,10,58,77,20,22,18,74,28,61,77,7,74,28,26,2,97,56,6,92,23,36,64,86,82,36,8,5,26,83,96,72,76,41,77,17,85,73,94,49,92,10,14,83,93,~ 27,36,27,11,88,98,24,29,20,77,68,46,77,80,69,76,76,32,12,34,83,29,86,14,59,46,52,45,58,87,99,81,96,4,50,0,82,86,10,100,88,60,59,14,62,23,24,19,29,86,87,30,7,0,72,49,99,59,63,55,88,2,23,93,32,26,4,100,5,31,14,47,92,97,88,10,95,42,97,70,55,90,61,100,52,84,60,98,38,52,3,52,37,81,57,57,59,34,32,78,91,58,85,95,85,72,44,47,71,47,95,57,57,72,46,32,74,64,10,15,87,59,88,65,62,15,39,57,6,22,51,84,55,60,14,42,31,90,51,17,61,25,98,33,55,13,47,7,36,27,22,35,51,60,39,57,70,78,80,9,7,29,43,24,5,76,2,47,64,99,62,51,72,98,56,25,21,48,30,73,96,100,23,54,100,74,70,6,94,65,80,15,9,32,52,79,93,98,99,19,42,43,75,87,97,47,63,4,19,62,23,92,10,59,84,76,66,27,91,78,0,52,38,13,52,30,87,67,39,2,27,97,53,25,83,45,9,72,2,20,92,46,97,84,48,88,2,22,56,96,2,51,31,86,73,39,97,87,77,97,38,34,45,60,93,17,56,72,98,30,57,66,40,32,84,88,88,60,22,100,57,75,95,5,99,68,67,64,92,64,16,99,45,37,19,40,9,5,38,6,63,23,8,35,27,66,43,88,44,76,78,30,65,80,59,11,38,25,37,8,87,78,36,59,41,42,90,55,20,17,1,30,98,23,18,74,17,51,79,75,79,88,73,14,20,99,0,47,6,73,3,21,97,41,7,31,84,61,65,73,91,79,18,66,61,~ 8,25,21,89,8,2,45,76,34,16,95,40,63,65,62,89,12,19,7,90,49,48,99,43,27,60,1,58,58,14,6,55,66,56,4,82,79,56,31,73,50,52,11,20,23,15,75,38,86,10,30,6,16,17,87,13,16,43,58,13,92,77,63,50,20,48,28,81,37,71,91,29,23,21,57,47,86,53,2,53,63,83,98,60,56,16,14,84,39,87,12,65,40,47,100,93,16,14,47,52,76,91,76,17,96,75,83,9,19,32,31,87,72,80,43,0,9,48,100,28,37,9,4,5,89,62,34,35,78,53,35,18,68,20,5,54,16,30,11,0,8,91,11,33,27,35,46,50,15,72,55,15,89,32,19,98,10,59,13,9,35,14,20,70,96,35,10,37,88,96,0,14,100,46,60,87,23,20,35,60,16,47,22,21,52,71,84,29,4,85,44,84,32,66,36,52,96,7,45,3,2,49,15,31,65,4,48,13,8,23,41,23,46,17,84,82,1,12,59,16,17,2,84,16,65,30,17,79,69,39,64,65,88,0,100,98,51,14,44,43,83,29,18,83,51,24,12,99,83,64,90,96,48,30,79,41,82,21,39,100,89,23,97,80,31,51,15,96,94,26,81,94,46,30,7,32,8,27,93,35,18,69,64,84,99,38,46,17,55,23,79,96,48,55,94,9,59,81,14,100,96,9,48,67,54,22,0,45,49,86,36,39,97,51,24,35,85,29,7,78,53,28,34,94,38,8,92,30,88,19,84,11,60,79,21,37,49,7,93,72,22,82,29,2,11,80,45,37,6,12,65,18,73,24,86,71,30,99,49,46,27,36,72,34,67,~ 75,67,26,51,13,69,11,61,100,30,63,65,2,19,100,32,69,33,77,83,88,25,95,92,95,17,5,80,6,54,25,76,68,39,34,9,59,59,19,26,70,85,73,3,72,46,30,53,45,31,33,68,63,30,7,50,97,92,42,13,78,10,28,9,0,89,8,87,4,87,14,31,32,55,33,20,8,39,45,2,28,74,78,39,78,47,27,0,56,40,53,75,51,87,0,63,62,60,22,43,74,1,75,35,60,30,80,85,53,89,12,80,76,89,17,89,72,70,83,28,83,19,82,52,89,89,0,41,54,92,66,65,81,34,11,26,72,77,0,52,93,44,58,90,63,49,28,58,61,64,31,46,76,29,8,51,99,93,8,46,42,35,93,75,50,29,1,4,75,88,8,38,16,8,70,26,46,79,80,100,62,95,100,51,23,95,9,17,2,0,60,86,56,76,96,0,19,10,94,0,70,19,71,28,57,99,64,21,68,86,94,79,29,19,25,58,82,24,57,42,14,66,14,59,70,4,0,79,52,43,37,99,33,96,94,89,94,53,90,16,76,67,83,57,84,58,7,83,36,9,85,51,100,54,24,98,19,56,20,86,48,0,38,84,13,70,39,93,32,25,26,74,11,73,62,58,27,51,75,41,32,12,17,55,82,71,5,25,67,79,11,83,86,43,30,48,22,52,30,11,59,85,99,28,51,80,58,80,12,50,60,97,20,7,89,31,76,32,37,66,78,25,32,3,78,90,6,9,82,14,9,7,82,32,11,94,89,47,55,100,8,40,88,12,55,22,19,49,66,56,50,83,94,80,40,100,5,84,47,83,63,73,97,75,15) NodeLocation: 248,160,1 NodeSize: 48,24 WindState: 2,584,354,720,350 DefnState: 2,986,413,591,254,,DFNM ValueState: 2,169,469,980,269,,MIDM NumberFormat: 2,I,4,2,1,1,4,0,$,0,"ABBREV",0,,,0,0 DisplayOutputs: Variable Sum_between_first_an {!40700|CellFormatExpression: if First_date <= Date_idx <= Last_date then ~ CellFormats( ~ CellFill('Green', 0.1),~ CellBorder('Solid',2,'Outer',Person,Date_idx,'Green')~ )} Variable Sum_between_first_an Title: Sum between first and last Description: The sum of daily amount falling on or between the first date and last date. NodeLocation: 376,160,1 NodeSize: 56,32 WindState: 2,848,473,720,350 NumberFormat: 2,I,4,2,1,1,4,0,$,0,"ABBREV",0,,,0,0 DisplayInputs: Variable First_date, Index Date_idx, Variable Last_date, Variable Daily_amount Text Te1460150555 Title: ллл Fill in Definition for this one NodeLocation: 584,164,-1 NodeSize: 152,12 Variable Correct_solution Title: Correct solution Description: This shows a solution. There are also a few other reasonable variations, such as:~ ~ Sum( If First_date <= Date_idx And Date_idx <= Last_date~ Then Daily_amount ~ Else 0, ~ Date_idx ) Definition: Sum( (First_date <= Date_idx <= Last_date) * Daily_amount, Date_idx ) NodeLocation: 376,288,1 NodeSize: 72,32 NodeInfo: 1,0,1,1,1,1,0,,0,,0 WindState: 2,175,455,720,350 ValueState: 2,494,495,416,303,,MIDM NumberFormat: 2,I,4,2,1,1,4,0,$,0,"ABBREV",0,,,0,0 Close Sum_between_challeng