Beispiel #1
0
void CLinearMapping::_init()
{
  setType("linear");
  setName("linear mapping");
  variance = 1.0;
  setVerbosity(2);
}
Beispiel #2
0
void CMlpMapping::_init()
{
  setType("mlp");
  setName("multi-layer perceptron");
  variance = 1.0;
  setVerbosity(2);
}
Beispiel #3
0
void popVerbosity()
{
  if (vstack.empty()) {
    errorQuda("popVerbosity() called with empty stack");
  }
  setVerbosity(vstack.top());
  vstack.pop();
}
Beispiel #4
0
ContextdPluginLogger::ContextdPluginLogger() : AbstractContextdPlugin("Contextd_Logger"), minP(ContextdPluginNotifyEvent::NOTIFY_INFO)
{
    openlog("Contextd_Logger", LOG_NDELAY, LOG_DAEMON);

#ifndef NDEBUG
    setVerbosity(ContextdPluginNotifyEvent::NOTIFY_DEBUG);
#endif
}
Beispiel #5
0
/**
 * main
 */
int main(int argc, char *argv[]) {
    int rc = -1;
    int c;
    OPENPTS_FSM_CONTEXT *ctx;
    char *input_filename = NULL;
    char *output_filename = NULL;

    /* logging/NLS */
    initCatalog();

    while ((c = getopt(argc, argv, "do:h")) != EOF) {
        switch (c) {
        case 'd':
            setVerbosity(1);
            break;
        case 'o':
            output_filename = optarg;
            break;
        case 'h':
            /* fall through */
        default:
            usage();
            return -1;
        }
    }
    argc -= optind;
    argv += optind;
    input_filename = argv[0];

    /* Read UML(XML) file */
    if (input_filename == NULL) {
        ERROR(NLS(MS_OPENPTS, OPENPTS_UML2DOT_MISSING_XML_FILE, "ERROR missing XMLfile\n"));
        usage();
        return -1;
    }

    /* read UML(XML) */
    ctx = newFsmContext();
    rc = readUmlModel(ctx, argv[0]);

    if (rc != 0) {
        LOG(LOG_ERR, "ERROR\n");
        goto error;
    }

    /* Gen DOT file */
    rc = writeDotModel(ctx, output_filename);

    if (rc != 0) {
        LOG(LOG_ERR, "ERROR\n");
        goto error;
    }

  error:
    freeFsmContext(ctx);

    return rc;
}
Beispiel #6
0
void pushVerbosity(QudaVerbosity verbosity)
{
  vstack.push(getVerbosity());
  setVerbosity(verbosity);

  if (vstack.size() > 10) {
    warningQuda("Verbosity stack contains %u elements.  Is there a missing popVerbosity() somewhere?",
		static_cast<unsigned int>(vstack.size()));
  }
}
Beispiel #7
0
static PyObject* module_verbose(PyObject* self, PyObject* args, PyObject* kwargs)
{
    int _verbose = 0;
    static char *kwlist[] = {"verbosity", NULL};
    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &_verbose))
	return NULL;
    setVerbosity(_verbose);

    return Py_BuildValue("s", 0);
}
Beispiel #8
0
bool Debug::setVerbosityString(const char *verb_str)
{
  bool check_fails = checkVerbosityString(verb_str);
  if (check_fails) {
    return true; // error
  }
  if (string(verb_str) == "none") {
    setVerbosity(No_Verb);
  } else if (string(verb_str) == "low") {
    setVerbosity(Low_Verb);
  } else if (string(verb_str) == "med") {
    setVerbosity(Med_Verb);
  } else if (string(verb_str) == "high") {
    setVerbosity(High_Verb);
  } else {
    cerr << "Error: unrecognized verbosity (use none, low, med, high): " << verb_str << endl;
    return true; // error
  }
  return false; // no error
}
Beispiel #9
0
CMlpMapping::CMlpMapping(CMatrix* pXin, CMatrix* pyOut, unsigned int nhidden, int verbos)
  :
  CMapModel(pXin->getCols(), pyOut->getCols(), pXin->getRows()), 
  COptimisable(),
  pX(pXin), py(pyOut), hiddenDim(nhidden)
{ 
  DIMENSIONMATCH(pX->getRows()==py->getRows());
  _init();
  setVerbosity(verbos);
  initStoreage();
  initVals();
}
Beispiel #10
0
CLinearMapping::CLinearMapping(CMatrix* inData, 
	   CMatrix* targetData, 
	   const string linearMappingInfoFile, 
	   const string linearMappingInfoVariable, 
	   int verbos) : 
  CMapModel(inData->getCols(), targetData->getCols(), inData->getRows()), COptimisable(),
  pX(inData), py(targetData)
{
  _init();
  setVerbosity(verbos);
  readMatlabFile(linearMappingInfoFile, linearMappingInfoVariable);
}
Beispiel #11
0
CLinearMapping::CLinearMapping(CMatrix* pXin, CMatrix* pyOut, int verbos)
  :
  CMapModel(pXin->getCols(), pyOut->getCols(), pXin->getRows()), 
  COptimisable(),
  pX(pXin), py(pyOut)
{ 
  DIMENSIONMATCH(pX->getRows()==py->getRows());
  _init();
  setVerbosity(verbos);
  initStoreage();
  initVals();
  
}
Beispiel #12
0
ILOSTLBEGIN

