parameters depending from variables.

19 views
Skip to first unread message

Andrea Di Taranto

unread,
Oct 9, 2017, 4:01:52 AM10/9/17
to AMPL Modeling Language
Hello.
I am writing to know if it is possible to create a parameter which value depends from the value of a variable. I'd like to have a parameter referred to a prduct j which value is 1 if the variable referred to product j is 1, if the variable is 2 the parameter value should be 10, if the variable is 3 the parameter value should be 100 and so on.

Briefly, in my problem the variable counts how many time a product j is produced in a given span of days.
The objective function aims to minimize the total cost production, but also to minimize the number of times each product is produced in the given span of days (I prefer two products produced only one time, instead of one product produced two times and a product not produced. Again I prefer two products produced two times intead of one product produced four times and another product not produced at all. Each product must be produced as little as possible).
I thought to insert in the objective function a sort of penalty based on a parameter that is higher and higher if the product j is produced more than one time.
Thank you in advice for any suggestion.

Robert Fourer

unread,
Oct 10, 2017, 10:40:44 AM10/10/17
to am...@googlegroups.com
Parameters in a model represent data values that are known before the optimization of the variables. Thus a model parameter cannot be a function of a variable. It is necessary to use a variable to represent a penalty function of another variable -- or else to write the expression for the penalty function as part of your objective function.

It appears that the penalty function you have in mind is 10^(x[j]-1), where x[j] is the amount produced. This will introduce a significant nonlinearity into your objective, however. You might consider instead some constant times x[j]^2, which introduces a convex quadratic function that can be handled even by many "linear" solvers.

Bob Fourer
am...@googlegroups.com

=======

Andrea Di Taranto

unread,
Oct 11, 2017, 3:55:11 AM10/11/17
to AMPL Modeling Language
Thank you Robert!
I am trying to solve this problem changing a bit the penalty function and using Piecewise-Linear program as suggested in chapter 17 of the AMPL handbook.
Reply all
Reply to author
Forward
0 new messages