本文整理汇总了Java中org.ojalgo.array.Primitive64Array.make方法的典型用法代码示例。如果您正苦于以下问题:Java Primitive64Array.make方法的具体用法?Java Primitive64Array.make怎么用?Java Primitive64Array.make使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ojalgo.array.Primitive64Array
的用法示例。
在下文中一共展示了Primitive64Array.make方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toModelState
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public Result toModelState(final Result solverState, final ExpressionsBasedModel model) {
final int numbVariables = model.countVariables();
if (this.isSolutionMapped()) {
final List<Variable> freeVariables = model.getFreeVariables();
final Set<IntIndex> fixedVariables = model.getFixedVariables();
if (solverState.count() != freeVariables.size()) {
throw new IllegalStateException();
}
final Primitive64Array modelSolution = Primitive64Array.make(numbVariables);
for (final IntIndex fixedIndex : fixedVariables) {
modelSolution.set(fixedIndex.index, model.getVariable(fixedIndex.index).getValue());
}
for (int f = 0; f < freeVariables.size(); f++) {
final int freeIndex = model.indexOf(freeVariables.get(f));
modelSolution.set(freeIndex, solverState.doubleValue(f));
}
return new Result(solverState.getState(), modelSolution);
} else {
if (solverState.count() != numbVariables) {
throw new IllegalStateException();
}
return solverState;
}
}
示例2: getValues
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public Primitive64Array getValues() {
final int tmpLength = myProcesses.length;
final Primitive64Array retVal = Primitive64Array.make(tmpLength);
for (int p = 0; p < tmpLength; p++) {
retVal.set(p, myProcesses[p].getValue());
}
return retVal;
}
示例3: make
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public static SampleSet make(final RandomNumber randomNumber, final int size) {
final Primitive64Array retVal = Primitive64Array.make(size);
final double[] tmpData = retVal.data;
for (int i = 0; i < size; i++) {
tmpData[i] = randomNumber.doubleValue();
}
return new SampleSet(retVal);
}
示例4: toSolverState
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public Result toSolverState(final Result modelState, final ExpressionsBasedModel model) {
if (this.isSolutionMapped()) {
final List<Variable> tmpFreeVariables = model.getFreeVariables();
final int numbFreeVars = tmpFreeVariables.size();
final Primitive64Array solverSolution = Primitive64Array.make(numbFreeVars);
for (int i = 0; i < numbFreeVars; i++) {
final Variable variable = tmpFreeVariables.get(i);
final int modelIndex = model.indexOf(variable);
solverSolution.set(i, modelState.doubleValue(modelIndex));
}
return new Result(modelState.getState(), solverSolution);
} else {
return modelState;
}
}
示例5: sample
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public PrimitiveSeries sample(final int interval) {
if (interval <= 1) {
throw new IllegalArgumentException();
} else {
final int tmpSampleSize = this.size() / interval;
final int tmpLastIndex = this.size() - 1;
final Primitive64Array tmpValues = Primitive64Array.make(tmpSampleSize);
for (int i = 0; i < tmpSampleSize; i++) {
tmpValues.set(i, tmpLastIndex - (i * interval));
}
return PrimitiveSeries.wrap(this);
}
}
示例6: testGeometricMeanAndStandardDeviation
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public void testGeometricMeanAndStandardDeviation() {
final int tmpSize = 1000;
final double tmpFactoryExpected = 1.05;
final double tmpFactoryStdDev = PrimitiveFunction.ABS.invoke(new Normal(0.0, (tmpFactoryExpected - ONE)).doubleValue());
final Normal tmpFactoryDistr = new Normal(tmpFactoryExpected, tmpFactoryStdDev);
TestUtils.assertEquals("Factory Expected", tmpFactoryExpected, tmpFactoryDistr.getExpected(), 1E-14 / PrimitiveMath.THREE);
TestUtils.assertEquals("Factory Std Dev", tmpFactoryStdDev, tmpFactoryDistr.getStandardDeviation(), 1E-14 / PrimitiveMath.THREE);
final Primitive64Array tmpRawValues = Primitive64Array.make(tmpSize);
final Primitive64Array tmpLogValues = Primitive64Array.make(tmpSize);
for (int i = 0; i < tmpSize; i++) {
tmpRawValues.data[i] = tmpFactoryDistr.doubleValue();
tmpLogValues.data[i] = PrimitiveFunction.LOG.invoke(tmpRawValues.data[i]);
}
final SampleSet tmpLogValuesSet = SampleSet.wrap(tmpLogValues);
final LogNormal tmpLogDistribut = new LogNormal(tmpLogValuesSet.getMean(), tmpLogValuesSet.getStandardDeviation());
final double tmpGeometricMean = tmpLogDistribut.getGeometricMean();
final double tmpGeometricStandardDeviation = tmpLogDistribut.getGeometricStandardDeviation();
double tmpRawProduct = ONE;
for (int i = 0; i < tmpSize; i++) {
tmpRawProduct *= tmpRawValues.data[i];
}
TestUtils.assertEquals(tmpGeometricMean, PrimitiveFunction.POW.invoke(tmpRawProduct, ONE / tmpSize), 1E-14 / PrimitiveMath.THREE);
double tmpLogSum = ZERO;
for (int i = 0; i < tmpSize; i++) {
tmpLogSum += tmpLogValues.data[i];
}
TestUtils.assertEquals(tmpGeometricMean, PrimitiveFunction.EXP.invoke(tmpLogSum / tmpSize), 1E-14 / PrimitiveMath.THREE);
final double tmpLogGeoMean = PrimitiveFunction.LOG.invoke(tmpGeometricMean);
double tmpVal;
double tmpSumSqrDiff = ZERO;
for (int i = 0; i < tmpSize; i++) {
tmpVal = tmpLogValues.data[i] - tmpLogGeoMean;
tmpSumSqrDiff += (tmpVal * tmpVal);
}
TestUtils.assertEquals(tmpGeometricStandardDeviation / tmpGeometricStandardDeviation,
PrimitiveFunction.EXP.invoke(PrimitiveFunction.SQRT.invoke(tmpSumSqrDiff / tmpSize)) / tmpGeometricStandardDeviation, 0.00005);
// Check that the geometric standard deviation is within ±0.005% of what it should be.
}
示例7: solve
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public Result solve(final Result kickStarter) {
try {
final List<IloNumVar> solVariables = this.getDelegateVariables();
Optimisation.State retState = Optimisation.State.UNEXPLORED;
double retValue = Double.NaN;
final Primitive64Array retSolution = Primitive64Array.make(solVariables.size());
DEFAULT.configure(myDelegateSolver, myOptions);
final Optional<Configurator> optional = myOptions.getConfigurator(Configurator.class);
if (optional.isPresent()) {
optional.get().configure(myDelegateSolver, myOptions);
}
if (myDelegateSolver.solve()) {
// Feasible or Optimal
for (int i = 0; i < solVariables.size(); i++) {
retSolution.set(i, myDelegateSolver.getValue(solVariables.get(i)));
}
retValue = myDelegateSolver.getObjValue();
}
retState = this.translate(myDelegateSolver.getStatus());
return new Result(retState, retValue, retSolution);
} catch (final IloException exception) {
exception.printStackTrace();
}
return new Result(Optimisation.State.FAILED, Double.NaN, kickStarter);
}
示例8: solve
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public Result solve(final Result kickStarter) {
final GRBVar[] tmpVars = myDelegateSolver.getVars();
Optimisation.State retState = Optimisation.State.UNEXPLORED;
double retValue = NaN;
final Primitive64Array retSolution = Primitive64Array.make(myDelegateSolver.getVars().length);
try {
final GRBEnv tmpEnvironment = INTEGRATION.getEnvironment();
DEFAULT.configure(tmpEnvironment, myDelegateSolver, myOptions);
final Optional<Configurator> optional = myOptions.getConfigurator(Configurator.class);
if (optional.isPresent()) {
optional.get().configure(tmpEnvironment, myDelegateSolver, myOptions);
}
myDelegateSolver.getEnv().set(gurobi.GRB.IntParam.OutputFlag, 0);
myDelegateSolver.optimize();
retState = this.translate(myDelegateSolver.get(IntAttr.Status));
if (retState.isFeasible()) {
retValue = myDelegateSolver.get(DoubleAttr.ObjVal);
for (int i = 0; i < tmpVars.length; i++) {
retSolution.set(i, tmpVars[i].get(DoubleAttr.X));
}
}
} catch (final GRBException exception) {
exception.printStackTrace();
}
return new Optimisation.Result(retState, retValue, retSolution);
}
示例9: decompose
import org.ojalgo.array.Primitive64Array; //导入方法依赖的package包/类
public boolean decompose(final Access2D.Collectable<Double, ? super PhysicalStore<Double>> matrix) {
this.setInPlace(matrix);
final int size = this.getMinDim();
if ((myDiagD == null) || (myDiagD.count() == size)) {
myDiagD = Primitive64Array.make(size);
myDiagE = Primitive64Array.make(size);
}
this.getInPlace().tred2(myDiagD, myDiagE, true);
return this.computed(true);
}