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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
<?xml version="1.0" encoding="UTF-8"?>
<!--

 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab

 * Copyright (C) Scilab Enterprises - 2012 - Paul Bignier

 *

 * Copyright (C) 2012 - 2016 - Scilab Enterprises

 *

 * This file is hereby licensed under the terms of the GNU GPL v2.0,

 * pursuant to article 5.3.4 of the CeCILL v.2.1.

 * This file was originally licensed under the terms of the CeCILL v2.1,

 * and continues to be available under such terms.

 * For more information, see the COPYING file which you should have received

 * along with this program.

 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg"  xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en_US" xml:id="Comparisons">
    <refnamediv>
        <refname>Comparisons</refname>
        <refpurpose>
            This page compares solvers to determine which one is best fitted for the studied problem.
        </refpurpose>
    </refnamediv>
    <refsection>
        <title>Introduction</title>
        <para>
            Following the type of problem, finding out which method to use is not always obvious, only general guidelines can be established. Those are discussed in this page.
        </para>
        <title>Variable-size and Fixed-size</title>
        <para>
            The solvers can be divided into two distinct main families: the <emphasis>Variable</emphasis>-size and the <emphasis>Fixed</emphasis>-size step methods.
        </para>
        <para>
            They both compute the next simulation time as the sum of the current simulation time and a quantity known as the step size, which is constant in the Fixed-size solvers and can change in the Variable-size ones, depending on the model dynamics and the input <link linkend="Simulatemenu_Menu_entries">tolerances</link>.
        </para>
        <para>
            If looking for stable computation time, the user should select a Fixed-size step solver, because the computation overhead for a Variable-size step method cannot be properly predicted.
        </para>
        <para>
            Although for a simple problem (or loose tolerances) a Variable-size solver can significantly improve the simulation time by computing bigger step sizes, a Fixed-size method is preferable if the ideal step size is known and roughly constant (the user should then mention it in <link linkend="Simulatemenu_Menu_entries">max step size</link>).
        </para>
        <para>
            <!--<informaltable border="1">

                <tr>

                    <td align="center">

                        <emphasis role="bold">Variable</emphasis>

                    </td>

                    <td align="center">

                        <emphasis role="bold">Fixed</emphasis>

                    </td>

                </tr>

                <tr>

                    <td> LSodar </td>

                    <td> Runge-Kutta </td>

                </tr>

                <tr>

                    <td> CVode </td>

                    <td> Dormand-Prince </td>

                </tr>

                <tr>

                    <td> IDA </td>

                    <td> Implicit Runge-Kutta </td>

                </tr>

            </informaltable>-->
            <emphasis role="bold">Variable</emphasis>-size step solvers:
            <simplelist>
                <member>LSodar</member>
                <member>CVode</member>
                <member>IDA</member>
            </simplelist>
            <emphasis role="bold">Fixed</emphasis>-size step solvers:
            <simplelist>
                <member>Runge-Kutta 4(5)</member>
                <member>Dormand-Prince 4(5)</member>
                <member>Implicit Runge-Kutta 4(5)</member>
                <member>Crank-Nicolson 2(3)</member>
            </simplelist>
        </para>
        <para>
            Variable step-size ODE solvers are not appropriate for deterministic real-time applications because the computational overhead of taking a time step varies over the course of an application.
        </para>
        <title>Explicit and Implicit - Stiffness</title>
        <para>
            Within these two families, we can distinguish <emphasis>Explicit</emphasis> solvers from <emphasis>Implicit</emphasis> ones.
        </para>
        <para>
            While <emphasis>explicit</emphasis> methods only use data available on the current step, the <emphasis>implicit</emphasis> ones will attempt to compute derivatives at further times. In order to do this, they use nonlinear solvers such as fixed-point iterations, functional iterations (nonstiff) or modified Newton methods (stiff).
        </para>
        <para>
            The family choice is usually determined by the <emphasis>stiffness</emphasis> of the problem, which is, when there is a big gap between the biggest and the smallest eigen values modules of the jacobian matrix (when it is ill-conditioned). It is generally a system that is sensitive to discontinuities, meaning that the required precision is not constant.
        </para>
        <para>
            <emphasis role="bold">Implicit</emphasis> solvers:
            <simplelist>
                <member>LSodar</member>
                <member>CVode</member>
                <member>IDA</member>
                <member>Implicit Runge-Kutta 4(5)</member>
                <member>Crank-Nicolson 2(3)</member>
            </simplelist>
            <emphasis role="bold">Explicit</emphasis> solvers:
            <simplelist>
                <member>Runge-Kutta 4(5)</member>
                <member>Dormand-Prince 4(5)</member>
            </simplelist>
        </para>
        <para>
            To put it simply, the <emphasis>Explicit</emphasis> go straight to a computation of the solution, whereas the <emphasis>Implicit</emphasis> concentrate on stability, involving more operations, following the tolerances.
        </para>
        <title>So how to choose?</title>
        <para>
            Because it is not possible to know for sure whether a solver will be efficient for a given system or not, the best way is to run the most probable one on it and to compare their results.
        </para>
        <para>
            The user should first establish the complexity of his problem (stability / stiffness) and if he desires high precision, rapid simulation, predictable time or an automated program.
            <para>
                <emphasis role="bold">Precision:</emphasis> <emphasis>CVode</emphasis>,
            </para>
            <para>
                <emphasis role="bold">Predictable time:</emphasis> Fixed-size step,
            </para>
            <para>
                <emphasis role="bold">Simulation time:</emphasis> <emphasis>LSodar</emphasis>,
            </para>
            <para>
                <emphasis role="bold">Automated:</emphasis> <emphasis>LSodar</emphasis>.
            </para>
        </para>
    </refsection>
    <refsection>
        <title>Examples - ODEs</title>
        <para>
            We will begin with a simple nonstiff example: a Sine integration.
        </para>
        <para>
            <link type="scilab" linkend="scilab.xcos/xcos/examples/solvers/ODE_Example.zcos">
                <inlinemediaobject>
                    <imageobject>
                        <imagedata align="center" fileref="../../../examples/solvers/ODE_Example.zcos" valign="middle"/>
                    </imageobject>
                </inlinemediaobject>
            </link>
            <scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/examples/solvers/ODE_Example.zcos");
