No explicit loop is needed:

@defVar(m, inf[i]<= pt[i=1:hmax] <=sup[i], SemiCont)

They keyword SemiCont means that the variable can be either equal to zero 
or fall within the given bounds.
Be sure to use a solver which supports this class of variables (Gurobi or 
CPLEX). 

On Monday, March 30, 2015 at 8:01:19 PM UTC-4, Michela Di Lullo wrote:
>
>
>
> Il giorno lunedì 30 marzo 2015 21:45:13 UTC+2, Miles Lubin ha scritto:
>>
>> Hi Michela, 
>>
>
>> It looks like you're referring to JuMP, in which case:
>>
>> @defVar(m, a <= x <= b, SemiCont)
>>
>> should do the trick. See also the documentation: 
>> http://jump.readthedocs.org/en/release-0.8/refvariable.html?highlight=semicontinuous
>>
>> We prefer to direct optimization-related questions to julia-opt 
>> <https://groups.google.com/forum/#!forum/julia-opt>, for future 
>> reference.
>>
>> Best,
>> Miles
>>
>> On Monday, March 30, 2015 at 3:36:15 PM UTC-4, Kevin Squire wrote:
>>>
>>> Hi Michela,
>>>
>>> I think you're going to need to provide some additional information.  
>>> Are you modeling this in JuMP by chance?  
>>>
>>> Cheers,
>>>    Kevin
>>>
>>> On Mon, Mar 30, 2015 at 12:25 PM, Michela Di Lullo <
>>> [email protected]> wrote:
>>>
>>>> Hallo everyone! 
>>>>
>>>> how do I model a variable (array of variables) that can either be zero 
>>>> or in some range not containing zero?  
>>>> e.g. x∈0∪[a,b] where a>0
>>>>
>>>> Thank you in advance for any information!
>>>>
>>>
>>>> Michela
>>>>
>>>
>>>
> Yes, exactly..
> I'm working with JuMP. 
>
> I need to model a matrix of semicontinuos power variables p[i,j] that 
> assume values in *0 union [pt_min,pt_max]*
> In other words it's: 
>
> for i=1:gmax
>
> {@defVar(m, inf[i]<= pt[1:hmax] <=sup[i], SemiCont)}
>
> end 
> but pt can also be equal to 0 !!
> How do I model it? 
>
> Thanks to anyone will answer 
>

Reply via email to