Clear/remove any existing loss variables, and set the loss variables to the specified variable names.<br>
See {@link #addLossVariable(String)} for more details
@param lossVariableNames Names of variables to be loss function variables
556745
public void setLossVariables(String... lossVariableNames){
        this.lossVariables.clear();
        for(String s : lossVariableNames){
            addLossVariable(s);
        }
        //After changing loss function variables, we (probably) need to recreate gradient function - as gradient
        // function is defined with respect to specific loss function variables
        sameDiffFunctionInstances.remove("grad");
    }
1071057
private function setVariables(array $variables): void
    {
        foreach ($variables as $variable => $value) {
            if ($this->variableExists($variable)) {
                $this->$variable = $value;
            }
        }
    }
1006798
public EnvironmentResponse withVariables(java.util.Map<String, String> variables) {
        setVariables(variables);
        return this;
    }
886185
public InputVariable removeInputVariable(String name) {
        for (Iterator<InputVariable> it = this.inputVariables.iterator(); it.hasNext();) {
            InputVariable inputVariable = it.next();
            if (inputVariable.getName().equals(name)) {
                it.remove();
                return inputVariable;
            }
        }
        throw new RuntimeException(String.format(
                "[engine error] no input variable by name <%s>", name));
    }
981678
@SuppressWarnings({ "unchecked", "rawtypes" })
  public void remove() {
    super.remove();

    for (VariableInstanceEntity variableInstance : variableStore.getVariables()) {
      invokeVariableLifecycleListenersDelete(variableInstance, this,
          Arrays.<VariableInstanceLifecycleListener<CoreVariableInstance>>asList((VariableInstanceLifecycleListener) VariableInstanceEntityPersistenceListener.INSTANCE));
      variableStore.removeVariable(variableInstance.getName());
    }

    CommandContext commandContext = Context.getCommandContext();

    for (CaseSentryPartEntity sentryPart : getCaseSentryParts()) {
      commandContext
        .getCaseSentryPartManager()
        .deleteSentryPart(sentryPart);
    }

    // finally delete this execution
    commandContext
      .getCaseExecutionManager()
      .deleteCaseExecution(this);
  }
706427
public void setVariables(Map<String, String> variables)
    {
        if (this.variables != null)
        {
            this.variables.putAll(variables);
        }
        else
        {
            this.variables = variables;
        }
    }
1138081
public synchronized void updateVariableCache(Map<String, Object> variables) {
        boolean dirty = false;
        for (Map.Entry<String, Object> entry : variables.entrySet()) {
            String variableName = entry.getKey();
            // skip any variables defined in server.xml
            if (configVariables.containsKey(variableName)) {
                continue;
            }
            Object variableValue = entry.getValue();
            if (!isVariableCached(variableName, variableValue)) {
                variableCache.put(variableName, variableValue);
                dirty = true;
            }
        }
        if (dirty) {
            saveVariableCache();
        }
    }
695969
@Override
	protected void putVariables(Map<String, String> variables) {
		variables.put(ScopeFormat.asVariable(this.key), value);
	}
624180
public void putIndexedVariableProperties(String key, List<Map<String, String>> subKeyValues) {
		checkNotNull(key);
		checkNotNull(subKeyValues);
		for (int idx = 0; idx < subKeyValues.size(); idx++) {
			final Map<String, String> values = subKeyValues.get(idx);
			for (Map.Entry<String, String> value : values.entrySet()) {
				put(key + '.' + idx + '.' + value.getKey(), value.getValue());
			}
		}
	}
381815
public CallActivityMock onExecutionAddVariables(final VariableMap variables){
    return this.onExecutionDo("addVariablesServiceMock_"+ randomUUID(),
      (execution) -> variables.forEach(execution::setVariable)
    );
  }
1014340
public void addVar(Var var) {
        int id = var.getId();
        boolean alreadyAdded = (0 <= id && id < vars.size());
        if (alreadyAdded) {
            if (vars.get(id) != var) {
                throw new IllegalStateException("Var id already set, but factor not yet added.");
            }
        } else {  
            // Var was not yet in the factor graph.
            //
            // Check and set the id.
            if (id != -1 && id != vars.size()) {
                throw new IllegalStateException("Var id already set, but incorrect: " + id);
            }
            var.setId(vars.size());
            // Add the Var.
            vars.add(var);

            if (bg != null) { log.warn("Discarding BipartiteGraph. This may indicate inefficiency."); }
            bg = null;
        }
    }
1331737
public void removeArgFromFunction(String varName, DifferentialFunction function) {
        val args = function.args();

        for (int i = 0; i < args.length; i++) {
            if (args[i].getVarName().equals(varName)) {
                /**
                 * Since we are removing the variable reference
                 * from the arguments we need to  update both
                 * the reverse and forward arguments.
                 */
                List<String> reverseArgs = ops.get(function.getOwnName()).getInputsToOp();
                val newArgs = new ArrayList<String>(args.length - 1);
                for (int arg = 0; arg < args.length; arg++) {
                    if (!reverseArgs.get(arg).equals(varName)) {
                        newArgs.add(reverseArgs.get(arg));
                    }
                }

                ops.get(function.getOwnName()).setInputsToOp(newArgs);
                break;
            }
        }
    }
515291
@Override
	protected void putVariables(Map<String, String> variables) {
		variables.put(ScopeFormat.SCOPE_JOB_ID, jobId.toString());
		variables.put(ScopeFormat.SCOPE_JOB_NAME, jobName);
	}
438670
public void updateVariableName(String varName, String withName) {
        SDVariable oldVarNameRef = getVariable(varName);
        Variable v = variables.remove(varName);
        String oldVarName = varName;
        oldVarNameRef.setVarName(withName);
        v.setName(withName);
        variables.put(withName, v);

        for(SameDiffOp op : ops.values()){
            List<String> outputsOfOp = op.getOutputsOfOp();
            if(outputsOfOp != null && !outputsOfOp.isEmpty()) {
                for (int i = 0; i < outputsOfOp.size(); i++) {
                    if (outputsOfOp.get(i).equals(oldVarName)) {
                        outputsOfOp.set(i, withName);
                    }
                }
            }

            List<String> inputsToOp = op.getInputsToOp();
            if(inputsToOp != null && !inputsToOp.isEmpty()) {
                for (int i = 0; i < inputsToOp.size(); i++) {
                    if (inputsToOp.get(i).equals(oldVarName)) {
                        inputsToOp.set(i, withName);
                    }
                }
            }
        }

//        if (variableNameToArr.containsKey(oldVarName)) {
//            val arr = variableNameToArr.remove(oldVarName);
//            variableNameToArr.put(withName, arr);
//        }


        if (variableNameToShape.containsKey(oldVarName)) {
            val shape = variableNameToShape.remove(oldVarName);
            variableNameToShape.put(withName, shape);
        }

        if (forwardVarForGrad.containsKey(oldVarName)) {
            val forwardGrad = forwardVarForGrad.remove(oldVarName);
            forwardVarForGrad.put(withName, forwardGrad);
        }


        if (v.getInputsForOp() != null) {
            List<String> funcNames = v.getInputsForOp();
            for (String s : funcNames) {
                DifferentialFunction func = ops.get(s).getOp();
                if (func instanceof BaseOp) {
                    BaseOp baseOp = (BaseOp) func;
                    if (baseOp.getXVertexId() != null && baseOp.getXVertexId().equals(oldVarName)) {
                        baseOp.setXVertexId(withName);
                    }

                    if (baseOp.getYVertexId() != null && baseOp.getYVertexId().equals(oldVarName)) {
                        baseOp.setYVertexId(withName);
                    }

                    if (baseOp.getZVertexId() != null && baseOp.getZVertexId().equals(oldVarName)) {
                        baseOp.setZVertexId(withName);
                    }

                }
            }
        }


        if (v.getOutputOfOp() != null) {
            DifferentialFunction func = ops.get(v.getOutputOfOp()).getOp();
            if (func instanceof BaseOp) {
                BaseOp baseOp = (BaseOp) func;
                if (baseOp.getXVertexId() != null && baseOp.getXVertexId().equals(oldVarName)) {
                    baseOp.setXVertexId(withName);
                }

                if (baseOp.getYVertexId() != null && baseOp.getYVertexId().equals(oldVarName)) {
                    baseOp.setYVertexId(withName);
                }

                if (baseOp.getZVertexId() != null && baseOp.getZVertexId().equals(oldVarName)) {
                    baseOp.setZVertexId(withName);
                }
            }
        }
    }
375644
private void addVariablesToBuffer(final java.util.List<VariableAndValue> usedVariables, final ListBuffer listBuffer) {
        for (VariableAndValue variableAndValue : usedVariables) {
            listBuffer.add(variableAndValue.getValue());
        }
    }
1077923
public static Map<String, Object> findFreeMarkerContextVariables(Variables variables, String... varNames)
    {
        Map<String, Object> results = new HashMap<>();

        for (String varName : varNames)
        {
            WindupVertexFrame payload = null;
            try
            {
                payload = Iteration.getCurrentPayload(variables, null, varName);
            }
            catch (IllegalStateException | IllegalArgumentException e)
            {
                // oh well
            }

            if (payload != null)
            {
                results.put(varName, payload);
            }
            else
            {
                Iterable<? extends WindupVertexFrame> var = variables.findVariable(varName);
                if (var != null)
                {
                    results.put(varName, var);
                }
            }
        }
        return results;
    }
1339898
public void removeDependentVariables(Variable ... depVars) {
		ArrayList<Variable> newDepVars = new ArrayList<Variable>();
		for (Variable v : this.dependentVariables) {
			boolean toRemove = false;
			for (Variable v1 : depVars) {
				if (v.equals(v1)) {
					toRemove = true;
					break;
				}
			}
			if (!toRemove) newDepVars.add(v);
		}
		this.dependentVariables = newDepVars.toArray(new Variable[newDepVars.size()]);
	}