|
From: | Mate Hegyhati |
Subject: | Re: Defining a variable of mixed datatype in Mathprog |
Date: | Tue, 15 Mar 2022 10:13:18 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
Hi!I'd assume, that the language does not support something like this. Others will tell if I'm wrong.
I don't know your special use-case, but I'd generally speak against such a practice. It seems cleaner if one knows whether a variable is integer or not.
However, if this would make the rest of the model cleaner, and it is more important than efficiency, you can always do this:
set intset; set contset; set all := intset union contset; var intvar {intset} integer; var mixedvar {all} >=0; s.t. foobar{i in intset}: intvar[i] = mixedvar[i];I thought that the presolver would maybe kick in and remove the unnecessary variables, but it doesn't seem to do so. (v4.65)
I haven't tried commercial solvers, but I'd assume they do. All the best! Mate On 2022. 03. 15. 7:26, Anku Pandey wrote:
Hi,I have to formulate a problem in mathprog where a variable can be both integer type and continuous type based on index.Let me give an example to further illustrate this. I have two sets of items: set itemInteger; set itemContinuous;I need to define a variable, awardQuantity, on these sets so that for items in the set itemInteger, it is of type Integer and for items in set itemContinuous, it is of type continuous.I know I can define two different variables: var awardQuantityInt[i in itemInteger], integer; var awardQuantityCont[i in itemContinuous]; But that is not what I am looking for. I want a single variable handling both types.I would really appreciate it if I can get some help on it. I have been trying to find an answer to this for a few days now.Thanks, Anku
[Prev in Thread] | Current Thread | [Next in Thread] |