MatchMethodJacobian.java

  1. // @formatter:off
  2.  /*******************************************************************************
  3.  *
  4.  * This file is part of JMad.
  5.  *
  6.  * Copyright (c) 2008-2011, CERN. All rights reserved.
  7.  *
  8.  * Licensed under the Apache License, Version 2.0 (the "License");
  9.  * you may not use this file except in compliance with the License.
  10.  * You may obtain a copy of the License at
  11.  *
  12.  *     http://www.apache.org/licenses/LICENSE-2.0
  13.  *
  14.  * Unless required by applicable law or agreed to in writing, software
  15.  * distributed under the License is distributed on an "AS IS" BASIS,
  16.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17.  * See the License for the specific language governing permissions and
  18.  * limitations under the License.
  19.  *
  20.  ******************************************************************************/
  21. // @formatter:on

  22. /**
  23.  *
  24.  */
  25. package cern.accsoft.steering.jmad.domain.result.match.methods;

  26. /**
  27.  * The JACOBIAN command minimises the penalty function calculating the Jacobian and solving the linear problem. A QR or
  28.  * LQ decomposition is performed when the system is over or under-determined. Before starting the matching routine two
  29.  * optional transformations (COOL and RANDOM) are performed.
  30.  * JACOBIAN,CALLS=integer,TOLERANCE=real,REPEAT=integer,STRATEGY=integer,COOL= real,BALANCE=real, random=real; The
  31.  * command has the attributes: CALLS: The maximum number of calls to the penalty function (default: 30). TOLERANCE: The
  32.  * desired tolerance for the minimum (default: 10**(-6)). REPEAT: The number of call of the JACOBIAN routine (default:
  33.  * 1). BISEC: Selects the maximum number of iteratation used to determin the step length which reduces the penalty
  34.  * function during the main iteration. A large number (i.e. 6) reduce the probability to diverge from the solution, but
  35.  * increase the one for being trapped in a local minum. STRATEGY: A code for the strategy to be used (default: 3). If
  36.  * STRATEGY=1 the routine resets the values of the variables which exceeds the limits. If STRATEGY=2 the routine print
  37.  * the Jacobian and exit without matching. If STRATEGY=3 the routine disables the variables which exceeds the limits
  38.  * keeping however the number of variables greater or equal to the number of the constraints. COOL, BALANCE: The factors
  39.  * which specify the following transformation:
  40.  * {@literal if "balance" >=0 newval=(1-cool)*oldval+cool*((1-balance)*maxval+balance*minval )
  41.  * else newval=(1-cool)*oldval+cool* optval }
  42.  * where newval is the new value after the transformation, oldval is the previous value, maxval, minval,
  43.  * optval are the maximum value, minimum value, optimal
  44.  * value of the variable specified in the VARY command. RANDOM: The factors which specify the following transformation:
  45.  * newval= (1+ random * rand() ) * oldval where newval is the new value after the transformation, oldval is the previous
  46.  * value, rand() is a stochastic variable with a uniform (-0.5,0.5) distribution. Example:
  47.  * JACOBIAN,CALLS=20,TOLERANCE=1.0E-8,STRATEGY= 3,COOL=0.1,BALANCE=0.5,RANDOM=0.01;
  48.  *
  49.  * @author muellerg
  50.  */
  51. public class MatchMethodJacobian extends AbstractMatchMethod {

  52.     private static final AlgorithmType ALGORITHM_TYPE = AlgorithmType.JACOBIAN;

  53.     private static final int DEFAULT_CALLS = 30;

  54.     private int repeat = 1;

  55.     /**
  56.      * The default constructor.
  57.      */
  58.     public MatchMethodJacobian() {
  59.         setCalls(DEFAULT_CALLS);
  60.     }

  61.     /**
  62.      * @param repeat adjust the number of call of the JACOBIAN routine
  63.      *            <p>
  64.      *            (default: 1)
  65.      */
  66.     public void setRepeat(int repeat) {
  67.         this.repeat = repeat;
  68.     }

  69.     /**
  70.      * @return the number of calls of the JACOBIAN routine
  71.      */
  72.     public int getRepeat() {
  73.         return repeat;
  74.     }

  75.     @Override
  76.     public AlgorithmType getAlgorithmType() {
  77.         return ALGORITHM_TYPE;
  78.     }
  79. }