scs_m.props.tol(6) = 0;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
        </para>
        <para>
            In the following script, we compare the time difference between the solvers by running the example with the nine solvers in turn (<emphasis>IDA</emphasis> doesn't handle this kind of problem):
            <link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchSine.sce">
                Open the script
            </link>
        </para>
        <para>
            The Scilab console displays:
            <screen><![CDATA[
Time for LSodar:
 10.1

Time for CVode BDF/Newton:
 31

Time for CVode BDF/Functional:
 30

Time for CVode Adams/Newton:
 17.211

Time for CVode Adams/Functional:
 16.305

Time for Dormand-Prince:
 12.92

Time for Runge-Kutta:
 7.663

Time for implicit Runge-Kutta:
 10.881

Time for Crank-Nicolson:
 7.856
            ]]></screen>
        </para>
        <para>
            These results show that on a nonstiff problem and for same precision required, <emphasis>Runge-Kutta</emphasis> is fastest.
        </para>
        <para>
            In spite of the computational overhead of the step size, <emphasis>LSodar</emphasis> is not too distant from the Fixed-size solvers because it is able to take long steps.
        </para>
        <para>
            From the results, we can extract speed factors and set the following table:
        </para>
        <para>
            <informaltable border="1">
                <tr>
                    <td align="center"> </td>
                    <td align="center">
                        <emphasis>BDF / Newton</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>BDF / Functional</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Adams / Newton</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Adams / Functional</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Dormand-Prince</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Runge-Kutta</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Implicit Runge-Kutta</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Crank-Nicolson</emphasis>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>LSodar</emphasis>
                    </td>
                    <td align="center"> 3.1x </td>
                    <td align="center"> 3x </td>
                    <td align="center"> 1.7x </td>
                    <td align="center"> 1.6x </td>
                    <td align="center"> 1.3x </td>
                    <td align="center"> 0.75x </td>
                    <td align="center"> 1.08x </td>
                    <td align="center"> .07x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>BDF / Newton</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.6x </td>
                    <td align="center"> 0.5x </td>
                    <td align="center"> 0.4x </td>
                    <td align="center"> 0.25x </td>
                    <td align="center"> 0.35x </td>
                    <td align="center"> 0.23x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>BDF / Functional</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.6x </td>
                    <td align="center"> 0.5x </td>
                    <td align="center"> 0.4x </td>
                    <td align="center"> 0.25x </td>
                    <td align="center"> 0.4x </td>
                    <td align="center"> 0.24x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Adams / Newton</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.9x </td>
                    <td align="center"> 0.75x </td>
                    <td align="center"> 0.45x </td>
                    <td align="center"> 0.6x </td>
                    <td align="center"> 0.42x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Adams / Functional</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.8x </td>
                    <td align="center"> 0.5x </td>
                    <td align="center"> 0.7x </td>
                    <td align="center"> 0.45x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Dormand-Prince</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.6x </td>
                    <td align="center"> 0.8x </td>
                    <td align="center"> 0.56x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Runge-Kutta</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 1.4x </td>
                    <td align="center"> 0.95x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Implicit Runge-Kutta</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.67x </td>
                </tr>
            </informaltable>
        </para>
        <para>
            Next, a basic controller with six continuous states is tested.
            <link type="scilab" linkend="scilab.xcos/xcos/demos/Controller.zcos">
                <inlinemediaobject>
                    <imageobject>
                        <imagedata align="center" fileref="../../../demos/Controller.zcos" valign="middle"/>
                    </imageobject>
                </inlinemediaobject>
            </link>
            <scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/Controller.zcos");
scs_m.props.tol(6) = 0;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
        </para>
        <para>
            In the following script, we compare the time difference between the solvers by running the example with the nine solvers in turn (<emphasis>IDA</emphasis> doesn't handle this kind of problem):
            <link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchBasic.sce">
                Open the script
            </link>
        </para>
        <para>
            The Scilab console displays:
            <screen><![CDATA[
Time for LSodar:
 10

Time for CVode BDF/Newton:
 28.254

Time for CVode BDF/Functional:
 25.545

Time for CVode Adams/Newton:
 15

Time for CVode Adams/Functional:
 12.1

Time for Dormand-Prince:
 2.359

Time for Runge-Kutta:
 1.671

Time for implicit Runge-Kutta:
 5.612

Time for Crank-Nicolson:
 3.345
            ]]></screen>
        </para>
        <para>
            These results show that as stiffness appears, <emphasis>BDF / Newton</emphasis> starts picking up speed. But the problem is not yet complicated enough for that method to be interesting.
        </para>
        <para>
            The updated speed factors table is as follows:
        </para>
        <para>
            <informaltable border="1">
                <tr>
                    <td align="center"> </td>
                    <td align="center">
                        <emphasis>BDF / Newton</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>BDF / Functional</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Adams / Newton</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Adams / Functional</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Dormand-Prince</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Runge-Kutta</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Implicit Runge-Kutta</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Crank-Nicolson</emphasis>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>LSodar</emphasis>
                    </td>
                    <td align="center"> 2.8x </td>
                    <td align="center"> 2.6x </td>
                    <td align="center"> 1.5x </td>
                    <td align="center"> 1.2x </td>
                    <td align="center"> 0.2x </td>
                    <td align="center"> 0.17x </td>
                    <td align="center"> 0.5x </td>
                    <td align="center"> 0.33x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>BDF / Newton</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> 0.9x </td>
                    <td align="center"> 0.5x </td>
                    <td align="center"> 0.4x </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.05x </td>
                    <td align="center"> 0.2x </td>
                    <td align="center"> 0.12x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>BDF / Functional</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.6x </td>
                    <td align="center"> 0.5x </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.07x </td>
                    <td align="center"> 0.2x </td>
                    <td align="center"> 0.13x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Adams / Newton</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.8x </td>
                    <td align="center"> 0.15x </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.4x </td>
                    <td align="center"> 0.22x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Adams / Functional</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.2x </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.5x </td>
                    <td align="center"> 0.28x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Dormand-Prince</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.7x </td>
                    <td align="center"> 2.4x </td>
                    <td align="center"> 1.42x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Runge-Kutta</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 3.4x </td>
                    <td align="center"> 2x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Implicit Runge-Kutta</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.6x </td>
                </tr>
            </informaltable>
        </para>
        <para>
            Now, we use Kalman's filter, which contains fifteen continuous states.
            <link type="scilab" linkend="scilab.xcos/xcos/demos/Kalman.zcos">
                <inlinemediaobject>
                    <imageobject>
                        <imagedata align="center" fileref="../../../demos/Kalman.zcos" valign="middle"/>
                    </imageobject>
                </inlinemediaobject>
            </link>
            <scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/Kalman.zcos");
scs_m.props.tol(6) = 0;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
        </para>
        <para>
            In the following script, we compare the time difference between the solvers by running the example with the nine solvers in turn (<emphasis>IDA</emphasis> doesn't handle this kind of problem):
            <link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchKalman.sce">
                Open the script
            </link>
        </para>
        <para>
            The Scilab console displays:
            <screen><![CDATA[
Time for LSodar:
 10

Time for CVode BDF/Newton:
 21.3

Time for CVode BDF/Functional:
 15.8

Time for CVode Adams/Newton:
 12.5

Time for CVode Adams/Functional:
 8.67

Time for Dormand-Prince:
 1.244

Time for Runge-Kutta:
 0.87

Time for implicit Runge-Kutta:
 4

Time for Crank-Nicolson:
 2.657
            ]]></screen>
        </para>
        <para>
            These results show that for a bigger problem (more continuous states implies more equations), the <emphasis>Newton iteration</emphasis> starts showing interest, for it comes closer to the other solvers.
        </para>
        <para>
            The updated speed factors table is as follows:
        </para>
        <para>
            <informaltable border="1">
                <tr>
                    <td align="center"> </td>
                    <td align="center">
                        <emphasis>BDF / Newton</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>BDF / Functional</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Adams / Newton</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Adams / Functional</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Dormand-Prince</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Runge-Kutta</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Implicit Runge-Kutta</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>Crank-Nicolson</emphasis>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>LSodar</emphasis>
                    </td>
                    <td align="center"> 2.1x </td>
                    <td align="center"> 1.6x </td>
                    <td align="center"> 1.3x </td>
                    <td align="center"> 0.85x </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.4x </td>
                    <td align="center"> 0.26x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>BDF / Newton</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> 0.75x </td>
                    <td align="center"> 0.6x </td>
                    <td align="center"> 0.4x </td>
                    <td align="center"> 0.06x </td>
                    <td align="center"> 0.05x </td>
                    <td align="center"> 0.2x </td>
                    <td align="center"> 0.12x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>BDF / Functional</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.8x </td>
                    <td align="center"> 0.55x </td>
                    <td align="center"> 0.08x </td>
                    <td align="center"> 0.06x </td>
                    <td align="center"> 0.25x </td>
                    <td align="center"> 0.17x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Adams / Newton</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.7x </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.07x </td>
                    <td align="center"> 0.3x </td>
                    <td align="center"> 0.21x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Adams / Functional</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.15x </td>
                    <td align="center"> 0.1x </td>
                    <td align="center"> 0.5x </td>
                    <td align="center"> 0.3x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Dormand-Prince</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.7x </td>
                    <td align="center"> 3.2x </td>
                    <td align="center"> 2.1x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Runge-Kutta</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 4.6x </td>
                    <td align="center"> 3.1x </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>Implicit Runge-Kutta</emphasis>
                    </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> </td>
                    <td align="center"> 0.66x </td>
                </tr>
            </informaltable>
        </para>
    </refsection>
    <refsection>
        <title>Examples - DAEs</title>
        <para>
            In this section we compare IDA with DDaskr.
        </para>
        <para>
            Example: a bouncing ball.
        </para>
        <para>
            <link type="scilab" linkend="scilab.xcos/xcos/demos/ModelicaBlocks/BouncingBall_Modelica.zcos">
                <inlinemediaobject>
                    <imageobject>
                        <imagedata align="center" fileref="../../../demos/ModelicaBlocks/BouncingBall_Modelica.zcos" valign="middle"/>
                    </imageobject>
                </inlinemediaobject>
            </link>
            <scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/ModelicaBlocks/BouncingBall_Modelica.zcos");
// Redefining messagebox() to avoid popup
function messagebox(msg, Title)
 disp(Title);
 disp(msg);
endfunction
scs_m.props.tol(6) = 100;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
        </para>
        <para>
            In the following script, we compare the time difference between the solvers by running the example with the three solvers in turn:
            <link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchBouncing.sce">
                Open the script
            </link>
        </para>
        <para>
            The Scilab console displays:
            <screen><![CDATA[
Time for IDA:
 8

Time for DDaskr - Newton:
 5.6

Time for DDaskr - GMRes:
 6.5
            ]]></screen>
        </para>
        <para>
            This result shows that on a stiff problem, with rootfinding and for same precision required, <emphasis>DDaskr - Newton</emphasis> is fastest.
        </para>
        <para>
            The difference in time is attributed to the powerful implementation of DDaskr and its least error control.
        </para>
        <para>
            GMRes is slower due to the small size of the problem.
        </para>
        <para>
            From the results, we can extract the speed factors:
        </para>
        <para>
            <informaltable border="1">
                <tr>
                    <td align="center"> </td>
                    <td align="center">
                        <emphasis>IDA</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>DDaskr G</emphasis>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>DDaskr N</emphasis>
                    </td>
                    <td align="center"> 1.39x </td>
                    <td align="center"> 1.9x </td>
                </tr>
            </informaltable>
        </para>
        <para>
            The next example simply corroborates the previous one, it is shorter but more thorough, since it deals with the filling and emptying of a tank.
        </para>
        <para>
            <link type="scilab" linkend="scilab.xcos/xcos/demos/ModelicaBlocks/Hydraulics.zcos">
                <inlinemediaobject>
                    <imageobject>
                        <imagedata align="center" fileref="../../../demos/ModelicaBlocks/Hydraulics.zcos" valign="middle"/>
                    </imageobject>
                </inlinemediaobject>
            </link>
            <scilab:image><![CDATA[
loadScicos();
loadXcosLibs();
importXcosDiagram(SCI + "/modules/xcos/demos/ModelicaBlocks/Hydraulics.zcos");
// Redefining messagebox() to avoid popup
function messagebox(msg, Title)
 disp(Title);
 disp(msg);
endfunction
scs_m.props.tol(6) = 100;
try xcos_simulate(scs_m, 4); catch disp(lasterror()); end
]]></scilab:image>
        </para>
        <para>
            In the following script, we compare the time difference between the solvers by running the example with the three solvers in turn:
            <link type="scilab" linkend ="scilab.scinotes/xcos/examples/solvers/benchHydraulics.sce">
                Open the script
            </link>
        </para>
        <para>
            The Scilab console displays:
            <screen><![CDATA[
Time for IDA:
 3

Time for DDaskr - Newton:
 0.8

Time for DDaskr - GMRes:
 0.85
            ]]></screen>
        </para>
        <para>
            From the results, we can extract the speed factors:
        </para>
        <para>
            <informaltable border="1">
                <tr>
                    <td align="center"> </td>
                    <td align="center">
                        <emphasis>IDA</emphasis>
                    </td>
                    <td align="center">
                        <emphasis>DDaskr G</emphasis>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <emphasis>DDaskr N</emphasis>
                    </td>
                    <td align="center"> 3.75x </td>
                    <td align="center"> 1.06x </td>
                </tr>
            </informaltable>
        </para>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="LSodar">LSodar</link>
            </member>
            <member>
                <link linkend="CVode">CVode</link>
            </member>
            <member>
                <link linkend="IDA">IDA</link>
            </member>
            <member>
                <link linkend="RK">Runge-Kutta 4(5)</link>
            </member>
            <member>
                <link linkend="DoPri">Dormand-Prince 4(5)</link>
            </member>
            <member>
                <link linkend="ImpRK">Implicit Runge-Kutta 4(5)</link>
            </member>
            <member>
                <link linkend="CRANI">Crank-Nicolson 2(3)</link>
            </member>
            <member>
                <link linkend="DDaskr">DDaskr</link>
            </member>
            <member>
                <link linkend="ode">ode</link>
            </member>
            <member>
                <link linkend="ode_discrete">ode_discrete</link>
            </member>
            <member>
                <link linkend="ode_root">ode_root</link>
            </member>
            <member>
                <link linkend="odedc">odedc</link>
            </member>
            <member>
                <link linkend="dae">dae</link>
            </member>
        </simplelist>
    </refsection>
</refentry>