Exemplo n.º 1
0
 internal static WarmStart NewEmptyWarmStart(OsiSolverInterface solver)
 {
     unsafe
     {
         return(new WarmStart(solver.getEmptyWarmStart(), 0, null, 0, null));
     }
 }
Exemplo n.º 2
0
        internal static WarmStart NewWarmStart(OsiSolverInterface solver)
        {
            unsafe
            {
#if (SONNET_SETWARMROWPRICE)
                return(new WarmStart(solver.getWarmStart(), solver.getNumCols(), solver.getColSolutionUnsafe(), solver.getNumCols(), solver.getRowPriceUnsafe()));
#else
                return(new WarmStart(solver.getWarmStart(), solver.getNumCols(), solver.getColSolutionUnsafe(), 0, null));
#endif
            }
        }
Exemplo n.º 3
0
        internal void ApplyWarmStart(OsiSolverInterface solver)
        {
            Ensure.NotNull(solver, "solver");

            unsafe
            {
                // set the primal solution
                if (numberColumns > 0)
                {
                    // if the new solver has *fewer* columns, then no problem.
                    // if the new solver has MORE columns, then make sure we dont copy wrong memory..
                    if (solver.getNumCols() > numberColumns)
                    {
                        int n = solver.getNumCols();

                        double[] newColSolution = new double[n];
                        fixed(double *newColSolutionPinned = newColSolution)
                        {
                            // copy the first NumberOfColumns into the new array
                            CoinUtils.CoinDisjointCopyN(colSolution, numberColumns, newColSolutionPinned);
                            // then fill it up with zeros
                            CoinUtils.CoinZeroN(&newColSolutionPinned[numberColumns], (n - numberColumns));
                        }

                        solver.setColSolution(newColSolution);
                    }
                    else
                    {
                        solver.setColSolutionUnsafe(colSolution);
                    }

                    // set the dual solution
                    if (numberRows > 0)
                    {
                        // if the new solver has *fewer* rows, then no problem.
                        // if the new solver has MORE rows, then make sure we dont copy wrong memory..
                        if (solver.getNumRows() > numberRows)
                        {
                            int m = solver.getNumRows();

                            double[] newRowPrice = new double[m];
                            fixed(double *newRowPricePinned = newRowPrice)
                            {
                                // copy the first NumberOfRows into the new array
                                CoinUtils.CoinDisjointCopyN(rowPrice, numberRows, newRowPricePinned);
                                // then fill it up with zeros
                                CoinUtils.CoinZeroN(&newRowPricePinned[numberRows], (m - numberRows));
                            }

                            solver.setRowPrice(newRowPrice);
                        }
                        else
                        {
                            solver.setRowPriceUnsafe(rowPrice);
                        }
                    }
                }
#if (!SONNET_SETWARMROWPRICE)
                if (numberRows > 0 || rowPrice != null)
                {
                    throw new NotSupportedException();
                }
#endif
            }

            // set the warmstart object
            solver.setWarmStart(coinWarmStart);
        }