Xcos solvers: set LSodar and DOPRI5 available 02/9902/6
Clément DAVID [Tue, 4 Dec 2012 09:28:11 +0000 (10:28 +0100)]
Change-Id: I176dd6310feb0e0789f26fd47941080f4b54bf16

scilab/modules/xcos/etc/XConfiguration-xcos.xml
scilab/modules/xcos/etc/XConfiguration-xcos.xsl
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/dialog/SetupDialog.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/ScicosParameters.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/scicos/ScicosParametersElement.java

index 2133403..e44d31a 100644 (file)
         <body>
             <xcos-simulation final-integration-time="1.0E05" real-time-scaling="0.0E00" integrator-absolute-tolerance="1.0E-06" integrator-relative-tolerance="1.0E-06" tolerance-on-time="1.0E-10" max-integration-interval="1.00001E05" solver="2" max-step-size="0.0" trace="0">
                 <!-- Available solver values list from scicos -->
-                <!-- <solver code="0" description="lsodar - BDF - NEWTON "/> -->
+                <solver code="0" description="LSodar"/>
                 <solver code="1" description="Sundials/CVODE - BDF - NEWTON"/>
                 <solver code="2" description="Sundials/CVODE - BDF - FUNCTIONAL"/>
                 <solver code="3" description="Sundials/CVODE - ADAMS - NEWTON"/>
                 <solver code="4" description="Sundials/CVODE - ADAMS - FUNCTIONAL"/>
-                <!-- <solver code="5" description="DOPRI5 - Runge-Kutta 4(5)"/> -->
+                <solver code="5" description="DOPRI5 - Dormand-Price 4(5)"/>
                 <solver code="100" description="Sundials/IDA"/>
                 <!-- Available trace values lists from scicos -->        
                 <trace code="0" description="_(No trace nor debug printing)"/>
index f34401a..8d0cc69 100644 (file)
                     </xsl:for-each>
                 </Select>
                 <Label gridx="1" gridy="8" text="_(Maximum step size (0 means no limit))"/>
-                <NumericalSpinner gridx="2" gridy="8" min-value="0" increment="1" length="4" listener="ActionListener" value="{@max-step-size}">
+                <ScilabDoubleEntry gridx="2" gridy="8" value="{@max-step-size}" listener="PropertyChangeListener">
                     <actionPerformed choose="max-step-size">
                         <xsl:call-template name="context"/>
                     </actionPerformed>
-                </NumericalSpinner>
+                </ScilabDoubleEntry>
             </Grid>
         </Title>
         <VSpace height="10"/>
