Create Histograms

92 views
Skip to first unread message

Bernie Lindner

unread,
Jun 1, 2013, 5:37:19 AM6/1/13
to ai...@googlegroups.com
Hi 

I have tried reading and executing statements in Chapter 19.3: Creating Histograms [User Interface Language Components] but to no avail.
It seems a little too complex for me, can someone explain how to create and
 view data as a histogram in AIMMS (i.e. have the data and a graph) more basically (if this is possible)

For example I would like to analyse the data from the variable called Output(i) (i is the number of iterations).

Thanks
Bernie


Franco Peschiera

unread,
Jun 1, 2013, 6:03:25 AM6/1/13
to ai...@googlegroups.com
Hello Bernie,

Recently I had to build one for the first time. I agree: it's unreasonably complex. I am sharing the code I did for the histogram I built, hope it helps (maybe someone has a better example: mine is not exactly "standard").

To graph I used the 2D graph object with the pHistogramaResultado(iPoint) parameter i got from the procedure as if it were a normal identifier.

HistogramCreate(histogram_id : lpHistogramID);
lpHistogramIDPast:=lpHistogramID;
!Erase previous histograms:
while lpHistogramIDPast>1 do
HistogramDelete(lpHistogramIDPast);
lpHistogramIDPast-=1;
endwhile;
!sDataParaHistograma is the size of elements you have data for, the number of observations (x)
HistogramCreate(
histogram_id : lpHistogramID,
sample_buffer_size: card(sDataParaHistograma)*2);
!pEstDispersionConMedia is the value (y) of each iPoint (x)
For iPoint in sDataParaHistograma do
HistogramAddObservation(histogram_id : lpHistogramID,value : pEstDispersionConMedia(iPoint))
endfor;
!Define the minimum, the maximum, the interval-size and the width of each interval (this is an example)
if not p01DoubleIntervals then lpHistWidth:=0.01 else lpHistWidth:=0.005 endif;
lpHistMin:=-pHistLimites;
lpHistIntervals:=pHistLimites*2/lpHistWidth*0.01;
lpHistMax:=lpHistMin+lpHistWidth*(lpHistIntervals);
!define a set that has as elements the points in your x-domain in the histogram (example)
sHistograma:=ElementRange(lpHistMin*1000,lpHistMax*1000,lpHistWidth*1000);
!configure the histogram with the previously defined elements
HistogramSetDomain(lpHistogramID,width:lpHistWidth,left:lpHistMin, intervals:lpHistIntervals-1);
!get the values of each point y in the x-domain of the histogram (pHistogramaResultado has as index domain iHist in sHistograma).
HistogramGetFrequencies(histogram_id :lpHistogramID ,frequencies :pHistogramaResultado )



Franco Peschiera
Jefe de proyectos
baobab soluciones


Bernie


--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bernie Lindner

unread,
Jun 11, 2013, 5:57:43 AM6/11/13
to ai...@googlegroups.com
Thanks Franco

I will definitely look at code and try it out and let you know.

Bernie
Reply all
Reply to author
Forward
0 new messages