public PqaEngine CreateCpuEngine(out PqaError err, EngineDefinition engDef) { if (engDef.AnswerCount == null || engDef.QuestionCount == null || engDef.TargetCount == null) { throw new PqaException("Answer, question and target counts must be all set."); } CiEngineDefinition ciEngDef = new CiEngineDefinition() { _nAnswers = engDef.AnswerCount.Value, _nQuestions = engDef.QuestionCount.Value, _nTargets = engDef.TargetCount.Value, _precType = (byte)engDef.PrecType, _precExponent = engDef.PrecExponent, _precMantissa = engDef.PrecMantissa, _initAmount = engDef.InitAmount, _memPoolMaxBytes = engDef.MemPoolMaxBytes }; IntPtr nativeEngine; IntPtr nativeError = IntPtr.Zero; try { nativeEngine = PqaEngineFactory_CreateCpuEngine(_nativeFactory, ref nativeError, ref ciEngDef); } finally { err = PqaError.Factor(nativeError); } if (nativeEngine == IntPtr.Zero) { return(null); } return(new PqaEngine(nativeEngine)); }
public PqaError Train(Int64 nQuestions, AnsweredQuestion[] AQs, Int64 iTarget, double amount = 1.0) { GCHandle pAQs = GCHandle.Alloc(AQs, GCHandleType.Pinned); try { return(PqaError.Factor(PqaEngine_Train(_nativeEngine, nQuestions, pAQs.AddrOfPinnedObject(), iTarget, amount))); } finally { pAQs.Free(); } }
public Int64 GetActiveQuestionId(out PqaError err, Int64 iQuiz) { IntPtr nativeErr = IntPtr.Zero; Int64 iQuestion; try { iQuestion = PqaEngine_GetActiveQuestionId(_nativeEngine, ref nativeErr, iQuiz); } finally { err = PqaError.Factor(nativeErr); } return(iQuestion); }
public Int64 NextQuestion(out PqaError err, Int64 iQuiz) { Int64 iQuestion; IntPtr nativeError = IntPtr.Zero; try { iQuestion = PqaEngine_NextQuestion(_nativeEngine, ref nativeError, iQuiz); } finally { err = PqaError.Factor(nativeError); } return(iQuestion); }
public Int64 StartQuiz(out PqaError err) { Int64 iQuiz; IntPtr nativeErr = IntPtr.Zero; try { iQuiz = PqaEngine_StartQuiz(_nativeEngine, ref nativeErr); } finally { err = PqaError.Factor(nativeErr); } return(iQuiz); }
public UInt64 GetTotalQuestionsAsked(out PqaError err) { IntPtr nativeErr = IntPtr.Zero; UInt64 res; try { res = PqaEngine_GetTotalQuestionsAsked(_nativeEngine, ref nativeErr); } finally { err = PqaError.Factor(nativeErr); } return(res); }
public PqaEngine LoadCpuEngine(out PqaError err, string filePath, ulong memPoolMaxBytes = EngineDefinition.cDefaultMemPoolMaxBytes) { IntPtr nativeEngine; IntPtr nativeError = IntPtr.Zero; try { nativeEngine = PqaEngineFactory_LoadCpuEngine(_nativeFactory, ref nativeError, filePath, memPoolMaxBytes); } finally { err = PqaError.Factor(nativeError); } if (nativeEngine == IntPtr.Zero) { return(null); } return(new PqaEngine(nativeEngine)); }
public Int64 ResumeQuiz(out PqaError err, Int64 nAnswered, AnsweredQuestion[] AQs) { GCHandle pAQs = GCHandle.Alloc(AQs, GCHandleType.Pinned); Int64 iQuiz; try { IntPtr nativeErr = IntPtr.Zero; try { iQuiz = PqaEngine_ResumeQuiz(_nativeEngine, ref nativeErr, nAnswered, pAQs.AddrOfPinnedObject()); } finally { err = PqaError.Factor(nativeErr); } } finally { pAQs.Free(); } return(iQuiz); }
// Fills the array |dest| with top targets and returns the number of targets filled, which can be less than the // length of array |dest|. public Int64 ListTopTargets(out PqaError err, Int64 iQuiz, RatedTarget[] dest) { GCHandle pDest = GCHandle.Alloc(dest, GCHandleType.Pinned); Int64 nListed; try { IntPtr nativeErr = IntPtr.Zero; try { nListed = PqaEngine_ListTopTargets(_nativeEngine, ref nativeErr, iQuiz, dest.LongLength, pDest.AddrOfPinnedObject()); } finally { err = PqaError.Factor(nativeErr); } } finally { pDest.Free(); } return(nListed); }
public PqaError SaveKB(string filePath, bool bDoubleBuffer) { return(PqaError.Factor(PqaEngine_SaveKB(_nativeEngine, filePath, (byte)(bDoubleBuffer ? 1 : 0)))); }
public PqaError ReleaseQuiz(Int64 iQuiz) { return(PqaError.Factor(PqaEngine_ReleaseQuiz(_nativeEngine, iQuiz))); }
public PqaError RecordQuizTarget(Int64 iQuiz, Int64 iTarget, double amount = 1.0) { return(PqaError.Factor(PqaEngine_RecordQuizTarget(_nativeEngine, iQuiz, iTarget, amount))); }
public PqaError RecordAnswer(Int64 iQuiz, Int64 iAnswer) { return(PqaError.Factor(PqaEngine_RecordAnswer(_nativeEngine, iQuiz, iAnswer))); }