index cc90f0a..4a6cb9c 100644 (file)
@@ -66,25 +66,25 @@ public class SetupDialog extends JDialog {
      */
     private static final InputVerifier VALIDATE_POSITIVE_DOUBLE = new InputVerifier() {
 
-            @Override
-            public boolean verify(javax.swing.JComponent arg0) {
-                boolean ret = false;
-                JFormattedTextField textField = (JFormattedTextField) arg0;
-                try {
-                    BigDecimal value = new BigDecimal(textField.getText());
-                    if (value.compareTo(BigDecimal.ZERO) >= 0 && value.compareTo(MAX_DOUBLE) <= 0) {
-                        ret = true;
-                    }
-
-                    // bug #7143 workaround
-                    textField.setValue(value);
-                } catch (NumberFormatException e) {
-                    return ret;
+        @Override
+        public boolean verify(javax.swing.JComponent arg0) {
+            boolean ret = false;
+            JFormattedTextField textField = (JFormattedTextField) arg0;
+            try {
+                BigDecimal value = new BigDecimal(textField.getText());
+                if (value.compareTo(BigDecimal.ZERO) >= 0 && value.compareTo(MAX_DOUBLE) <= 0) {
+                    ret = true;
                 }
+
+                // bug #7143 workaround
+                textField.setValue(value);
+            } catch (NumberFormatException e) {
                 return ret;
+            }
+            return ret;
 
-            };
         };
+    };
 
     /**
      * Initialize static final fields
@@ -105,7 +105,7 @@ public class SetupDialog extends JDialog {
     private JFormattedTextField toleranceOnTime;
     private JFormattedTextField maxIntegrationTime;
     private JComboBox solver;
-    private JSpinner maxStepSize;
+    private JFormattedTextField maxStepSize;
 
     /**
      * Instanciate a new dialog.
@@ -171,13 +171,13 @@ public class SetupDialog extends JDialog {
         maxIntegrationTime.setValue(new BigDecimal(parameters.getMaxIntegrationTimeInterval()));
 
         JLabel solverLabel = new JLabel(XcosMessages.SOLVER_CHOICE);
-        final String[] solvers = new String[] { "lsodar - BDF - NEWTON ", "Sundials/CVODE - BDF - NEWTON", "Sundials/CVODE - BDF - FUNCTIONAL",
-                                                "Sundials/CVODE - ADAMS - NEWTON", "Sundials/CVODE - ADAMS - FUNCTIONAL", "DOPRI5 - Runge-Kutta 4(5)", "Sundials/IDA"
-        };
-        final String[] solversTooltips = new String[] { "Not available yet", "Method: BDF, Nonlinear solver= NEWTON",
-                                                        "Method: BDF, Nonlinear solver= FUNCTIONAL", "Method: ADAMS, Nonlinear solver= NEWTON", "Method: ADAMS, Nonlinear solver= FUNCTIONAL",
-                                                        "Not available yet", "Sundials/IDA"
-        };
+        final String[] solvers = new String[] { "LSodar", "Sundials/CVODE - BDF - NEWTON", "Sundials/CVODE - BDF - FUNCTIONAL",
+                                                "Sundials/CVODE - ADAMS - NEWTON", "Sundials/CVODE - ADAMS - FUNCTIONAL", "DOPRI5 - Dormand-Price 4(5)", "Sundials/IDA"
+                                              };
+        final String[] solversTooltips = new String[] { "Method: dynamic, Nonlinear solver= dynamic", "Method: BDF, Nonlinear solver= NEWTON",
+                "Method: BDF, Nonlinear solver= FUNCTIONAL", "Method: ADAMS, Nonlinear solver= NEWTON", "Method: ADAMS, Nonlinear solver= FUNCTIONAL",
+                "Method: Fixed step", "Sundials/IDA"
+                                                      };
 
         solver = new JComboBox(solvers);
         double solverValue = parameters.getSolver();
@@ -201,10 +201,9 @@ public class SetupDialog extends JDialog {
         solver.setRenderer(new ComboboxToolTipRenderer());
 
         JLabel maxStepSizeLabel = new JLabel(XcosMessages.MAXIMUN_STEP_SIZE);
-        SpinnerNumberModel spinnerModel = new SpinnerNumberModel((int) parameters.getMaximumStepSize(), 0, null, 1);
-        maxStepSize = new JSpinner();
-        maxStepSize.setModel(spinnerModel);
-        maxStepSize.setEditor(new JSpinner.NumberEditor(maxStepSize, "0"));
+        maxStepSize = new JFormattedTextField(CURRENT_FORMAT);
+        maxStepSize.setInputVerifier(VALIDATE_POSITIVE_DOUBLE);
+        maxStepSize.setValue(new BigDecimal(parameters.getMaximumStepSize()));
 
         JButton cancelButton = new JButton(XcosMessages.CANCEL);
         JButton okButton = new JButton(XcosMessages.OK);
@@ -319,68 +318,68 @@ public class SetupDialog extends JDialog {
      */
     private void installActionListeners(JButton cancelButton, JButton okButton, JButton defaultButton, JButton setContextButton) {
         cancelButton.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    dispose();
-                }
-            });
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                dispose();
+            }
+        });
 
         defaultButton.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    integration.setValue(new BigDecimal(ScicosParameters.FINAL_INTEGRATION_TIME));
