Creates a new instance of the right class for a given problem.
349905
def _create_task_problem(self, problemid, problem_content, task_problem_types):
        """"""
        # Basic checks
        if not id_checker(problemid):
            raise Exception("Invalid problem _id: " + problemid)
        if problem_content.get('type', "") not in task_problem_types:
            raise Exception("Invalid type for problem " + problemid)

        return task_problem_types.get(problem_content.get('type', ""))(self, problemid, problem_content, self._translations)
1198260
public static function create()
	{
		switch (func_num_args()) {
			case 0:
				return new ClassWithStringProperty();
			case 1:
				return new ClassWithStringProperty(func_get_arg(0));
			case 2:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1));
			case 3:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2));
			case 4:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
			case 5:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
			case 6:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
			case 7:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
			case 8:
				return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
			default:
				throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
		}
	}
141743
def create_problem_from_type_A(problem):
    
    
    p = OptProblem()
    
    nx = problem.get_num_primal_variables()
    nz = problem.G.shape[0]

    p.phi = problem.phi
    p.gphi = np.hstack((problem.gphi,np.zeros(nz)))
    p.Hphi = coo_matrix((problem.Hphi.data,(problem.Hphi.row,problem.Hphi.col)),shape=(nx+nz,nx+nz))    
    p.A = bmat([[problem.A,None],[problem.G,-eye(nz)]],format='coo')
    p.b = np.hstack((problem.b,np.zeros(nz)))
    p.f = problem.f
    p.J = coo_matrix((problem.J.data,(problem.J.row,problem.J.col)),shape=(problem.J.shape[0],nx+nz))
    p.H_combined = coo_matrix((problem.H_combined.data,(problem.H_combined.row,problem.H_combined.col)),shape=(nx+nz,nx+nz))
    p.u = np.hstack((problem.get_upper_limits(),problem.u))                
    p.l = np.hstack((problem.get_lower_limits(),problem.l))
    p.x = np.hstack((problem.x,np.zeros(nz)))

    p.P = None
    p.lam = None
    p.nu = None
    p.mu = None
    p.pi = None
    
    p.wrapped_problem = problem

    def eval(cls,xz):
        x = xz[:nx]
        z = xz[nx:]
        prob = cls.wrapped_problem
        prob.eval(x)
        cls.phi = prob.phi
        cls.gphi = np.hstack((prob.gphi,np.zeros(nz)))
        cls.Hphi = coo_matrix((prob.Hphi.data,(prob.Hphi.row,prob.Hphi.col)),shape=(nx+nz,nx+nz))
        cls.f = prob.f
        cls.J = coo_matrix((prob.J.data,(prob.J.row,prob.J.col)),shape=(prob.J.shape[0],nx+nz))

    def combine_H(cls,coeff,ensure_psd=False):
        prob = cls.wrapped_problem
        prob.combine_H(coeff,ensure_psd=ensure_psd)
        cls.H_combined = coo_matrix((prob.H_combined.data,(prob.H_combined.row,prob.H_combined.col)),shape=(nx+nz,nx+nz))
            
    def recover_primal_variables(cls,x):
        return x[:nx]
    
    def recover_dual_variables(cls,lam,nu,mu,pi):
        prob = cls.wrapped_problem
        return lam[:prob.A.shape[0]],nu,mu[nx:],pi[nx:]
                
    p.eval = MethodType(eval,p)
    p.combine_H = MethodType(combine_H,p)
    p.recover_primal_variables = MethodType(recover_primal_variables,p)
    p.recover_dual_variables = MethodType(recover_dual_variables,p)

    # Return
    return p
320665
protected Object createInstance(String classname) {

        // get the classloader to use
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (classLoader == null) {
            classLoader = this.getClass().getClassLoader();
        }

        // create an instance of the class using the default constructor
        try {

            return classLoader.loadClass(classname).newInstance();

        } catch (InstantiationException e) {
            throw new IllegalStateException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException(e);
        }

    }
847380
def create(self):
        """"""
        assert not self.called
        return self.klass(*self.args, **self.kw)