CPLEXSolver::CPLEXSolver() {
    DBG("Create a CPLEX solver %s\n", "");

    var_counter = 0;
    _verbosity = 0;
    cplextime = 0.0;
    has_been_added = false;
    optimstatus = IloAlgorithm::Unknown;
    env = new IloEnv();
    model = new IloModel(*env);
    cplex = new IloCplex(*model);
    variables = new IloNumVarArray(*env);
    setVerbosity(_verbosity);  // Default to no verbose output
}
Beispiel #13
0
void ListModel::applyParams(SolverParams &params) {
	LOG_I("Applying custom parameters");
	if (ls.getNbPhases() == 0) {
		auto phase = ls.createPhase();
		if(params.iterLimit != -1)
			phase.setIterationLimit(static_cast<long long>(params.iterLimit));
		if(params.timeLimit != -1.0)
			phase.setTimeLimit(static_cast<int>(params.timeLimit));
		auto param = ls.getParam();
		param.setNbThreads(params.threadCount);
		param.setSeed(params.seed);
		param.setVerbosity(params.verbosityLevel);
		if (params.traceobj) {
			int timeBetweenDisplays = static_cast<int>(ceil(MSECS_BETWEEN_TRACES_LONG / 1000.0));
			param.setTimeBetweenDisplays(timeBetweenDisplays);
		}
	}
}
Beispiel #14
0
GurobiSolver::GurobiSolver(){
    _verbosity = 0;
    has_been_added = false;
    optimstatus = -1;

    /*  GRBModel takes a copy of env, so to change parameters of the env we
        need to use model->getEnv() and modify that. */
    try {
        env = new GRBEnv();
        model = new GRBModel(*env);
        variables = new vector<GRBVar>;

        setVerbosity(_verbosity);  // Default to no output
    } catch (GRBException e) {
        std::cout << "Gurobi execption while initialising number: " << e.getErrorCode() << std::endl;
        std::cout << e.getMessage() << std::endl;
        exit(1);
    }
}
void LegendManager::procDirectDebugInstruction(StringBuilder *input) {
  char* str = input->position(0);

  uint8_t temp_byte = 0;
  if (*(str) != 0) {
    temp_byte = atoi((char*) str+1);
  }

  StringBuilder parse_mule;

  switch (*(str)) {
    case 'v':
      parse_mule.concat(str);
      local_log.concatf("parse_mule split (%s) into %d positions.\n", str, parse_mule.split(","));
      parse_mule.drop_position(0);
      if (temp_byte < 17) {
        if (parse_mule.count() > 0) {
          int temp_int = parse_mule.position_as_int(0);
          iius[temp_byte].setVerbosity(temp_int);
        }
        local_log.concatf("Verbosity on IIU %d is %d.\n", temp_byte, iius[temp_byte].getVerbosity());
      }
      break;

    case 'i':
      if (1 == temp_byte) {
        local_log.concatf("The IIU preallocated measurements are stored at %p.\n", (uintptr_t) __prealloc);
      }
      else if (2 == temp_byte) {
        if (operating_legend) {
          operating_legend->printDebug(&local_log);
        }
      }
      else {
        int8_t old_verbosity = getVerbosity();
        if (temp_byte && (temp_byte < 7)) setVerbosity(temp_byte);
        printDebug(&local_log);
        if (temp_byte && (temp_byte < 7)) setVerbosity(old_verbosity);
      }
      break;

    case '-':
      if (operating_legend) {
        operating_legend->copy_frame();
        local_log.concat("Frame copied.\n");
        operating_legend->printDataset(&local_log);
      }
      break;
    case '+':
      if (temp_byte < 17) {
        iius[temp_byte].dumpPointers(&local_log);
      }
      break;


    // IMU DEBUG //////////////////////////////////////////////////////////////////
    case 'c':
      if (temp_byte < 17) {
        iius[temp_byte].printDebug(&local_log);
      }
      break;

    // IMU STATE CONTROL //////////////////////////////////////////////////////////
    case 'g':
      if (255 == temp_byte) {
        local_log.concat("Syncing all IIUs...\n");
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].sync();
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].sync();
        local_log.concatf("Syncing IIU %d.\n", temp_byte);
      }
      break;

    case 's':
      parse_mule.concat(str);
      parse_mule.split(",");
      parse_mule.drop_position(0);
      if (parse_mule.count() > 0) {
        int temp_int = parse_mule.position_as_int(0);

        if (255 == temp_byte) {
          for (uint8_t i = 0; i < 17; i++) {
            iius[i].setOperatingState(temp_int);
          }
        }
        else if (temp_byte < 17) {
          local_log.concatf("Setting the state of IMU %d to %d\n", temp_byte, temp_int);
          iius[temp_byte].setOperatingState(temp_int);
        }

      }
      break;

    case 'k':
      if ((temp_byte < 6) && (temp_byte >= 0)) {
        ManuvrMsg *event = Kernel::returnEvent(DIGITABULUM_MSG_IMU_INIT);
        event->addArg((uint8_t) temp_byte);  // Set the desired init stage.
        event->priority(0);
        raiseEvent(event);
        local_log.concatf("Broadcasting IMU_INIT for stage %u...\n", temp_byte);
      }
      else {
        local_log.concatf("Illegal INIT stage: %u\n", temp_byte);
      }
      break;

    case 'r':
      if (255 == temp_byte) {
        local_log.concat("Reseting all IIUs...\n");
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].reset();
        }
      }
      else if (temp_byte < 17) {
        local_log.concatf("Resetting IIU %d.\n", temp_byte);
        iius[temp_byte].reset();
      }
      break;


    case 'T':
    case 't':
      if (temp_byte < 17) {
        ManuvrMsg *event = Kernel::returnEvent((*(str) == 'T') ? DIGITABULUM_MSG_IMU_DOUBLE_TAP : DIGITABULUM_MSG_IMU_TAP);
        event->setOriginator((EventReceiver*) this);
        event->addArg((uint8_t) temp_byte);
        Kernel::staticRaiseEvent(event);
        local_log.concatf("Sent %stap event for IMU %d.\n", ((*(str) == 'T') ? "double ":""), temp_byte);
      }
      break;

    case 'q':
      if (temp_byte < 17) {
        ManuvrMsg *event = Kernel::returnEvent(DIGITABULUM_MSG_IMU_QUAT_CRUNCH);
        event->specific_target = (EventReceiver*) this;
        event->addArg((uint8_t) temp_byte);
        Kernel::staticRaiseEvent(event);
        local_log.concatf("Running quat on IIU %d.\n", temp_byte);
      }
      break;



    // IMU DATA ///////////////////////////////////////////////////////////////////
    case 'j':
      switch (*(str+1)) {
        case '0':
          reflection_acc.x = -1;
          reflection_acc.y = 1;
          reflection_acc.z = -1;
          reflection_gyr.set(-1, 1, -1);
          reflection_mag.x = 1;
          reflection_mag.y = 1;
          reflection_mag.z = -1;
          break;
        case 'm':
          if (*(str+2) == 'x')      reflection_mag.x *= -1;
          else if (*(str+2) == 'y') reflection_mag.y *= -1;
          else if (*(str+2) == 'z') reflection_mag.z *= -1;
          break;

        case 'a':
          if (*(str+2) == 'x')      reflection_acc.x *= -1;
          else if (*(str+2) == 'y') reflection_acc.y *= -1;
          else if (*(str+2) == 'z') reflection_acc.z *= -1;
          break;

        case 'g':
          if (*(str+2) == 'x')      reflection_gyr.x *= -1;
          else if (*(str+2) == 'y') reflection_gyr.y *= -1;
          else if (*(str+2) == 'z') reflection_gyr.z *= -1;
          break;
      }
      local_log.concatf("Reflection vectors\n\tMag (%d, %d, %d)\n\tAcc (%d, %d, %d)\n\tGyr (%d, %d, %d)\n", reflection_mag.x, reflection_mag.y, reflection_mag.z, reflection_acc.x, reflection_acc.y, reflection_acc.z, reflection_gyr.x, reflection_gyr.y, reflection_gyr.z);
      break;

    case '[':
    case ']':
      if (255 == temp_byte) {
        local_log.concatf("%sabling spherical abberation correction on all IIUs.\n", ((*(str) == ']') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].correctSphericalAbberation((*(str) == ']'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].correctSphericalAbberation((*(str) == ']'));
        local_log.concatf("%sabling spherical abberation correction on IIU %d.\n", ((*(str) == ']') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'u':
    case 'U':
      if (255 == temp_byte) {
        local_log.concatf("%sabling (clean-mag-is-zero) on all IIUs.\n", ((*(str) == 'U') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].cleanMagZero((*(str) == 'U'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].cleanMagZero((*(str) == 'U'));
        local_log.concatf("%sabling (clean-mag-is-zero) on IIU %d.\n", ((*(str) == 'U') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'w':
    case 'W':
      if (255 == temp_byte) {
        local_log.concatf("%sabling mag data scrutiny on all IIUs.\n", ((*(str) == 'Z') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].dropObviousBadMag((*(str) == 'Z'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].dropObviousBadMag((*(str) == 'Z'));
        local_log.concatf("%sabling mag data scrutiny on IIU %d.\n", ((*(str) == 'Z') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'z':
    case 'Z':
      if (255 == temp_byte) {
        local_log.concatf("%sabling autoscale on all IIUs.\n", ((*(str) == 'Z') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].enableAutoscale((*(str) == 'Z'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].enableAutoscale((*(str) == 'Z'));
        local_log.concatf("%sabling autoscale on IIU %d.\n", ((*(str) == 'Z') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'n':
    case 'N':
      if (255 == temp_byte) {
        local_log.concatf("%sabling range-binding on all IIUs.\n", ((*(str) == 'N') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].rangeBind((*(str) == 'N'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].rangeBind((*(str) == 'N'));
        local_log.concatf("%sabling range-binding on IIU %d.\n", ((*(str) == 'N') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'h':
    case 'H':
      if (255 == temp_byte) {
        local_log.concatf("%sabling quats on all IIUs.\n", ((*(str) == 'H') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].processQuats((*(str) == 'H'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].processQuats((*(str) == 'H'));
        local_log.concatf("%sabling quats on IIU %d.\n", ((*(str) == 'H') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'x':
    case 'X':
      if (255 == temp_byte) {
        local_log.concatf("%sabling gyro error compensation on all IIUs.\n", ((*(str) == 'X') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].nullGyroError((*(str) == 'X'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].nullGyroError((*(str) == 'X'));
        local_log.concatf("%sabling gyro error compensation on IIU %d.\n", ((*(str) == 'X') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'm':
    case 'M':
      if (255 == temp_byte) {
        local_log.concatf("%sabling gravity nullification on all IIUs.\n", ((*(str) == 'M') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].nullifyGravity((*(str) == 'M'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].nullifyGravity((*(str) == 'M'));
        local_log.concatf("%sabling gravity nullification on IIU %d.\n", ((*(str) == 'M') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'y':
    case 'Y':
      if (255 == temp_byte) {
        local_log.concatf("%sabling bearing nullification on all IIUs.\n", ((*(str) == 'Y') ? "En":"Dis"));
        for (uint8_t i = 0; i < 17; i++) {
          iius[i].nullifyBearing((*(str) == 'Y'));
        }
      }
      else if (temp_byte < 17) {
        iius[temp_byte].nullifyBearing((*(str) == 'Y'));
        local_log.concatf("%sabling bearing nullification on IIU %d.\n", ((*(str) == 'Y') ? "En":"Dis"), temp_byte);
      }
      break;

    case 'Q':
      local_log.concatf("Madgwick iterations to %d on all IIUs.\n", temp_byte);
      for (uint8_t i = 0; i < 17; i++) {
        iius[i].madgwickIterations(temp_byte);
      }
      break;



    case ',':
      IIU::max_quats_per_event = temp_byte;
      local_log.concatf("IIU class now runs a maximum of %u quats per event.\n", IIU::max_quats_per_event);
      break;

    case 'b':
      for (uint8_t i = 0; i < 17; i++) {
        iius[i].beta = (float)temp_byte * 0.1;
      }
      local_log.concatf("Beta value is now %f.\n", (double) (temp_byte * 0.1f));
      break;

    case 'L':
      for (uint8_t i = 0; i < 17; i++) {
        iius[i].setSampleRateProfile(temp_byte);
      }
      local_log.concatf("Moving to sample rate profile %d.\n", temp_byte);
      break;

    case 'o':
      for (uint8_t i = 0; i < 17; i++) {
        iius[i].setGyroBaseFiler(temp_byte);
      }
      local_log.concatf("Setting GYR base filter to %d.\n", temp_byte);
      break;

    case 'O':
      for (uint8_t i = 0; i < 17; i++) {
        iius[i].setAccelBaseFiler(temp_byte);
      }
      local_log.concatf("Setting ACC base filter to %d.\n", temp_byte);
      break;

    case 'a':
      if (255 == temp_byte) {
        refreshIMU();
      }
      else if (17 > temp_byte) {
        refreshIMU(temp_byte);
      }
      break;

    case 'd':
      switch (temp_byte) {
        case 255:
          event_legend_frame_ready.fireNow();  // Fire a single frame transmission.
          local_log.concat("We are manually firing the IMU frame broadcasts schedule.\n");
          break;
        case 254:
          event_legend_frame_ready.enableSchedule(true);  // Enable the periodic read.
          local_log.concat("Enabled frame broadcasts.\n");
          break;
        #if defined(__MANUVR_DEBUG)
          case 253:
            event_legend_frame_ready.printDebug(&local_log);
            break;
        #endif
        case 252:
          send_map_event();
          local_log.concat("We are manually firing the IMU frame broadcasts schedule.\n");
          break;
        default:
          if (temp_byte) {
            event_legend_frame_ready.alterSchedulePeriod(temp_byte*10);
            local_log.concatf("Set periodic frame broadcast to once every %dms.\n", temp_byte*10);
          }
          else {
            event_legend_frame_ready.enableSchedule(false);  // Disable the periodic read.
            local_log.concat("Disabled frame broadcasts.\n");
          }
          break;
      }
      break;

    case 'f':
      switch (temp_byte) {
        case 255:
          event_iiu_read.fireNow();
          local_log.concat("We are manually firing the IMU read schedule.\n");
          break;
        case 254:
          event_iiu_read.enableSchedule(true);
          local_log.concat("Enabled periodic readback.\n");
          break;
        default:
          if (temp_byte) {
            event_iiu_read.alterSchedulePeriod(temp_byte*10);
            local_log.concatf("Set periodic read schedule to once every %dms.\n", temp_byte*10);
          }
          else {
            event_iiu_read.enableSchedule(false);  // Disable the periodic read.
            local_log.concat("Disabled periodic readback.\n");
          }
          break;
      }
      break;

    case 'p':
      {
        parse_mule.concat(str);
        parse_mule.split(",");
        parse_mule.drop_position(0);
        uint8_t start = (temp_byte < 17) ? temp_byte   : 0;
        uint8_t stop  = (temp_byte < 17) ? temp_byte+1 : 17;
        int temp_int  = (parse_mule.count() > 0) ? parse_mule.position_as_int(0) : 255;
        for (uint8_t i = start; i < stop; i++) {
          if (255 != temp_int) {  // The user wants to make a change..
            iius[i].enableProfiling(temp_int ? true:false);
          }
          local_log.concatf("Profiling IIU %d: %sabled.\n", i, (iius[i].enableProfiling() ? "en":"dis"));
        }
      }
      break;

    case 'e':
      if (temp_byte < 17) {
        iius[temp_byte].dumpPreformedElements(&local_log);
      }
      break;


    default:
      EventReceiver::procDirectDebugInstruction(input);
      break;
  }

  flushLocalLog();
}
int main(int argc, char* argv[]) {



	bool correctInput=true;
	for(int i=1;i<argc;++i) {
		if(argv[i][0] == '-') {
			int j=1;
			while(argv[i][j] != '\0') {
				switch(argv[i][j++]) {
					case 'h': printHelp(0); //This will exit the program
							  break;
					case 'v': setVerbosity(VERBOSE); //Print more info
							  break;
					case 'd': setVerbosity(DEBUG); //Implies verbose too
							  PRINT(DEBUG,"Setting verbosity to debug\n");
							  break;
					case 's': setVerbosity(SILENT); //Print nothing but critical errors
							  break;
					default:  correctInput = false;
							  PRINT(CRITICAL,"Unknown parameter -%c\n",argv[i][j]);
							  break;
				}
			}
		}
		else {
			if(first == NULL) {
				PRINT(VERBOSE,"Trying to read file %s... ",argv[i]);
				graphFile = fopen(argv[i], "r");
				if(graphFile == NULL) {
					PRINT(VERBOSE, "failed\n");
					PRINT(CRITICAL, "Failed to open %s: %s\n",argv[i], strerror(errno));
					exit(errno);
				}
				else {
					PRINT(VERBOSE, "done\n");
					parseGraphFile(graphFile);
					PRINT(DEBUG,"Done parsing graph\n");
					fclose(graphFile);
				}
			}
			else {
				PRINT(ALERT,"Only one file can be supplied per run.\n Ignoring %s\n",argv[i]);
			}
		}
		if(!correctInput) {
			printHelp(1);
		}
	}

	//If the graph was read correctly, solve it!
	if(entrypoint != NULL) {	
		PRINT(VERBOSE, "Traveling graph from %c:\n", entrypoint->id);
		travelGraph();
	}
	else {
		PRINT(CRITICAL,"No graph file found (or reading it failed)\n");
		printHelp(2);
	}

	//Clean up memory
	freeAllNodes(first);
	return 0;
}