Changeset f85223 in git for kernel


Ignore:
Timestamp:
Apr 20, 2009, 5:35:04 PM (15 years ago)
Author:
Martin Monerjan
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
Children:
8614b753fb6893a43005f8652abd5d7296d3c992
Parents:
6b0aa282252fc9ee946503d2609e77b28ea0aa7f
Message:
#defined GMPRATIONAL
Computation of interior points works. However Singular quits with a sig11, restarts and then successfully prints the interior point.


git-svn-id: file:///usr/local/Singular/svn/trunk@11733 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r6b0aa2 rf85223  
    22Compute the Groebner fan of an ideal
    33$Author: monerjan $
    4 $Date: 2009-04-17 13:44:27 $
    5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.35 2009-04-17 13:44:27 monerjan Exp $
    6 $Id: gfan.cc,v 1.35 2009-04-17 13:44:27 monerjan Exp $
     4$Date: 2009-04-20 15:35:04 $
     5$Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.36 2009-04-20 15:35:04 monerjan Exp $
     6$Id: gfan.cc,v 1.36 2009-04-20 15:35:04 monerjan Exp $
    77*/
    88
     
    2121#include "ring.h"
    2222#include "prCopy.h"
    23 #include "iostream.h"   //deprecated
     23#include <iostream.h>   //deprecated
     24
     25/*remove the following at your own risk*/
     26#ifndef GMPRATIONAL
     27#define GMPRATIONAL
     28#endif
    2429
    2530//Hacks for different working places
     
    3944#include "/u/slg/monerjan/cddlib/include/setoper.h"
    4045#include "/u/slg/monerjan/cddlib/include/cdd.h"
     46#include "/u/slg/monerjan/cddlib/include/cddmp.h"
    4147#endif
    4248
     
    164170                {
    165171#ifdef gfan_DEBUG
    166                         cout << "*** Computing Inequalities... ***" << endl;
     172                        std::cout << "*** Computing Inequalities... ***" << std::endl;
    167173#endif         
    168174                        //All variables go here - except ineq matrix and *v, see below
     
    178184                        dd_rowset ddredrows;            // # of redundant rows in ddineq
    179185                        dd_rowset ddlinset;             // the opposite
    180                         dd_rowindex ddnewpos;           // all to make dd_Canonicalize happy
    181                         dd_NumberType ddnumb=dd_Real;   //Number type
     186                        dd_rowindex ddnewpos;             // all to make dd_Canonicalize happy
     187                        dd_NumberType ddnumb=dd_Integer; //Number type
    182188                        dd_ErrorType dderr=dd_NoError;  //
    183189                        // End of var declaration
     
    203209                        ddrows=rows;
    204210                        ddcols=cols;
    205                         dd_MatrixPtr ddineq;            //Matrix to store the inequalities
     211                        dd_MatrixPtr ddineq;            //Matrix to store the inequalities                     
    206212                        ddineq=dd_CreateMatrix(ddrows,ddcols+1); //The first col has to be 0 since cddlib checks for additive consts there
    207213               
     
    286292                                for (int jj = 1; jj <ddcols; jj++)
    287293                                {
     294#ifdef GMPRATIONAL
     295                                        double foo;
     296                                        foo = mpq_get_d(ddineq->matrix[kk][jj]);
     297#ifdef gfan_DEBUG
     298                                        std::cout << "fAct is " << foo << " at " << fAct << std::endl;
     299#endif
     300                                        (*load)[jj-1] = (int)foo;               //store typecasted entry at pos jj-1 of load
     301#endif
     302#ifndef GMPRATIONAL
    288303                                        double *foo;
    289                                         foo = (double*)ddineq->matrix[kk][jj];  //get entry from actual position
     304                                        foo = (double*)ddineq->matrix[kk][jj];  //get entry from actual position#endif
    290305#ifdef gfan_DEBUG
    291306                                        std::cout << "fAct is " << *foo << " at " << fAct << std::endl;
    292 #endif 
     307#endif
    293308                                        (*load)[jj-1] = (int)*foo;              //store typecasted entry at pos jj-1 of load
     309#endif //GMPRATIONAL                                   
     310                       
     311
     312                                        //(*load)[jj-1] = (int)foo;             //store typecasted entry at pos jj-1 of load
    294313                                        //check for flipability here
    295314                                        if (jj<ddcols)                          //Is this facet NOT the last facet? Writing while instead of if is a really bad idea :)
     
    364383                        fNormal = f->getFacetNormal();  //read this->fNormal;
    365384#ifdef gfan_DEBUG
    366                         cout << "===" << endl;
    367                         cout << "running gcone::flip" << endl;
    368                         cout << "fNormal=";
     385                        std::cout << "===" << std::endl;
     386                        std::cout << "running gcone::flip" << std::endl;
     387                        std::cout << "fNormal=";
    369388                        fNormal->show();
    370                         cout << endl;
     389                        std::cout << std::endl;
    371390#endif                         
    372391                        /*1st step: Compute the initial ideal*/
     
    473492                        compute the difference accordingly
    474493                        */
    475                         dd_set_global_constants;
     494                        dd_set_global_constants();
    476495                        bool markingsAreCorrect=FALSE;
    477496                        dd_MatrixPtr intPointMatrix;
     
    487506                        */
    488507                        intPointMatrix = dd_CreateMatrix(iPMatrixRows+2,this->numVars+1);
     508                        intPointMatrix->numbtype=dd_Integer;    //NOTE: DO NOT REMOVE OR CHANGE TO dd_Rational
    489509                       
    490510                        for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
     
    560580                        /*Now we add the constraint for the standard simplex*/
    561581                        /*NOTE:Might actually work without the standard simplex*/
    562                         //dd_set_si(intPointMatrix->matrix[aktrow][0],100);
     582                        dd_set_si(intPointMatrix->matrix[aktrow][0],-1);
    563583                        for (int jj=1;jj<=this->numVars;jj++)
    564584                        {
    565                                 //dd_set_si(intPointMatrix->matrix[aktrow][jj],-1);
     585                                dd_set_si(intPointMatrix->matrix[aktrow][jj],1);
    566586                        }
    567587                        dd_WriteMatrix(stdout,intPointMatrix);
    568588                        interiorPoint(intPointMatrix);  //TODO This should finally return an intvec
    569589                        dd_FreeMatrix(intPointMatrix);
     590                        //dd_free_global_constants();
    570591                       
    571592                        /*Step 3
     
    724745                }//bool isParallel
    725746               
    726                 void interiorPoint(dd_MatrixPtr &M) //no const &M here since we want to remove redundant rows
     747                void interiorPoint(dd_MatrixPtr M) //no const &M here since we want to remove redundant rows
    727748                {
    728749                        dd_LPPtr lp,lpInt;
    729750                        dd_ErrorType err=dd_NoError;
    730751                        dd_LPSolverType solver=dd_DualSimplex;
    731                         dd_LPSolutionPtr lpSol;
     752                        dd_LPSolutionPtr lpSol=NULL;
    732753                        dd_rowset ddlinset,ddredrows;
    733754                        dd_rowindex ddnewpos;
    734                         dd_NumberType numb;
    735                         numb=dd_Integer;
    736                        
    737                         M->numbtype=numb;
    738                         dd_MatrixCanonicalize(&M, &ddlinset, &ddredrows, &ddnewpos, &err);
    739                         dd_WriteMatrix(stdout,M);
     755                        dd_NumberType numb;     
     756                        //M->representation=dd_Inequality;
     757                        //M->objective-dd_LPMin;  //Not sure whether this is needed
     758                        dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1);
     759                        cout << "TICK 1" << endl;
     760                        //numb=dd_Rational;
     761                       
     762                        //M->numbtype=dd_Real;
     763                        //dd_MatrixCanonicalize(&M, &ddlinset, &ddredrows, &ddnewpos, &err);
     764                        //if (err!=dd_NoError){cout << "Error during dd_MatrixCanonicalize" << endl;}
     765                        cout << "Tick 2" << endl;
     766                        //dd_WriteMatrix(stdout,M);
    740767                       
    741768                        lp=dd_Matrix2LP(M, &err);
     769                        //if (err!=dd_NoError){cout << "Error during dd_Matrix2LP" << endl;}                   
     770                        if (lp==NULL){cout << "LP is NULL" << endl;}
     771                        dd_WriteLP(stdout,lp);
     772                        cout << "Tick 3" << endl;
     773                                               
    742774                        lpInt=dd_MakeLPforInteriorFinding(lp);
    743                         dd_LPSolve(lpInt,solver,&err);
    744                         lpSol=dd_CopyLPSolution(lpInt);
    745                         lpSol->numbtype=numb;
     775                        //if (err!=dd_NoError){cout << "Error during dd_MakeLPForInteriorFinding" << endl;}
     776                        dd_WriteLP(stdout,lpInt);
     777                        cout << "Tick 4" << endl;
     778                       
     779                        dd_FindRelativeInterior(M,&ddlinset,&ddredrows,&lpSol,&err);
     780                       
     781                        //dd_LPSolve(lpInt,solver,&err);        //This will not result in a point from the relative interior
     782                        //if (err!=dd_NoError){cout << "Error during dd_LPSolve" << endl;}
     783                        cout << "Tick 5" << endl;
     784                                                                       
     785                        //lpSol=dd_CopyLPSolution(lpInt);
     786                        //if (err!=dd_NoError){cout << "Error during dd_CopyLPSolution" << endl;}                       
     787                        cout << "Tick 6" << endl;
     788                       
    746789                        cout << "Interior point: ";
    747790                        for (int ii=1; ii<(lpSol->d)-1;ii++)
     
    751794                        dd_FreeLPData(lp);
    752795                        dd_FreeLPSolution(lpSol);
    753                         dd_FreeLPData(lpInt);                   
     796                        dd_FreeLPData(lpInt);
     797                        dd_FreeMatrix(M);
     798                        set_free(ddlinset);
     799                        set_free(ddredrows);
    754800                }//void interiorPoint(dd_MatrixPtr const &M)
    755801};//class gcone
Note: See TracChangeset for help on using the changeset viewer.