1332795
private Object createInstance(Class pClass, Object pParam) {
    Object value;

    try {

      // Create param and argument arrays
      Class[]  param = { pParam.getClass() };
      Object[] arg   = { pParam };

      // Get constructor
      Constructor constructor = pClass.getDeclaredConstructor(param);

      // Invoke and create instance
      value = constructor.newInstance(arg);
    } catch (Exception e) {
      return null;
    }
    return value;
  }
428944
def build_new_exception e
        e.class.new(e.message)
      rescue
        Exception.new e.message
      end
381609
private static void createFactoryInstance()
  {
    if (tc.isEntryEnabled())
      tc.entry(cclass, "createFactoryInstance");

    try
    {
      Class cls = Class.forName(MATCHING_CLASS_NAME);
      instance = (Matching) cls.newInstance();
    }
    catch (Exception e)
    {
      // No FFDC Code Needed.
      // FFDC driven by wrapper class.
      FFDC.processException(cclass,
        "com.ibm.ws.sib.matchspace.Matching.createFactoryInstance",
        e,
        "1:94:1.18");
//TODO: trace.error  
//      tc.error(cclass, "UNABLE_TO_CREATE_MATCHING_INSTANCE_CWSIH0007E", e);

      createException = e;
    }
    
    if (tc.isEntryEnabled())
      tc.exit(cclass, "createFactoryInstance");
  }
327660
public static Object newInstanceFromName(String className, ClassLoader classLoader) {
        try {
            Class<?> clazz = Class.forName(className, true, classLoader);
            return clazz.newInstance();
        } catch (Exception e) {
            String m = "Couldn't create instance from name " + className + " (" + e.getMessage() + ")";
            LOG.error(m, e);
            throw new RuntimeException(m);
        }
    }
116030
def new(self, *args, **kwargs):
        '''
'''
        return self.session().add(self.model(*args, **kwargs))
467659
public static <T> T newInstance(Class clazz, Object... args) {

        if (clazz == null) return null;

        Class[] argsClass = getArgsClasses(args);

        try {
            Constructor<T> constructor = clazz.<T>getConstructor(argsClass);
            return constructor.newInstance(args);
        } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
684852
@SuppressWarnings("unchecked")
  public static <S> Problem<S> loadProblem(String problemName) {
    Problem<S> problem ;
    try {
      problem = (Problem<S>)Class.forName(problemName).getConstructor().newInstance() ;
    } catch (InstantiationException e) {
      throw new JMetalException("newInstance() cannot instantiate (abstract class)", e) ;
    } catch (IllegalAccessException e) {
      throw new JMetalException("newInstance() is not usable (uses restriction)", e) ;
    } catch (InvocationTargetException e) {
      throw new JMetalException("an exception was thrown during the call of newInstance()", e) ;
    } catch (NoSuchMethodException e) {
      throw new JMetalException("getConstructor() was not able to find the constructor without arguments", e) ;
    } catch (ClassNotFoundException e) {
      throw new JMetalException("Class.forName() did not recognized the name of the class", e) ;
    }

    return problem ;
  }
55029
static <T> T newInstance(Class<T> cls) {
        try {
            return cls.newInstance();
        } catch (Exception e) {
            throw wrap(e);
        }
    }
957071
public static <T> Supplier<T> newInstance(Class<T> clazz, Object... parameters) {
        return new ClassConstructorNewInstanceSupplier<T>(clazz, parameters);
    }
152844
public static <E extends BaseException> E createNew(Class<E> exceptionType, ErrorCode errorCode) {
        try {
            Constructor<E> constructor = exceptionType.getDeclaredConstructor(ErrorCode.class);
            constructor.setAccessible(true);
            return constructor.newInstance(errorCode);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
                | InstantiationException e) {
            throw new IllegalArgumentException(exceptionType.getCanonicalName()
                    + " must implement a constructor with ErrorCode as parameter", e);
        }
    }
676548
def create_new(cls, oldvalue, *args):
    ""
    if oldvalue is not None:
        raise AlreadyExistsException('%r already exists' % (oldvalue,))
    return cls.create_instance(*args)
901981
public static <T> T newInstance(String className, Object... initargs) 
	throws SetupException
	{
		return newInstance(toClass(className),initargs);		
	}