How to consider only parts of the whole planning period in objective function?

80 views
Skip to first unread message

xubwa...@gmail.com

unread,
Apr 9, 2019, 8:32:25 AM4/9/19
to AIMMS - The Modeling System
Dear all,

I have constructed a stochastic model and have an objective function as following:

09-04-2019 14-16-07.png












In this function, two kinds of holding costs(HY & HA) are only considered for part of the whole planning period, that is, the whole planning period is from 1 to LTP+M, but the two costs are only considered from 1 to M. For example, the whole planning period are from t=1 to t=6, but these two holding costs(HY & HA) are considered only from t=1 to t=3. How can I put such an objective function into AIMMS, when trying to solve the model using AIMMS?

I am new to AIMMS and have a project to be completed in urgent.... Could someone help me on this? Thank you very much!!


Best regards,
Xubo

mateus.n...@unisoma.com

unread,
Apr 9, 2019, 10:14:48 AM4/9/19
to AIMMS - The Modeling System
Hi, Xubo.

You could use subset to represent different planning periods within the sum:

OF.png


where

t_index is the index of set "t":


set_t.png



and subset_t_index is the index of set "subset_t":

subset_t.png




Hope it helps.

Xubo Wang

unread,
Apr 9, 2019, 11:12:36 AM4/9/19
to ai...@googlegroups.com
Hi Mateus,

Thanks for your help!
I tried your method, but it returns "The data type numeric expression "LTP+M"cannot be turned into an element valued expression"... What should I do?.....


Best,
Xubo

--
You received this message because you are subscribed to the Google Groups "AIMMS - The Modeling System" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aimms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aimms/2b348fc9-fa16-4fbb-b232-dafa412155fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohan

unread,
Apr 9, 2019, 12:50:43 PM4/9/19
to AIMMS - The Modeling System
Hi Xubo,

For that set definition, you can use the ElementRange function as well.

ElementRange(1, LPT+M, 1) will generate set elements {1, 2, 3, .. LPT+M}.

In your example, M = 3, and LPT = 3 so LPT+M = 6.

Instead of having to create subsets, you can also simply use index domain conditions in the sum function.

sum[t | t <= 3, HA(t) + HY(t)] + sum[t, OtherTerm(t)]

The first term will will be summed only for values of t <= 3, whereas the second term will be summed for all values of t.

Hope this helps.

On Tuesday, April 9, 2019 at 8:12:36 AM UTC-7, Xubo Wang wrote:
Hi Mateus,

Thanks for your help!
I tried your method, but it returns "The data type numeric expression "LTP+M"cannot be turned into an element valued expression"... What should I do?.....


Best,
Xubo

To unsubscribe from this group and stop receiving emails from it, send an email to aimms+unsubscribe@googlegroups.com.

mateus.n...@unisoma.com

unread,
Apr 10, 2019, 3:41:15 AM4/10/19
to AIMMS - The Modeling System
Hi Xubo,

Did you set "t" as subset of Integers? Are LTP and M integer parameters?
To unsubscribe from this group and stop receiving emails from it, send an email to ai...@googlegroups.com.

xubwa...@gmail.com

unread,
Apr 11, 2019, 3:44:28 AM4/11/19
to AIMMS - The Modeling System
Hi Mohan,

It works! Thank you so much for your help! 

And I would like to ask further, that is:
unnamed.png

like the above two constraints, so similarly I can write "(s,b,t) | 1<=t<=LTP" in the index domain area to set the time period of the first constraint as from t=1 to t=LTP, is this correct?
does it also work for variables when that variable only exist in part of the whold planning period?

Thanks!


Best regards,
Xubo


To unsubscribe from this group and stop receiving emails from it, send an email to ai...@googlegroups.com.

xubwa...@gmail.com

unread,
Apr 11, 2019, 9:28:09 AM4/11/19
to AIMMS - The Modeling System
Hi Mateus,

I forgot to set them... now it works! Thank you so much!


Best,
Xubo

Mohan

unread,
Apr 11, 2019, 2:36:45 PM4/11/19
to AIMMS - The Modeling System
Hi Xubo,

Yes, you can write your constraint like that. If the set t starts from 1, you need not write 1<= t, it will automatically start for t.

If 1 <= t <= Lt is not accepted as a syntax, you can simply write t >= 1 and t <= Lt.

You can do the same for variables - you simply add this condition in the index domain of the variable. Suppose you have a variable Var(l, t) - this would be like the below in AIMMS.

Name: Var
Index domain: (l, t).



Update the index domain like below.

Index domain: (l, t) | t in PlanningPeriod



where Planning Period is a subset of the set T in planning.

xubwa...@gmail.com

unread,
Apr 12, 2019, 3:44:11 AM4/12/19
to AIMMS - The Modeling System
Hi Mohan,

Actually I set t from 0, so 1<=t is necessary for me.... 

Your guide is very helpful... just I want to further ask, so for Parameters, if I also want to restraint them to part of the whole planning period, the method for Variables suits, rather than the method for Constraints, is that correct? 

like, 

Name: Parameter
Index domain: tin PlanningPeriod
 
where Planning Period is a subset of the set T in planning.


And, why are the methods of explaining part of the period different for Constraints and Variables in AIMMS?

Hope my silly questions don't make you feel annoyed...

Thank you!!!


Best regards,
Xubo

Mohan

unread,
Apr 12, 2019, 3:06:22 PM4/12/19
to AIMMS - The Modeling System
Hi Xubo,

Yes, you can use the same method for parameters as well.

If you need to use this 1<=t<=Lt condition in multiple places, then it will be better if you create a Subset of t, say sub_T with definition {t | 1<=t <= Lt} and use the index of this subset in your variable, constraint and parameter declarations. If index is sub_t, then you variable will become Var(l, sub_t) instead of Var(l, t)| t >= 1 and t<= Lt.

Not sure what you mean by the difference in Constraints and Variables, can you elaborate ?

You can use the domain conditions ( | t >= 1 and t<= Lt for example) in the Index domain of constraints as well. In the discussion above, the constraint part was about a sum inside the constraint definition and not the constraint itself.

xubwa...@gmail.com

unread,
Apr 25, 2019, 8:42:35 AM4/25/19
to AIMMS - The Modeling System
Hello Mohan,

Sorry that I think I was just confused by the different ways of setting conditions to the variable, like sometimes we can use t | t<=3, but sometimes we should use t | t in PlanningPeriod....

Thank you!!


Regards,
Xubo
Reply all
Reply to author
Forward
0 new messages