Hi!

I would like to to solve a weekly problem on a daily basis and the results to be written in the right order/position of the week.

More specifically I have:

sets

t1 "hours_week" / 1 * 168/

t2(t1) "hours_day /1 * 24/ ;

Variable

X(i,t2) ;

Parameter

Xpar(i,t1) ;

then I solve the problem for the first day and I want the results X(i,t2) to be stored in Xpar in the right order:

Xpar(i,t1)$(ord(t1)=1 and ord(t1)<=24) = X.l(i,t2);

But I get the message "error 149 (Uncontrolled set entered as constant)".

Any ideas on how to overcome this issue?

Thank you very much in advance!

## Results in the right order/position of the week

### Re: Results in the right order/position of the week

Hi,

The "Uncontrolled set" refers to t2 which you are using on the right hand side of the assignment without controlling it.

You could either replace the ord() stuff by just using t2 on the left hand side as well
or you might want to declare variable X over super set t1 and then use t1 on the right hand side of your assignment
or just do both
I hope this helps!

Fred

The "Uncontrolled set" refers to t2 which you are using on the right hand side of the assignment without controlling it.

You could either replace the ord() stuff by just using t2 on the left hand side as well

Code: Select all

```
Xpar(i,t2) = X.l(i,t2);
```

Code: Select all

```
Variable X(i,t1) ;
[...]
Xpar(i,t1)$(ord(t1)=1 and ord(t1)<=24) = X.l(i,t1);
```

Code: Select all

```
Variable X(i,t1) ;
[...]
Xpar(i,t2) = X.l(i,t2);
```

Fred

### Re: Results in the right order/position of the week

Hi Fred,

Thank you for your prompt reply.

The problem arises with the second loop where I have to store the resuts of the second day of the variable X(i,t2) (where t2 is again between 1 and 24) in parameter Xpar(i,t1), in the right order. I would then like to do the following but unfortunately is not working:

Xpar(i,t1)$(ord(t1)=25 and ord(t1)<=48) = X.l(i,t2);

Is there any way to do that by avoiding solving my problem with X(i,t1) but instead using X(i,t2)?

Thanks again!

Thank you for your prompt reply.

The problem arises with the second loop where I have to store the resuts of the second day of the variable X(i,t2) (where t2 is again between 1 and 24) in parameter Xpar(i,t1), in the right order. I would then like to do the following but unfortunately is not working:

Xpar(i,t1)$(ord(t1)=25 and ord(t1)<=48) = X.l(i,t2);

Is there any way to do that by avoiding solving my problem with X(i,t1) but instead using X(i,t2)?

Thanks again!

### Re: Results in the right order/position of the week

Hi,

If I understand you correctly, you basically want to map 7 daily solutions of hours 1...24 to the hours of week 1...168

day1 1...24 --> 1..24

day2 1...24 --> 25..48

...

day7 1...24 --> 145..168

The following should do he trick:

I am not convinced that this is the best solution. Maybe you could solve your model for the correct set of hours directly instead of doing such a mapping afterwards. If you would be wiling to share your code, users might pick up on that and come up with more elegant suggestions.

Best,

Fred

If I understand you correctly, you basically want to map 7 daily solutions of hours 1...24 to the hours of week 1...168

day1 1...24 --> 1..24

day2 1...24 --> 25..48

...

day7 1...24 --> 145..168

The following should do he trick:

Code: Select all

```
set d days /d1*d7/;
loop(d,
* some solve statements that gives you X.l(i,t2)
Xpar(i,t1)$(ord(t1)>(ord(d)-1)*24 and ord(t1)<=(ord(d))*24) = sum(t2$(ord(t2)=ord(t1)-(ord(d)-1)*24), X.l(i,t2));
);
```

Best,

Fred

### Re: Results in the right order/position of the week

Fred thank you very much for your useful reply. It seems that it’s working.

In case that I got stuck again,I will revert and kindly ask.

Kind regards,

Bill

In case that I got stuck again,I will revert and kindly ask.

Kind regards,

Bill