-                    rts.setValue(new BigDecimal(ScicosParameters.REAL_TIME_SCALING));
-                    integrator.setValue(new BigDecimal(ScicosParameters.INTEGRATOR_ABSOLUTE_TOLERANCE));
-                    integratorRel.setValue(new BigDecimal(ScicosParameters.INTEGRATOR_RELATIVE_TOLERANCE));
-                    toleranceOnTime.setValue(new BigDecimal(ScicosParameters.TOLERANCE_ON_TIME));
-                    maxIntegrationTime.setValue(new BigDecimal(ScicosParameters.MAX_INTEGRATION_TIME_INTERVAL));
-                    solver.setSelectedIndex((int) ScicosParameters.SOLVER);
-                    maxStepSize.setValue((int) ScicosParameters.MAXIMUM_STEP_SIZE);
-                }
-            });
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                integration.setValue(new BigDecimal(ScicosParameters.FINAL_INTEGRATION_TIME));
+                rts.setValue(new BigDecimal(ScicosParameters.REAL_TIME_SCALING));
+                integrator.setValue(new BigDecimal(ScicosParameters.INTEGRATOR_ABSOLUTE_TOLERANCE));
+                integratorRel.setValue(new BigDecimal(ScicosParameters.INTEGRATOR_RELATIVE_TOLERANCE));
+                toleranceOnTime.setValue(new BigDecimal(ScicosParameters.TOLERANCE_ON_TIME));
+                maxIntegrationTime.setValue(new BigDecimal(ScicosParameters.MAX_INTEGRATION_TIME_INTERVAL));
+                solver.setSelectedIndex((int) ScicosParameters.SOLVER);
+                maxStepSize.setValue(new BigDecimal(ScicosParameters.MAXIMUM_STEP_SIZE));
+            }
+        });
 
         okButton.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    if (((JButton) e.getSource()).hasFocus()) {
-                        try {
-                            /*
-                             * FIXME This logic must be deported to a vetoable
-                             * handler
-                             */
-                            int solverSelectedIndex = solver.getSelectedIndex();
-                            if (solverSelectedIndex >= 0.0 && solverSelectedIndex <= solver.getModel().getSize() - 2) {
-                                parameters.setSolver(solverSelectedIndex);
-                            } else {
-                                parameters.setSolver(100.0);
-                            }
-
-                            parameters.setFinalIntegrationTime(((BigDecimal) integration.getValue()).doubleValue());
-                            parameters.setRealTimeScaling(((BigDecimal) rts.getValue()).doubleValue());
-                            parameters.setIntegratorAbsoluteTolerance(((BigDecimal) integrator.getValue()).doubleValue());
-                            parameters.setIntegratorRelativeTolerance(((BigDecimal) integratorRel.getValue()).doubleValue());
-                            parameters.setToleranceOnTime(((BigDecimal) toleranceOnTime.getValue()).doubleValue());
-                            parameters.setMaxIntegrationTimeInterval(((BigDecimal) maxIntegrationTime.getValue()).doubleValue());
-                            parameters.setMaximumStepSize(((Integer) maxStepSize.getValue()).doubleValue());
-
-                            dispose();
-
-                        } catch (PropertyVetoException ex) {
-                            Logger.getLogger(SetupAction.class.getName()).severe(ex.toString());
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                if (((JButton) e.getSource()).hasFocus()) {
+                    try {
+                        /*
+                         * FIXME This logic must be deported to a vetoable
+                         * handler
+                         */
+                        int solverSelectedIndex = solver.getSelectedIndex();
+                        if (solverSelectedIndex >= 0.0 && solverSelectedIndex <= solver.getModel().getSize() - 2) {
+                            parameters.setSolver(solverSelectedIndex);
+                        } else {
+                            parameters.setSolver(100.0);
                         }
+
+                        parameters.setFinalIntegrationTime(((BigDecimal) integration.getValue()).doubleValue());
+                        parameters.setRealTimeScaling(((BigDecimal) rts.getValue()).doubleValue());
+                        parameters.setIntegratorAbsoluteTolerance(((BigDecimal) integrator.getValue()).doubleValue());
+                        parameters.setIntegratorRelativeTolerance(((BigDecimal) integratorRel.getValue()).doubleValue());
+                        parameters.setToleranceOnTime(((BigDecimal) toleranceOnTime.getValue()).doubleValue());
+                        parameters.setMaxIntegrationTimeInterval(((BigDecimal) maxIntegrationTime.getValue()).doubleValue());
+                        parameters.setMaximumStepSize(((BigDecimal) maxStepSize.getValue()).doubleValue());
+
+                        dispose();
+
+                    } catch (PropertyVetoException ex) {
+                        Logger.getLogger(SetupAction.class.getName()).severe(ex.toString());
                     }
                 }
-            });
+            }
+        });
 
         setContextButton.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    final SetContextDialog dialog = new SetContextDialog(SetupDialog.this, parameters);
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                final SetContextDialog dialog = new SetContextDialog(SetupDialog.this, parameters);
 
