Пример #1
0
        private IDictionary <UInt64, UInt64> DownloadTrainProblemResult(TrainResponse trainProblem, UInt64[] arguments)
        {
            EvalRequest request = new EvalRequest()
            {
                program   = trainProblem.challenge,
                arguments = arguments.Select(i => i.ToString("X")).ToArray()
            };
            var response = webApi.Eval(request);
            Dictionary <UInt64, UInt64> results = new Dictionary <ulong, ulong>();

            if (response.outputs.Length != arguments.Length)
            {
                return(null);
            }
            for (int i = 0; i < response.outputs.Length; ++i)
            {
                UInt64 result = Convert.ToUInt64(response.outputs[i], 16);
                results[arguments[i]] = result;
            }
            return(results);
        }
Пример #2
0
        private List <ulong> Eval(EvalRequest request, IEnumerable <ulong> inputs)
        {
            request.arguments = inputs.Select(ui => ui.ToString("X")).ToArray();

            var response = webApi.Eval(request);

            if (!response.status.Equals("ok", StringComparison.OrdinalIgnoreCase))
            {
                throw new ApplicationException(string.Format("Error EvalResponse ({0}): {1}", response.status, response.message));
            }

            var values = response.outputs.Select(str => Convert.ToUInt64(str, 16)).ToList();

            return(values);
        }