本文整理汇总了Java中org.ojalgo.array.Primitive64Array类的典型用法代码示例。如果您正苦于以下问题:Java Primitive64Array类的具体用法?Java Primitive64Array怎么用?Java Primitive64Array使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Primitive64Array类属于org.ojalgo.array包,在下文中一共展示了Primitive64Array类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SparseTableau
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
@SuppressWarnings("unchecked")
SparseTableau(final int numberOfConstraints, final int numberOfProblemVariables, final int numberOfSlackVariables) {
super(numberOfConstraints, numberOfProblemVariables, numberOfSlackVariables);
// Including artificial variables
final int totNumbVars = this.countVariablesTotally();
final Factory<Double> denseFactory = Primitive64Array.FACTORY;
final SparseFactory<Double> sparseFactory = SparseArray.factory(denseFactory, totNumbVars).initial(3).limit(totNumbVars);
final Array1D.Factory<Double> factory1D = Array1D.factory(denseFactory);
myRows = new SparseArray[numberOfConstraints];
for (int r = 0; r < numberOfConstraints; r++) {
myRows[r] = sparseFactory.make();
}
myRHS = factory1D.makeZero(numberOfConstraints);
myObjectiveWeights = factory1D.makeZero(totNumbVars);
myPhase1Weights = denseFactory.makeZero(totNumbVars);
}
示例2: testP20150809
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
/**
* Issue reported at GitHub. A set of problems related to when Q is zero - a linear problem. Generally the
* ConvexSolver is not the right option to handle linear problems, but there is some desireable behaviour.
*/
public void testP20150809() {
final Primitive64Array tmpExpectedSolution = Primitive64Array.wrap(new double[] { 0.12, -0.05, 0.08, 0.07 });
final Primitive64Array tmpBoundedSolution = Primitive64Array.wrap(new double[] { 99999, -99999, 99999, 99999 });
ConvexSolver tmpSolver = P20150809.buildModel(true, false);
Result tmpResult = tmpSolver.solve();
TestUtils.assertStateNotLessThanOptimal(tmpResult);
TestUtils.assertEquals(tmpExpectedSolution, tmpResult);
tmpSolver = P20150809.buildModel(true, true);
tmpResult = tmpSolver.solve();
TestUtils.assertStateNotLessThanOptimal(tmpResult);
TestUtils.assertEquals(tmpExpectedSolution, tmpResult);
tmpSolver = P20150809.buildModel(false, false);
tmpResult = tmpSolver.solve();
TestUtils.assertEquals(Optimisation.State.UNBOUNDED, tmpResult.getState());
tmpSolver = P20150809.buildModel(false, true);
tmpResult = tmpSolver.solve();
TestUtils.assertStateNotLessThanOptimal(tmpResult); // Since it is now constrained, the solver should be able find the optimal solution.
TestUtils.assertEquals(tmpBoundedSolution, tmpResult);
}
示例3: 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;
}
}
示例4: divideAndCopyColumn
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
public void divideAndCopyColumn(final int row, final int column, final BasicArray<Double> destination) {
final double[] tmpData = data;
final int tmpRowDim = myRowDim;
final double[] tmpDestination = ((Primitive64Array) destination).data;
int tmpIndex = row + (column * tmpRowDim);
final double tmpDenominator = tmpData[tmpIndex];
for (int i = row + 1; i < tmpRowDim; i++) {
tmpDestination[i] = tmpData[++tmpIndex] /= tmpDenominator;
}
}
示例5: 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;
}
示例6: 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);
}
示例7: testEmptySet
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
public void testEmptySet() {
final Primitive64Array tmpSamples = Primitive64Array.wrap(new double[] { });
final SampleSet tmpSampleSet = SampleSet.wrap(tmpSamples);
try {
// The key thing is that all methods return something
// 0.0, NaN, Inf... doesn't really matter...
TestUtils.assertEquals(0.0, tmpSampleSet.getFirst());
TestUtils.assertEquals(0.0, tmpSampleSet.getInterquartileRange());
TestUtils.assertEquals(0.0, tmpSampleSet.getLargest());
TestUtils.assertEquals(0.0, tmpSampleSet.getLast());
TestUtils.assertEquals(0.0, tmpSampleSet.getMaximum());
TestUtils.assertEquals(Double.NaN, tmpSampleSet.getMean());
TestUtils.assertEquals(0.0, tmpSampleSet.getMedian());
TestUtils.assertEquals(0.0, tmpSampleSet.getMinimum());
TestUtils.assertEquals(0.0, tmpSampleSet.getQuartile1());
TestUtils.assertEquals(0.0, tmpSampleSet.getQuartile2());
TestUtils.assertEquals(0.0, tmpSampleSet.getQuartile3());
TestUtils.assertTrue(Double.isInfinite(tmpSampleSet.getSmallest()));
TestUtils.assertEquals(0.0, tmpSampleSet.getStandardDeviation());
TestUtils.assertEquals(0.0, tmpSampleSet.getSumOfSquares());
TestUtils.assertEquals(0.0, tmpSampleSet.getVariance());
} catch (final Exception exception) {
// Important NOT to throw an exception!
TestUtils.fail(exception.getMessage());
}
}
示例8: solve
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
public Result solve(final Result kickStarter) {
final int tmpNumberOfVariables = myTask.getnumvar();
Optimisation.State tmpSate = Optimisation.State.FAILED;
double tmpValue = Double.NaN;
final double[] tmpSolution = new double[tmpNumberOfVariables];
try {
final Env tmpEnvironment = INTEGRATION.getEnvironment();
DEFAULT.configure(tmpEnvironment, myTask, myOptions);
final Optional<Configurator> optional = myOptions.getConfigurator(Configurator.class);
if (optional.isPresent()) {
optional.get().configure(tmpEnvironment, myTask, myOptions);
}
if (myTask.optimize() == rescode.ok) {
final solsta[] tmpSolverState = new solsta[1];
myTask.getsolsta(mySolutionType, tmpSolverState);
myTask.getxx(mySolutionType, tmpSolution);
switch (tmpSolverState[0]) {
case optimal:
case near_optimal:
tmpSate = Optimisation.State.OPTIMAL;
tmpValue = myTask.getprimalobj(mySolutionType);
break;
case dual_infeas_cer:
case prim_infeas_cer:
case near_dual_infeas_cer:
case near_prim_infeas_cer:
tmpSate = Optimisation.State.INFEASIBLE;
break;
default:
tmpSate = Optimisation.State.FAILED;
break;
}
}
} catch (final Exception xcptn) {
throw xcptn;
}
return new Optimisation.Result(tmpSate, tmpValue, Primitive64Array.wrap(tmpSolution));
}
示例9: makePrimitive
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
static Tensor<Double> makePrimitive(final int rank, final int dimensions) {
return new AnyTensor<>(rank, dimensions, Primitive64Array.FACTORY);
}
示例10: 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;
}
}
示例11: Equation
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
public Equation(final int row, final long numberOfColumns, final double rhs) {
super();
index = row;
myElements = SparseArray.factory(Primitive64Array.FACTORY, numberOfColumns).make();
myRHS = rhs;
}
示例12: makeSingularValues
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
protected Array1D<Double> makeSingularValues() {
return Array1D.PRIMITIVE64.wrap(Primitive64Array.wrap(s));
}
示例13: makeD
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
@Override
protected MatrixStore<N> makeD() {
final DiagonalBasicArray<Double> tmpDiagonal = new DiagonalBasicArray<>(Primitive64Array.wrap(d), null, null, ZERO);
return this.wrap(tmpDiagonal).diagonal(false).get();
}
示例14: array
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
public DenseArray.Factory<Double> array() {
return Primitive64Array.FACTORY;
}
示例15: applyCholesky
import org.ojalgo.array.Primitive64Array; //导入依赖的package包/类
public void applyCholesky(final int iterationPoint, final BasicArray<Double> multipliers) {
final double[] tmpData = data;
final double[] tmpColumn = ((Primitive64Array) multipliers).data;
if ((myColDim - iterationPoint - 1) > ApplyCholesky.THRESHOLD) {
final DivideAndConquer tmpConquerer = new DivideAndConquer() {
@Override
protected void conquer(final int first, final int limit) {
ApplyCholesky.invoke(tmpData, myRowDim, first, limit, tmpColumn);
}
};
tmpConquerer.invoke(iterationPoint + 1, myColDim, ApplyCholesky.THRESHOLD);
} else {
ApplyCholesky.invoke(tmpData, myRowDim, iterationPoint + 1, myColDim, tmpColumn);
}
}