-                    dialog.pack();
-                    dialog.setVisible(true);
-                }
-            });
+                dialog.pack();
+                dialog.setVisible(true);
+            }
+        });
     }
 }
 // CSON: ClassDataAbstractionCoupling
index b823618..16e9740 100644 (file)
@@ -297,13 +297,12 @@ public class ScicosParameters implements Serializable, Cloneable {
 
     /**
      * <ul>
-     * <li>0 : Lsodar : Method: BDF, Nonlinear solver= NEWTON (not available
-     * yet)
+     * <li>0 : LSodar
      * <li>1 : Sundials/CVODE : Method: BDF, Nonlinear solver= FUNCTIONAL
      * <li>2 : Sundials/CVODE : Method: BDF, Nonlinear solver= FUNCTIONAL
      * <li>3 : Sundials/CVODE : Method: ADAMS, Nonlinear solver= NEWTON
      * <li>4 : Sundials/CVODE : Method: ADAMS, Nonlinear solver= FUNCTIONAL
-     * <li>5 : DOPRI5 : Method: Runge-Kutta 4(5) (not available yet)
+     * <li>5 : DOPRI5 : Method: Runge-Kutta 4(5)
      * <li>100 : Sundials/IDA
      *
      *
@@ -315,13 +314,12 @@ public class ScicosParameters implements Serializable, Cloneable {
 
     /**
      * <ul>
-     * <li>0 : Lsodar : Method: BDF, Nonlinear solver= NEWTON (not available
-     * yet)
+     * <li>0 : Lsodar : Method: BDF, Nonlinear solver= NEWTON
      * <li>1 : Sundials/CVODE : Method: BDF, Nonlinear solver= FUNCTIONAL
      * <li>2 : Sundials/CVODE : Method: BDF, Nonlinear solver= FUNCTIONAL
      * <li>3 : Sundials/CVODE : Method: ADAMS, Nonlinear solver= NEWTON
      * <li>4 : Sundials/CVODE : Method: ADAMS, Nonlinear solver= FUNCTIONAL
-     * <li>5 : DOPRI5 : Method: Runge-Kutta 4(5) (not available yet)
+     * <li>5 : DOPRI5 : Method: Runge-Kutta 4(5)
      * <li>100 : Sundials/IDA
      *
      *
index 4758e66..8b29ea1 100644 (file)
@@ -370,13 +370,7 @@ public final class ScicosParametersElement extends AbstractElement<ScicosParamet
         tolField[field++][0] = from.getToleranceOnTime();
         tolField[field++][0] = from.getMaxIntegrationTimeInterval();
         tolField[field++][0] = from.getRealTimeScaling();
-        int solver = (int) from.getSolver();
-        // FIXME: implement compat. with future values
-        solver--;
-        if (solver == -1 || solver == 4) {
-            solver = 0;
-        }
-        tolField[field++][0] = solver;
+        tolField[field++][0] = from.getSolver();
         tolField[field++][0] = from.getMaximumStepSize();
 
         assert field == TOL_SIZE;