text:
#function bodies
@createOpenGLFun glxDestroyPixmap(glxpixmap::GLint)::Void
@createOpenGLFun glxCreateNewContext(config::GLint, render_type::GLint, share_list::GLint, direct::GLint)::Void
@createOpenGLFun glxGetContextIDEXT(context::GLXContext)::Cuint
@createOpenGLFun glxRenderLarge()::Void
@createOpenGLFun glxCopyContext(source::GLint, dest::GLint, mask::GLint)::Void
@createOpenGLFun glxGetFBConfigFromVisualSGIX(dpy::Ptr{Display}, vis::XVisualInfo)::Ptr{Void}
@createOpenGLFun glxImportContextEXT(dpy::Ptr{Display}, contextID::GLXContextID)::Ptr{Void}
@createOpenGLFun glxGetAGPOffsetMESA(pointer::Ptr{Void})::Cuint
@createOpenGLFun glxChooseFBConfig(dpy::Ptr{Display}, screen::Cint, attrib_list::Ptr{Cint}, nelements::Ptr{Cint})::Ptr{Void}
@createOpenGLFun glxQueryChannelRectSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, dx::Ptr{Cint}, dy::Ptr{Cint}, dw::Ptr{Cint}, dh::Ptr{Cint})::Cint
@createOpenGLFun glxReleaseVideoCaptureDeviceNV(dpy::Ptr{Display}, device::GLXVideoCaptureDeviceNV)::Void
@createOpenGLFun glxJoinSwapGroupNV(dpy::Ptr{Display}, drawable::GLXDrawable, group::GLuint)::Cint
@createOpenGLFun glxReleaseTexImageEXT(dpy::Ptr{Display}, drawable::GLXDrawable, buffer::int)::Void
@createOpenGLFun glxQuerySwapGroupNV(dpy::Ptr{Display}, drawable::GLXDrawable, group::Ptr{GLuint}, barrier::Ptr{GLuint})::Cint
@createOpenGLFun glxSendPbufferToVideoNV(dpy::Ptr{Display}, pbuf::GLXPbuffer, iBufferType::Cint, pulCounterPbuffer::Ptr{Culong}, bBlock::GLboolean)::Cint
@createOpenGLFun glxHyperpipeAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, attribList::Ptr{Void})::Cint
@createOpenGLFun glxChooseFBConfigSGIX(dpy::Ptr{Display}, screen::Cint, attrib_list::Ptr{Cint}, nelements::Ptr{Cint})::Ptr{Void}
@createOpenGLFun glxEnumerateVideoCaptureDevicesNV(dpy::Ptr{Display}, screen::Cint, nelements::Ptr{Cint})::Ptr{Void}
@createOpenGLFun glxGetVisualFromFBConfigSGIX(dpy::Ptr{Display}, config::GLXFBConfigSGIX)::Ptr{Void}
@createOpenGLFun glxVendorPrivate()::Void
@createOpenGLFun glxGetProcAddress(procName::Ptr{GLubyte})::Ptr{Void}
@createOpenGLFun glxHyperpipeConfigSGIX(dpy::Ptr{Display}, networkId::Cint, npipes::Cint, cfg::Ptr{GLXHyperpipeConfigSGIX}, hpId::Ptr{Cint})::Cint
@createOpenGLFun glxChannelRectSyncSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, synctype::GLenum)::Cint
@createOpenGLFun glxGetTransparentIndexSUN(dpy::Ptr{Display}, overlay::Window, underlay::Window, pTransparentIndex::Ptr{long})::Cint
@createOpenGLFun glxGetCurrentReadDrawableSGI()::Ptr{Void}
@createOpenGLFun glxCreateGLXPbufferSGIX(config::GLint, pbuffer::GLint)::Void
@createOpenGLFun glxCreatePbuffer(config::GLint, pbuffer::GLint)::Void
@createOpenGLFun glxGetFBConfigAttribSGIX(dpy::Ptr{Display}, config::GLXFBConfigSGIX, attribute::Cint, value::Ptr{Cint})::Cint
@createOpenGLFun glxQueryMaxSwapBarriersSGIX()::Void
@createOpenGLFun glxBindHyperpipeSGIX(dpy::Ptr{Display}, hpId::Cint)::Cint
@createOpenGLFun glxQueryDrawable(dpy::Ptr{Display}, draw::GLXDrawable, attribute::int, value::Ptr{uint32})::Void
@createOpenGLFun glxCushionSGI(dpy::Ptr{Display}, window::Window, cushion::float32)::Void
@createOpenGLFun glxQueryVideoCaptureDeviceNV(dpy::Ptr{Display}, device::GLXVideoCaptureDeviceNV, attribute::Cint, value::Ptr{Cint})::Cint
@createOpenGLFun glxWaitVideoSyncSGI(divisor::Cint, remainder::Cint, count::Ptr{uint32})::Cint
@createOpenGLFun glxCreateContext(gc_id::GLint, screen::GLint, visual::GLint, share_list::GLint)::Void
@createOpenGLFun glxCreateContextAttribsARB(dpy::Ptr{Display}, config::GLXFBConfig, share_context::GLXContext, direct::Cint, attrib_list::Ptr{Cint})::Ptr{Void}
@createOpenGLFun glxQueryMaxSwapGroupsNV(dpy::Ptr{Display}, screen::Cint, maxGroups::Ptr{GLuint}, maxBarriers::Ptr{GLuint})::Cint
@createOpenGLFun glxGetVideoSyncSGI(count::Ptr{uint32})::Cint
@createOpenGLFun glxSelectEvent(dpy::Ptr{Display}, draw::GLXDrawable, event_mask::unsigned_long)::Void
@createOpenGLFun glxChangeDrawableAttributes(drawable::GLint)::Void
@createOpenGLFun glxQueryHyperpipeConfigSGIX(dpy::Ptr{Display}, hpId::Cint, npipes::Ptr{Cint})::Ptr{Void}
@createOpenGLFun glxBindSwapBarrierNV(dpy::Ptr{Display}, group::GLuint, barrier::GLuint)::Cint
@createOpenGLFun glxCreateGLXPixmap(visual::GLint, pixmap::GLint, glxpixmap::GLint)::Void
@createOpenGLFun glxDestroyWindow(glxwindow::GLint)::Void
@createOpenGLFun glxClientInfo()::Void
@createOpenGLFun glxGetFBConfigsSGIX()::Void
@createOpenGLFun glxDestroyHyperpipeConfigSGIX(dpy::Ptr{Display}, hpId::Cint)::Cint
@createOpenGLFun glxVendorPrivateWithReply()::Void
@createOpenGLFun glxSwapBuffers(drawable::GLint)::Void
@createOpenGLFun glxCopySubBufferMESA(dpy::Ptr{Display}, drawable::GLXDrawable, x::int, y::int, width::int, height::int)::Void
@createOpenGLFun glxCreateGLXPixmapMESA(dpy::Ptr{Display}, visual::XVisualInfo, pixmap::Pixmap, cmap::Colormap)::Ptr{Void}
@createOpenGLFun glxReleaseBuffersMESA(dpy::Ptr{Display}, drawable::GLXDrawable)::Cint
@createOpenGLFun glxDestroyGLXPbufferSGIX(pbuffer::GLint)::Void
@createOpenGLFun glxQueryHyperpipeAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, returnAttribList::Ptr{Void})::Cint
@createOpenGLFun glxGetMscRateOML(dpy::Ptr{Display}, drawable::GLXDrawable, numerator::Ptr{Cint}, denominator::Ptr{Cint})::Cint
@createOpenGLFun glxFreeContextEXT(dpy::Ptr{Display}, context::GLXContext)::Void
@createOpenGLFun glxReleaseVideoDeviceNV(dpy::Ptr{Display}, screen::Cint, VideoDevice::GLXVideoDeviceNV)::Cint
@createOpenGLFun glxWaitForMscOML(dpy::Ptr{Display}, drawable::GLXDrawable, target_msc::CClonglong, divisor::CClonglong, remainder::CClonglong, ust::Ptr{Clonglong}, msc::Ptr{Clonglong}, sbc::Ptr{Clonglong})::Cint
@createOpenGLFun glxCreateGLXPixmapWithConfigSGIX(config::GLint, pixmap::GLint, glxpixmap::GLint)::Void
@createOpenGLFun glxDestroyGLXVideoSourceSGIX(dpy::GLint, glxvideosource::GLint)::Void
@createOpenGLFun glxWaitForSbcOML(dpy::Ptr{Display}, drawable::GLXDrawable, target_sbc::CClonglong, ust::Ptr{Clonglong}, msc::Ptr{Clonglong}, sbc::Ptr{Clonglong})::Cint
@createOpenGLFun glxSelectEventSGIX(dpy::Ptr{Display}, drawable::GLXDrawable, mask::unsigned_long)::Void
@createOpenGLFun glxGetFBConfigs()::Void
@createOpenGLFun glxDestroyGLXPixmap(pixmap::GLint)::Void
@createOpenGLFun glxRender()::Void
@createOpenGLFun glxBindChannelToWindowSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, window::Window)::Cint
@createOpenGLFun glxBindTexImageEXT(dpy::Ptr{Display}, drawable::GLXDrawable, buffer::int, attrib_list::Ptr{int})::Void
@createOpenGLFun glxSwapIntervalSGI()::Void
@createOpenGLFun glxQueryChannelDeltasSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, x::Ptr{Cint}, y::Ptr{Cint}, w::Ptr{Cint}, h::Ptr{Cint})::Cint
@createOpenGLFun glxLockVideoCaptureDeviceNV(dpy::Ptr{Display}, device::GLXVideoCaptureDeviceNV)::Void
@createOpenGLFun glxGetFBConfigAttrib(dpy::Ptr{Display}, config::GLXFBConfig, attribute::Cint, value::Ptr{Cint})::Cint
@createOpenGLFun glxQueryContext()::Void
@createOpenGLFun glxGetSelectedEvent(dpy::Ptr{Display}, draw::GLXDrawable, event_mask::Ptr{unsigned_long})::Void
@createOpenGLFun glxCreateWindow(config::GLint, window::GLint, glxwindow::GLint)::Void
@createOpenGLFun glxQueryHyperpipeBestAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, attribList::Ptr{Void}, returnAttribList::Ptr{Void})::Cint
@createOpenGLFun glxIsDirect(dpy::GLint, context::GLint)::Void
@createOpenGLFun glxChannelRectSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, x::Cint, y::Cint, w::Cint, h::Cint)::Cint
@createOpenGLFun glxGetCurrentDisplay()::Ptr{Void}
@createOpenGLFun glxBindSwapBarrierSGIX(window::GLint, barrier::GLint)::Void
@createOpenGLFun glxCopyImageSubDataNV(dpy::Ptr{Display}, srcCtx::GLXContext, srcName::GLuint, srcTarget::GLenum, srcLevel::GLint, srcX::GLint, srcY::GLint, srcZ::GLint, dstCtx::GLXContext, dstName::GLuint, dstTarget::GLenum, dstLevel::GLint, dstX::GLint, dstY::GLint, dstZ::GLint, width::GLsizei, height::GLsizei, depth::GLsizei)::Void
@createOpenGLFun glxQueryContextInfoEXT()::Void
@createOpenGLFun glxGetVideoInfoNV(dpy::Ptr{Display}, screen::Cint, VideoDevice::GLXVideoDeviceNV, pulCounterOutputPbuffer::Ptr{Culong}, pulCounterOutputVideo::Ptr{Culong})::Cint
@createOpenGLFun glxWaitX()::Void
@createOpenGLFun glxQueryServerString(screen::GLint, name::GLint)::Void
@createOpenGLFun glxJoinSwapGroupSGIX(window::GLint, group::GLint)::Void
@createOpenGLFun glxQueryVersion(major::Ptr{GLint}, minor::Ptr{GLint})::Void
@createOpenGLFun glxGetCurrentReadDrawable()::Ptr{Void}
@createOpenGLFun glxUseXFont(font::GLint, first::GLint, count::GLint, list_base::GLint)::Void
@createOpenGLFun glxReleaseVideoImageNV(dpy::Ptr{Display}, pbuf::GLXPbuffer)::Cint
@createOpenGLFun glxCreateGLXVideoSourceSGIX(dpy::GLint, screen::GLint, server::GLint, path::GLint, class::GLint, node::GLint)::Void
@createOpenGLFun glxQueryFrameCountNV(dpy::Ptr{Display}, screen::Cint, count::Ptr{GLuint})::Cint
@createOpenGLFun glxQueryGLXPbufferSGIX(dpy::Ptr{Display}, pbuf::GLXPbufferSGIX, attribute::Cint, value::Ptr{uint32})::Cint
@createOpenGLFun glxEnumerateVideoDevicesNV(dpy::Ptr{Display}, screen::Cint, nelements::Ptr{Cint})::Ptr{Cuint}
@createOpenGLFun glxSwapBuffersMscOML(dpy::Ptr{Display}, drawable::GLXDrawable, target_msc::CClonglong, divisor::CClonglong, remainder::CClonglong)::CClonglong
@createOpenGLFun glxQueryHyperpipeNetworkSGIX(dpy::Ptr{Display}, npipes::Ptr{Cint})::Ptr{Void}
@createOpenGLFun glxGetProcAddressARB(procName::Ptr{GLubyte})::Ptr{Void}
@createOpenGLFun glxGetSyncValuesOML(dpy::Ptr{Display}, drawable::GLXDrawable, ust::Ptr{Clonglong}, msc::Ptr{Clonglong}, sbc::Ptr{Clonglong})::Cint
@createOpenGLFun glxWaitGL(context::GLint)::Void
@createOpenGLFun glxMakeCurrentReadSGI(drawable::GLint, readdrawable::GLint, context::GLint)::Void
@createOpenGLFun glxDestroyContext(context::GLint)::Void
@createOpenGLFun glxAssociateDMPbufferSGIX(dpy::Ptr{Display}, pbuffer::GLXPbufferSGIX, params::DMparams, dmbuffer::DMbuffer)::Cint
@createOpenGLFun glxSet3DfxModeMESA(mode::Cint)::Cint
@createOpenGLFun glxGetSelectedEventSGIX(dpy::Ptr{Display}, drawable::GLXDrawable, mask::Ptr{unsigned_long})::Void
@createOpenGLFun glxBindVideoCaptureDeviceNV(dpy::Ptr{Display}, video_capture_slot::Cuint, device::GLXVideoCaptureDeviceNV)::Cint
@createOpenGLFun glxMakeCurrent(drawable::GLint, context::GLint)::Void
@createOpenGLFun glxCreateContextWithConfigSGIX(gc_id::GLint, screen::GLint, config::GLint, share_list::GLint)::Void
@createOpenGLFun glxCreatePixmap(config::GLint, pixmap::GLint, glxpixmap::GLint)::Void
@createOpenGLFun glxBindVideoDeviceNV(dpy::Ptr{Display}, video_slot::Cuint, video_device::Cuint, attrib_list::Ptr{Cint})::Cint
@createOpenGLFun glxDestroyPbuffer(pbuffer::GLint)::Void
@createOpenGLFun glxGetVisualConfigs()::Void
@createOpenGLFun glxGetCurrentDisplayEXT()::Ptr{Void}
@createOpenGLFun glxBindVideoImageNV(dpy::Ptr{Display}, VideoDevice::GLXVideoDeviceNV, pbuf::GLXPbuffer, iVideoBuffer::Cint)::Cint
@createOpenGLFun glxQueryExtensionsString(screen::GLint)::Void
@createOpenGLFun glxSwapIntervalEXT(dpy::Ptr{Display}, drawable::GLXDrawable, interval::int)::Void
@createOpenGLFun glxGetVisualFromFBConfig(dpy::Ptr{Display}, config::GLXFBConfig)::Ptr{Void}
@createOpenGLFun glxGetDrawableAttributes(drawable::GLint)::Void
@createOpenGLFun glxResetFrameCountNV(dpy::Ptr{Display}, screen::Cint)::Cint
@createOpenGLFun glxMakeContextCurrent(drawable::GLint, readdrawable::GLint, context::GLint)::Void
@createOpenGLFun glxGetDrawableAttributesSGIX(drawable::GLint)::Void
@createOpenGLFun glxChangeDrawableAttributesSGIX(drawable::GLint)::Void
@createOpenGLFun glxGetVideoDeviceNV(dpy::Ptr{Display}, screen::Cint, numVideoDevices::Cint, pVideoDevice::GLXVideoDeviceNV)::Cint
#constants
const GL_VIDEO_OUT_COLOR_AND_ALPHA_NV                                 = 0x20C6
const GL_SAMPLES_SGIS                                                 = 100001
const GL_HEIGHT_SGIX                                                  = 0x801E
const GL_PIXMAP_BIT_SGIX                                              = 0x00000002
const GL_AUX4_EXT                                                     = 0x20E6
const GL_FRONT_LEFT_EXT                                               = 0x20DE
const GL_TEXTURE_RECTANGLE_BIT_EXT                                    = 0x00000004
const GL_CONTEXT_MAJOR_VERSION_ARB                                    = 0x2091
const GL_TRANSPARENT_RED_VALUE                                        = 0x25
const GL_SCREEN                                                       = 0x800C
const GL_TRANSPARENT_GREEN_VALUE                                      = 0x26
const GL_TEXTURE_FORMAT_EXT                                           = 0x20D5
const GL_MAX_PBUFFER_HEIGHT_SGIX                                      = 0x8017
const GL_TEXTURE_FORMAT_NONE_EXT                                      = 0x20D8
const GL_TRANSPARENT_ALPHA_VALUE                                      = 0x28
const GL_GPU_CLOCK_AMD                                                = 0x21A4
const GL_LATE_SWAPS_TEAR_EXT                                          = 0x20F3
const GL_BIND_TO_TEXTURE_TARGETS_EXT                                  = 0x20D3
const GL_DIRECT_COLOR_EXT                                             = 0x8003
const GL_CONFIG_CAVEAT                                                = 0x20
const GL_GPU_FASTEST_TARGET_GPUS_AMD                                  = 0x21A2
const GL_BUFFER_SWAP_COMPLETE_INTEL_MASK                              = 0x04000000
const GL_VISUAL_CAVEAT_EXT                                            = 0x20
const GL_PSEUDO_COLOR_EXT                                             = 0x8004
const GL_PBUFFER_BIT                                                  = 0x00000004
const GL_AUX5_EXT                                                     = 0x20E7
const GL_RENDER_TYPE                                                  = 0x8011
const GL_PIPE_RECT_LIMITS_SGIX                                        = 0x00000002
const GL_MAX_PBUFFER_WIDTH                                            = 0x8016
const GL_FLIP_COMPLETE_INTEL                                          = 0x8182
const GL_TRUE_COLOR_EXT                                               = 0x8002
const GL_BACK_EXT                                                     = 0x20E0
const GL_GPU_OPENGL_VERSION_STRING_AMD                                = 0x1F02
const GL_AUX_BUFFERS_BIT                                              = 0x00000010
const GL_TEXTURE_FORMAT_RGB_EXT                                       = 0x20D9
const GL_VISUAL_ID                                                    = 0x800B
const GL_AUX7_EXT                                                     = 0x20E9
const GL_PIXMAP_BIT                                                   = 0x00000002
const GL_NO_RESET_NOTIFICATION_ARB                                    = 0x8261
const GL_DIRECT_COLOR                                                 = 0x8003
const GL_WINDOW_BIT                                                   = 0x00000001
const GL_CONTEXT_FLAGS_ARB                                            = 0x2094
const GL_TRANSPARENT_BLUE_VALUE                                       = 0x27
const GL_BIND_TO_TEXTURE_RGB_EXT                                      = 0x20D0
const GL_DEPTH_BUFFER_BIT                                             = 0x00000020
const GL_LOSE_CONTEXT_ON_RESET_ARB                                    = 0x8252
const GL_RGBA_TYPE                                                    = 0x8014
const GL_SAMPLE_BUFFERS_ARB                                           = 100000
const GL_X_RENDERABLE                                                 = 0x8012
const GL_COPY_COMPLETE_INTEL                                          = 0x8181
const GL_NONE                                                         = 0x8000
const GL_MAX_SWAP_INTERVAL_EXT                                        = 0x20F2
const GL_BIND_TO_MIPMAP_TEXTURE_EXT                                   = 0x20D2
const GL_SWAP_EXCHANGE_OML                                            = 0x8061
const GL_SHARE_CONTEXT_EXT                                            = 0x800A
const GL_TRANSPARENT_BLUE_VALUE_EXT                                   = 0x27
const GL_X_VISUAL_TYPE                                                = 0x22
const GL_HYPERPIPE_DISPLAY_PIPE_SGIX                                  = 0x00000001
const GL_SAMPLES_ARB                                                  = 100001
const GL_BACK_RIGHT_BUFFER_BIT                                        = 0x00000008
const GL_GPU_NUM_SIMD_AMD                                             = 0x21A6
const GL_BACK_LEFT_BUFFER_BIT_SGIX                                    = 0x00000004
const GL_SLOW_VISUAL_EXT                                              = 0x8001
const GL_VISUAL_ID_EXT                                                = 0x800B
const GL_COLOR_INDEX_TYPE_SGIX                                        = 0x8015
const GL_BLENDED_RGBA_SGIS                                            = 0x8025
const GL_MAX_PBUFFER_HEIGHT                                           = 0x8017
const GL_TRUE_COLOR                                                   = 0x8002
const GL_SWAP_COPY_OML                                                = 0x8062
const GL_VIDEO_OUT_COLOR_AND_DEPTH_NV                                 = 0x20C7
const GL_FRONT_RIGHT_BUFFER_BIT                                       = 0x00000002
const GL_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS                             = 0x8027
const GL_WINDOW_BIT_SGIX                                              = 0x00000001
const GL_WINDOW_SGIX                                                  = 0x8022
const GL_PBUFFER_WIDTH                                                = 0x8041
const GL_UNIQUE_ID_NV                                                 = 0x20CE
const GL_NON_CONFORMANT_CONFIG                                        = 0x800D
const GL_SLOW_CONFIG                                                  = 0x8001
const GL_SYNC_FRAME_SGIX                                              = 0x00000000
const GL_BAD_HYPERPIPE_CONFIG_SGIX                                    = 91
const GL_BACK_LEFT_EXT                                                = 0x20E0
const GL_TEXTURE_TARGET_EXT                                           = 0x20D6
const GL_SAMPLE_BUFFERS_SGIS                                          = 100000
const GL_DRAWABLE_TYPE_SGIX                                           = 0x8010
const GL_SWAP_INTERVAL_EXT                                            = 0x20F1
const GL_SWAP_UNDEFINED_OML                                           = 0x8063
const GL_MIPMAP_TEXTURE_EXT                                           = 0x20D7
const GL_FLOAT_COMPONENTS_NV                                          = 0x20B0
const GL_STENCIL_BUFFER_BIT                                           = 0x00000040
const GL_AUX8_EXT                                                     = 0x20EA
const GL_COVERAGE_SAMPLES_NV                                          = 100001
const GL_DRAWABLE_TYPE                                                = 0x8010
const GL_BAD_HYPERPIPE_SGIX                                           = 92
const GL_AUX1_EXT                                                     = 0x20E3
const GL_PBUFFER_BIT_SGIX                                             = 0x00000004
const GL_GPU_NUM_PIPES_AMD                                            = 0x21A5
const GL_TRANSPARENT_RED_VALUE_EXT                                    = 0x25
const GL_TRANSPARENT_INDEX                                            = 0x8009
const GL_VIDEO_OUT_ALPHA_NV                                           = 0x20C4
const GL_STATIC_COLOR_EXT                                             = 0x8005
const GL_TRANSPARENT_INDEX_EXT                                        = 0x8009
const GL_CONTEXT_ES_PROFILE_BIT_EXT                                   = 0x00000004
const GL_GRAY_SCALE_EXT                                               = 0x8006
const GL_HYPERPIPE_STEREO_SGIX                                        = 0x00000003
const GL_SAMPLE_BUFFERS_3DFX                                          = 0x8050
const GL_MAX_PBUFFER_WIDTH_SGIX                                       = 0x8016
const GL_ACCUM_BUFFER_BIT                                             = 0x00000080
const GL_FRONT_LEFT_BUFFER_BIT_SGIX                                   = 0x00000001
const GL_DEVICE_ID_NV                                                 = 0x20CD
const GL_RGBA_FLOAT_TYPE_ARB                                          = 0x20B9
const GL_PBUFFER_SGIX                                                 = 0x8023
const GL_GPU_NUM_SPI_AMD                                              = 0x21A8
const GL_VIDEO_OUT_DEPTH_NV                                           = 0x20C5
const GL_FRONT_RIGHT_BUFFER_BIT_SGIX                                  = 0x00000002
const GL_TRANSPARENT_GREEN_VALUE_EXT                                  = 0x26
const GL_COLOR_INDEX_BIT                                              = 0x00000002
const GL_RENDER_TYPE_SGIX                                             = 0x8011
const GL_SAVED                                                        = 0x8021
const GL_VIDEO_OUT_STACKED_FIELDS_1_2_NV                              = 0x20CB
const GL_FRAMEBUFFER_SRGB_CAPABLE_ARB                                 = 0x20B2
const GL_STENCIL_BUFFER_BIT_SGIX                                      = 0x00000040
const GL_BIND_TO_TEXTURE_RGBA_EXT                                     = 0x20D1
const GL_X3DFX_WINDOW_MODE_MESA                                       = 0x1
const GL_PBUFFER_HEIGHT                                               = 0x8040
const GL_HYPERPIPE_PIXEL_AVERAGE_SGIX                                 = 0x00000004
const GL_OPTIMAL_PBUFFER_HEIGHT_SGIX                                  = 0x801A
const GL_HYPERPIPE_RENDER_PIPE_SGIX                                   = 0x00000002
const GL_GPU_VENDOR_AMD                                               = 0x1F00
const GL_VIDEO_OUT_FIELD_1_NV                                         = 0x20C9
const GL_PBUFFER                                                      = 0x8023
const GL_BACK_RIGHT_BUFFER_BIT_SGIX                                   = 0x00000008
const GL_TRANSPARENT_RGB                                              = 0x8008
const GL_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB                 = 0x2095
const GL_EVENT_MASK_SGIX                                              = 0x801F
const GL_AUX_BUFFERS_BIT_SGIX                                         = 0x00000010
const GL_COLOR_SAMPLES_NV                                             = 0x20B3
const GL_STATIC_GRAY                                                  = 0x8007
const GL_BUFFER_CLOBBER_MASK_SGIX                                     = 0x08000000
const GL_BACK_LEFT_BUFFER_BIT                                         = 0x00000004
const GL_RGBA_FLOAT_BIT_ARB                                           = 0x00000004
const GL_VIDEO_OUT_STACKED_FIELDS_2_1_NV                              = 0x20CC
const GL_PRESERVED_CONTENTS_SGIX                                      = 0x801B
const GL_GRAY_SCALE                                                   = 0x8006
const GL_RGBA_UNSIGNED_FLOAT_TYPE_EXT                                 = 0x20B1
const GL_AUX2_EXT                                                     = 0x20E4
const GL_SAVED_SGIX                                                   = 0x8021
const GL_EXCHANGE_COMPLETE_INTEL                                      = 0x8180
const GL_GPU_NUM_RB_AMD                                               = 0x21A7
const GL_NUM_VIDEO_CAPTURE_SLOTS_NV                                   = 0x20CF
const GL_VIDEO_OUT_FRAME_NV                                           = 0x20C8
const GL_TRANSPARENT_ALPHA_VALUE_EXT                                  = 0x28
const GL_PIPE_RECT_SGIX                                               = 0x00000001
const GL_DEPTH_BUFFER_BIT_SGIX                                        = 0x00000020
const GL_SYNC_SWAP_SGIX                                               = 0x00000001
const GL_SAMPLES                                                      = 100001
const GL_SWAP_METHOD_OML                                              = 0x8060
const GL_TEXTURE_FORMAT_RGBA_EXT                                      = 0x20DA
const GL_HEIGHT                                                       = 0x801E
const GL_AUX9_EXT                                                     = 0x20EB
const GL_AUX0_EXT                                                     = 0x20E2
const GL_DAMAGED                                                      = 0x8020
const GL_TEXTURE_2D_EXT                                               = 0x20DC
const GL_DONT_CARE                                                    = 0xFFFFFFFF
const GL_X_RENDERABLE_SGIX                                            = 0x8012
const GL_NON_CONFORMANT_VISUAL_EXT                                    = 0x800D
const GL_VISUAL_SELECT_GROUP_SGIX                                     = 0x8028
const GL_TEXTURE_2D_BIT_EXT                                           = 0x00000002
const GL_DAMAGED_SGIX                                                 = 0x8020
const GL_VIDEO_OUT_COLOR_NV                                           = 0x20C3
const GL_CONTEXT_MINOR_VERSION_ARB                                    = 0x2092
const GL_ACCUM_BUFFER_BIT_SGIX                                        = 0x00000080
const GL_STATIC_GRAY_EXT                                              = 0x8007
const GL_FBCONFIG_ID                                                  = 0x8013
const GL_CONTEXT_CORE_PROFILE_BIT_ARB                                 = 0x00000001
const GL_TRANSPARENT_INDEX_VALUE_EXT                                  = 0x24
const GL_HYPERPIPE_PIPE_NAME_LENGTH_SGIX                              = 80
const GL_CONTEXT_PROFILE_MASK_ARB                                     = 0x9126
const GL_TEXTURE_1D_EXT                                               = 0x20DB
const GL_MULTISAMPLE_SUB_RECT_WIDTH_SGIS                              = 0x8026
const GL_TRANSPARENT_INDEX_VALUE                                      = 0x24
const GL_X_VISUAL_TYPE_EXT                                            = 0x22
const GL_RGBA_BIT                                                     = 0x00000001
const GL_LARGEST_PBUFFER                                              = 0x801C
const GL_RGBA_BIT_SGIX                                                = 0x00000001
const GL_SAMPLES_3DFX                                                 = 0x8051
const GL_WIDTH                                                        = 0x801D
const GL_PBUFFER_CLOBBER_MASK                                         = 0x08000000
const GL_WINDOW                                                       = 0x8022
const GL_PSEUDO_COLOR                                                 = 0x8004
const GL_WIDTH_SGIX                                                   = 0x801D
const GL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB                        = 0x00000002
const GL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB                      = 0x8256
const GL_BACK_BUFFER_AGE_EXT                                          = 0x20F4
const GL_FRAMEBUFFER_SRGB_CAPABLE_EXT                                 = 0x20B2
const GL_TRANSPARENT_TYPE                                             = 0x23
const GL_TRANSPARENT_TYPE_EXT                                         = 0x23
const GL_VIDEO_OUT_FIELD_2_NV                                         = 0x20CA
const GL_AUX6_EXT                                                     = 0x20E8
const GL_FBCONFIG_ID_SGIX                                             = 0x8013
const GL_BACK_RIGHT_EXT                                               = 0x20E1
const GL_AUX3_EXT                                                     = 0x20E5
const GL_STATIC_COLOR                                                 = 0x8005
const GL_FRONT_EXT                                                    = 0x20DE
const GL_COLOR_INDEX_BIT_SGIX                                         = 0x00000002
const GL_CONTEXT_ROBUST_ACCESS_BIT_ARB                                = 0x00000004
const GL_EVENT_MASK                                                   = 0x801F
const GL_CONTEXT_DEBUG_BIT_ARB                                        = 0x00000001
const GL_FRONT_RIGHT_EXT                                              = 0x20DF
const GL_COLOR_INDEX_TYPE                                             = 0x8015
const GL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB                           = 0x00000002
const GL_Y_INVERTED_EXT                                               = 0x20D4
const GL_SAMPLE_BUFFERS                                               = 100000
const GL_FRONT_LEFT_BUFFER_BIT                                        = 0x00000001
const GL_CONTEXT_ES2_PROFILE_BIT_EXT                                  = 0x00000004
const GL_PRESERVED_CONTENTS                                           = 0x801B
const GL_TEXTURE_1D_BIT_EXT                                           = 0x00000001
const GL_TRANSPARENT_RGB_EXT                                          = 0x8008
const GL_LARGEST_PBUFFER_SGIX                                         = 0x801C
const GL_GPU_RAM_AMD                                                  = 0x21A3
const GL_RGBA_UNSIGNED_FLOAT_BIT_EXT                                  = 0x00000008
const GL_MAX_PBUFFER_PIXELS_SGIX                                      = 0x8018
const GL_X3DFX_FULLSCREEN_MODE_MESA                                   = 0x2
const GL_TEXTURE_RECTANGLE_EXT                                        = 0x20DD
const GL_RGBA_TYPE_SGIX                                               = 0x8014
const GL_GPU_RENDERER_STRING_AMD                                      = 0x1F01
const GL_NUM_VIDEO_SLOTS_NV                                           = 0x20F0
const GL_SAMPLE_BUFFERS_BIT_SGIX                                      = 0x00000100
const GL_MAX_PBUFFER_PIXELS                                           = 0x8018
const GL_HYPERPIPE_ID_SGIX                                            = 0x8030
const GL_OPTIMAL_PBUFFER_WIDTH_SGIX                                   = 0x8019
const GL_DIGITAL_MEDIA_PBUFFER_SGIX                                   = 0x8024
# Export everything!
export glxDestroyPixmap, glxCreateNewContext, glxGetContextIDEXT, glxRenderLarge, glxCopyContext, glxGetFBConfigFromVisualSGIX, glxImportContextEXT, glxGetAGPOffsetMESA, glxChooseFBConfig, glxQueryChannelRectSGIX, glxReleaseVideoCaptureDeviceNV, glxJoinSwapGroupNV, glxReleaseTexImageEXT, glxQuerySwapGroupNV, glxSendPbufferToVideoNV, glxHyperpipeAttribSGIX, glxChooseFBConfigSGIX, glxEnumerateVideoCaptureDevicesNV, glxGetVisualFromFBConfigSGIX, glxVendorPrivate, glxGetProcAddress, glxHyperpipeConfigSGIX, glxChannelRectSyncSGIX, glxGetTransparentIndexSUN, glxGetCurrentReadDrawableSGI, glxCreateGLXPbufferSGIX, glxCreatePbuffer, glxGetFBConfigAttribSGIX, glxQueryMaxSwapBarriersSGIX, glxBindHyperpipeSGIX, glxQueryDrawable, glxCushionSGI, glxQueryVideoCaptureDeviceNV, glxWaitVideoSyncSGI, glxCreateContext, glxCreateContextAttribsARB, glxQueryMaxSwapGroupsNV, glxGetVideoSyncSGI, glxSelectEvent, glxChangeDrawableAttributes, glxQueryHyperpipeConfigSGIX, glxBindSwapBarrierNV, glxCreateGLXPixmap, glxDestroyWindow, glxClientInfo, glxGetFBConfigsSGIX, glxDestroyHyperpipeConfigSGIX, glxVendorPrivateWithReply, glxSwapBuffers, glxCopySubBufferMESA, glxCreateGLXPixmapMESA, glxReleaseBuffersMESA, glxDestroyGLXPbufferSGIX, glxQueryHyperpipeAttribSGIX, glxGetMscRateOML, glxFreeContextEXT, glxReleaseVideoDeviceNV, glxWaitForMscOML, glxCreateGLXPixmapWithConfigSGIX, glxDestroyGLXVideoSourceSGIX, glxWaitForSbcOML, glxSelectEventSGIX, glxGetFBConfigs, glxDestroyGLXPixmap, glxRender, glxBindChannelToWindowSGIX, glxBindTexImageEXT, glxSwapIntervalSGI, glxQueryChannelDeltasSGIX, glxLockVideoCaptureDeviceNV, glxGetFBConfigAttrib, glxQueryContext, glxGetSelectedEvent, glxCreateWindow, glxQueryHyperpipeBestAttribSGIX, glxIsDirect, glxChannelRectSGIX, glxGetCurrentDisplay, glxBindSwapBarrierSGIX, glxCopyImageSubDataNV, glxQueryContextInfoEXT, glxGetVideoInfoNV, glxWaitX, glxQueryServerString, glxJoinSwapGroupSGIX, glxQueryVersion, glxGetCurrentReadDrawable, glxUseXFont, glxReleaseVideoImageNV, glxCreateGLXVideoSourceSGIX, glxQueryFrameCountNV, glxQueryGLXPbufferSGIX, glxEnumerateVideoDevicesNV, glxSwapBuffersMscOML, glxQueryHyperpipeNetworkSGIX, glxGetProcAddressARB, glxGetSyncValuesOML, glxWaitGL, glxMakeCurrentReadSGI, glxDestroyContext, glxAssociateDMPbufferSGIX, glxSet3DfxModeMESA, glxGetSelectedEventSGIX, glxBindVideoCaptureDeviceNV, glxMakeCurrent, glxCreateContextWithConfigSGIX, glxCreatePixmap, glxBindVideoDeviceNV, glxDestroyPbuffer, glxGetVisualConfigs, glxGetCurrentDisplayEXT, glxBindVideoImageNV, glxQueryExtensionsString, glxSwapIntervalEXT, glxGetVisualFromFBConfig, glxGetDrawableAttributes, glxResetFrameCountNV, glxMakeContextCurrent, glxGetDrawableAttributesSGIX, glxChangeDrawableAttributesSGIX, glxGetVideoDeviceNV, GL_VIDEO_OUT_COLOR_AND_ALPHA_NV, GL_SAMPLES_SGIS, GL_HEIGHT_SGIX, GL_PIXMAP_BIT_SGIX, GL_AUX4_EXT, GL_FRONT_LEFT_EXT, GL_TEXTURE_RECTANGLE_BIT_EXT, GL_CONTEXT_MAJOR_VERSION_ARB, GL_TRANSPARENT_RED_VALUE, GL_SCREEN, GL_TRANSPARENT_GREEN_VALUE, GL_TEXTURE_FORMAT_EXT, GL_MAX_PBUFFER_HEIGHT_SGIX, GL_TEXTURE_FORMAT_NONE_EXT, GL_TRANSPARENT_ALPHA_VALUE, GL_GPU_CLOCK_AMD, GL_LATE_SWAPS_TEAR_EXT, GL_BIND_TO_TEXTURE_TARGETS_EXT, GL_DIRECT_COLOR_EXT, GL_CONFIG_CAVEAT, GL_GPU_FASTEST_TARGET_GPUS_AMD, GL_BUFFER_SWAP_COMPLETE_INTEL_MASK, GL_VISUAL_CAVEAT_EXT, GL_PSEUDO_COLOR_EXT, GL_PBUFFER_BIT, GL_AUX5_EXT, GL_RENDER_TYPE, GL_PIPE_RECT_LIMITS_SGIX, GL_MAX_PBUFFER_WIDTH, GL_FLIP_COMPLETE_INTEL, GL_TRUE_COLOR_EXT, GL_BACK_EXT, GL_GPU_OPENGL_VERSION_STRING_AMD, GL_AUX_BUFFERS_BIT, GL_TEXTURE_FORMAT_RGB_EXT, GL_VISUAL_ID, GL_AUX7_EXT, GL_PIXMAP_BIT, GL_NO_RESET_NOTIFICATION_ARB, GL_DIRECT_COLOR, GL_WINDOW_BIT, GL_CONTEXT_FLAGS_ARB, GL_TRANSPARENT_BLUE_VALUE, GL_BIND_TO_TEXTURE_RGB_EXT, GL_DEPTH_BUFFER_BIT, GL_LOSE_CONTEXT_ON_RESET_ARB, GL_RGBA_TYPE, GL_SAMPLE_BUFFERS_ARB, GL_X_RENDERABLE, GL_COPY_COMPLETE_INTEL, GL_NONE, GL_MAX_SWAP_INTERVAL_EXT, GL_BIND_TO_MIPMAP_TEXTURE_EXT, GL_SWAP_EXCHANGE_OML, GL_SHARE_CONTEXT_EXT, GL_TRANSPARENT_BLUE_VALUE_EXT, GL_X_VISUAL_TYPE, GL_HYPERPIPE_DISPLAY_PIPE_SGIX, GL_SAMPLES_ARB, GL_BACK_RIGHT_BUFFER_BIT, GL_GPU_NUM_SIMD_AMD, GL_BACK_LEFT_BUFFER_BIT_SGIX, GL_SLOW_VISUAL_EXT, GL_VISUAL_ID_EXT, GL_COLOR_INDEX_TYPE_SGIX, GL_BLENDED_RGBA_SGIS, GL_MAX_PBUFFER_HEIGHT, GL_TRUE_COLOR, GL_SWAP_COPY_OML, GL_VIDEO_OUT_COLOR_AND_DEPTH_NV, GL_FRONT_RIGHT_BUFFER_BIT, GL_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS, GL_WINDOW_BIT_SGIX, GL_WINDOW_SGIX, GL_PBUFFER_WIDTH, GL_UNIQUE_ID_NV, GL_NON_CONFORMANT_CONFIG, GL_SLOW_CONFIG, GL_SYNC_FRAME_SGIX, GL_BAD_HYPERPIPE_CONFIG_SGIX, GL_BACK_LEFT_EXT, GL_TEXTURE_TARGET_EXT, GL_SAMPLE_BUFFERS_SGIS, GL_DRAWABLE_TYPE_SGIX, GL_SWAP_INTERVAL_EXT, GL_SWAP_UNDEFINED_OML, GL_MIPMAP_TEXTURE_EXT, GL_FLOAT_COMPONENTS_NV, GL_STENCIL_BUFFER_BIT, GL_AUX8_EXT, GL_COVERAGE_SAMPLES_NV, GL_DRAWABLE_TYPE, GL_BAD_HYPERPIPE_SGIX, GL_AUX1_EXT, GL_PBUFFER_BIT_SGIX, GL_GPU_NUM_PIPES_AMD, GL_TRANSPARENT_RED_VALUE_EXT, GL_TRANSPARENT_INDEX, GL_VIDEO_OUT_ALPHA_NV, GL_STATIC_COLOR_EXT, GL_TRANSPARENT_INDEX_EXT, GL_CONTEXT_ES_PROFILE_BIT_EXT, GL_GRAY_SCALE_EXT, GL_HYPERPIPE_STEREO_SGIX, GL_SAMPLE_BUFFERS_3DFX, GL_MAX_PBUFFER_WIDTH_SGIX, GL_ACCUM_BUFFER_BIT, GL_FRONT_LEFT_BUFFER_BIT_SGIX, GL_DEVICE_ID_NV, GL_RGBA_FLOAT_TYPE_ARB, GL_PBUFFER_SGIX, GL_GPU_NUM_SPI_AMD, GL_VIDEO_OUT_DEPTH_NV, GL_FRONT_RIGHT_BUFFER_BIT_SGIX, GL_TRANSPARENT_GREEN_VALUE_EXT, GL_COLOR_INDEX_BIT, GL_RENDER_TYPE_SGIX, GL_SAVED, GL_VIDEO_OUT_STACKED_FIELDS_1_2_NV, GL_FRAMEBUFFER_SRGB_CAPABLE_ARB, GL_STENCIL_BUFFER_BIT_SGIX, GL_BIND_TO_TEXTURE_RGBA_EXT, GL_X3DFX_WINDOW_MODE_MESA, GL_PBUFFER_HEIGHT, GL_HYPERPIPE_PIXEL_AVERAGE_SGIX, GL_OPTIMAL_PBUFFER_HEIGHT_SGIX, GL_HYPERPIPE_RENDER_PIPE_SGIX, GL_GPU_VENDOR_AMD, GL_VIDEO_OUT_FIELD_1_NV, GL_PBUFFER, GL_BACK_RIGHT_BUFFER_BIT_SGIX, GL_TRANSPARENT_RGB, GL_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB, GL_EVENT_MASK_SGIX, GL_AUX_BUFFERS_BIT_SGIX, GL_COLOR_SAMPLES_NV, GL_STATIC_GRAY, GL_BUFFER_CLOBBER_MASK_SGIX, GL_BACK_LEFT_BUFFER_BIT, GL_RGBA_FLOAT_BIT_ARB, GL_VIDEO_OUT_STACKED_FIELDS_2_1_NV, GL_PRESERVED_CONTENTS_SGIX, GL_GRAY_SCALE, GL_RGBA_UNSIGNED_FLOAT_TYPE_EXT, GL_AUX2_EXT, GL_SAVED_SGIX, GL_EXCHANGE_COMPLETE_INTEL, GL_GPU_NUM_RB_AMD, GL_NUM_VIDEO_CAPTURE_SLOTS_NV, GL_VIDEO_OUT_FRAME_NV, GL_TRANSPARENT_ALPHA_VALUE_EXT, GL_PIPE_RECT_SGIX, GL_DEPTH_BUFFER_BIT_SGIX, GL_SYNC_SWAP_SGIX, GL_SAMPLES, GL_SWAP_METHOD_OML, GL_TEXTURE_FORMAT_RGBA_EXT, GL_HEIGHT, GL_AUX9_EXT, GL_AUX0_EXT, GL_DAMAGED, GL_TEXTURE_2D_EXT, GL_DONT_CARE, GL_X_RENDERABLE_SGIX, GL_NON_CONFORMANT_VISUAL_EXT, GL_VISUAL_SELECT_GROUP_SGIX, GL_TEXTURE_2D_BIT_EXT, GL_DAMAGED_SGIX, GL_VIDEO_OUT_COLOR_NV, GL_CONTEXT_MINOR_VERSION_ARB, GL_ACCUM_BUFFER_BIT_SGIX, GL_STATIC_GRAY_EXT, GL_FBCONFIG_ID, GL_CONTEXT_CORE_PROFILE_BIT_ARB, GL_TRANSPARENT_INDEX_VALUE_EXT, GL_HYPERPIPE_PIPE_NAME_LENGTH_SGIX, GL_CONTEXT_PROFILE_MASK_ARB, GL_TEXTURE_1D_EXT, GL_MULTISAMPLE_SUB_RECT_WIDTH_SGIS, GL_TRANSPARENT_INDEX_VALUE, GL_X_VISUAL_TYPE_EXT, GL_RGBA_BIT, GL_LARGEST_PBUFFER, GL_RGBA_BIT_SGIX, GL_SAMPLES_3DFX, GL_WIDTH, GL_PBUFFER_CLOBBER_MASK, GL_WINDOW, GL_PSEUDO_COLOR, GL_WIDTH_SGIX, GL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, GL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GL_BACK_BUFFER_AGE_EXT, GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, GL_TRANSPARENT_TYPE, GL_TRANSPARENT_TYPE_EXT, GL_VIDEO_OUT_FIELD_2_NV, GL_AUX6_EXT, GL_FBCONFIG_ID_SGIX, GL_BACK_RIGHT_EXT, GL_AUX3_EXT, GL_STATIC_COLOR, GL_FRONT_EXT, GL_COLOR_INDEX_BIT_SGIX, GL_CONTEXT_ROBUST_ACCESS_BIT_ARB, GL_EVENT_MASK, GL_CONTEXT_DEBUG_BIT_ARB, GL_FRONT_RIGHT_EXT, GL_COLOR_INDEX_TYPE, GL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, GL_Y_INVERTED_EXT, GL_SAMPLE_BUFFERS, GL_FRONT_LEFT_BUFFER_BIT, GL_CONTEXT_ES2_PROFILE_BIT_EXT, GL_PRESERVED_CONTENTS, GL_TEXTURE_1D_BIT_EXT, GL_TRANSPARENT_RGB_EXT, GL_LARGEST_PBUFFER_SGIX, GL_GPU_RAM_AMD, GL_RGBA_UNSIGNED_FLOAT_BIT_EXT, GL_MAX_PBUFFER_PIXELS_SGIX, GL_X3DFX_FULLSCREEN_MODE_MESA, GL_TEXTURE_RECTANGLE_EXT, GL_RGBA_TYPE_SGIX, GL_GPU_RENDERER_STRING_AMD, GL_NUM_VIDEO_SLOTS_NV, GL_SAMPLE_BUFFERS_BIT_SGIX, GL_MAX_PBUFFER_PIXELS, GL_HYPERPIPE_ID_SGIX, GL_OPTIMAL_PBUFFER_WIDTH_SGIX, GL_DIGITAL_MEDIA_PBUFFER_SGIX


text:
OPT = OneClassActiveLearning.QueryStrategies.QuerySynthesisStrategies.Optimization
@testset "query synthesis optimization" begin
    @testset "particle swarm optimization" begin
        for d in [1, 2, 10]
            @testset "$d dim" begin
                Random.seed!(0)
                f(x) = vec(sum(abs.(x), dims=1))
                x_opt, _ = OPT.pso(f, -ones(d), ones(d))
                @test size(x_opt) == (d,)
                @test all(f(reshape(x_opt, 1, d)) .< 0.015 * d)
            end
        end
    end
    @testset "query optimizers" begin
        MAX_ITER = 1
        for opt in [EvolutionaryOptimization(:cmaes, μ=1, λ=2, iterations=MAX_ITER),
                    ParticleSwarmOptimization(swarmsize=3, maxiter=MAX_ITER),
                    BlackBoxOptimization(:dxnes, MaxSteps=MAX_ITER)]
            for d in [1, 2, 10]
                @testset "$(typeof(opt)): $d dim" begin
                    Random.seed!(0)
                    f(x) = -vec(sum(abs.(x), dims=1))
                    x_opt = OPT.query_synthesis_optimize(f, opt, randn(d, 10), fill(:U, 10))
                    @test size(x_opt) == (d, 1)
                end
            end
        end
    end
end

ext: jl


text:
export
    archicad

macro arch_str(str)
    rpc("ARCH", str)
end
#
abstract type ARCHKey end
const ARCHId = Int
const ARCHIds = Vector{ARCHId}
const ARCHRef = GenericRef{ARCHKey, ARCHId}
const ARCHRefs = Vector{ARCHRef}
const ARCHNativeRef = NativeRef{ARCHKey, ARCHId}
const ARCH = SocketBackend{ARCHKey, ARCHId}

void_ref(b::ARCH) = ARCHNativeRef(-1)

create_archicad_connection() = create_backend_connection("ArchiCAD", 8080)

const archicad = ARCH(LazyParameter(TCPSocket, create_archicad_connection))

encode_std__vector_double_ = encode_double_array
#current_backend(archicad)
arch"int api::createCircle(double x1, double y1, double r)"
arch"int api::createSpline(std::vector<double> x, std::vector<double> y, bool closed)"

realize(b::ARCH, s::Circle) =
  ARCHapi__createCircle(connection(b), s.center.x, s.center.y, s.radius)

b.api__createCircle(s.center)

realize(b::ARCH, s::Spline) =
  ARCHapi__createSpline(connection(b),
                     map(cx, s.points),
                     map(cy, s.points),
                     false)

#=
export
    revit,
    all_walls,
    all_floors,
    RevitSystemFamily,
    RevitFileFamily,
    RevitInPlaceFamily,
    revit_systems_family,
    revit_file_family

macro rvt_str(str)
    rpc("RVT", str)
end

encode_XYZ = encode_Point3d
decode_XYZ = decode_Point3d
encode_XYZ_array = encode_Point3d_array
decode_XYZ_array = decode_Point3d_array
encode_ElementId = encode_int
decode_ElementId = decode_int_or_error_numbered(-1234) # sometimes, Revit returns a id of -1
encode_ElementId_array = encode_int_array
decode_ElementId_array = decode_int_or_error_numbered_array(-1234) # sometimes, Revit returns a id of -1
encode_Element = encode_ElementId
decode_Element = decode_ElementId
decode_Element_array = decode_ElementId_array
encode_Length = encode_double
decode_Length = decode_double
encode_Length_array = encode_double_array
encode_Level = encode_ElementId
decode_Level = decode_ElementId
encode_Level_array = encode_ElementId_array
decode_Level_array = decode_ElementId_array
encode_FloorFamily = encode_int
decode_FloorFamily = decode_int_or_error

rvt"public Element SurfaceGrid(XYZ[] linearizedMatrix, int n, int m)"
rvt"public void MoveElement(ElementId id, XYZ translation)"
rvt"public void RotateElement(ElementId id, double angle, XYZ axis0, XYZ axis1)"
rvt"public Element InsertDoor(Length deltaFromStart, Length deltaFromGround, Element host, ElementId familyId)"
rvt"public Element InsertWindow(Length deltaFromStart, Length deltaFromGround, Element host, ElementId familyId, string[] names, object[] values)"
rvt"public Element InsertRailing(Element host, ElementId familyId)"

rvt"public void CreateFamily(string familyTemplatesPath, string familyTemplateName, string familyName)"
rvt"public void CreateFamilyExtrusionTest(XYZ[] pts, double height)"
rvt"public void InsertFamily(string familyName, XYZ p)"

rvt"public void HighlightElement(ElementId id)"
rvt"public ElementId[] GetSelectedElements()"
rvt"public bool IsProject()"
rvt"public void DeleteAllElements()"
rvt"public void SetView(XYZ camera, XYZ target, double focal_length)"
rvt"public void EnergyAnalysis()"

abstract type RVTKey end
const RVTId = Int
const RVTIds = Vector{RVTId}
const RVTRef = GenericRef{RVTKey, RVTId}
const RVTRefs = Vector{RVTRef}
const RVTNativeRef = NativeRef{RVTKey, RVTId}
const RVT = SocketBackend{RVTKey, RVTId}
const RVTVoidId = -1
void_ref(b::RVT) = RVTNativeRef(RVTVoidId)

create_RVT_connection() = create_backend_connection("Revit", 11001)

const revit = RVT(LazyParameter(TCPSocket, create_RVT_connection))

# Levels

rvt"public Level FindOrCreateLevelAtElevation(Length elevation)"
rvt"public Level UpperLevel(Level level, Length addedElevation)"
rvt"public Length GetLevelElevation(Level level)"

realize(b::RVT, s::Level) =
    RVTFindOrCreateLevelAtElevation(connection(b), s.height)

# Revit also considers unconnected walls. These have a top level with id -1
is_unconnected_level(level::Level) = ref(level).value == -1

# Families
#=

Revit families are divided into
1. System Families (for walls, roofs, floors, pipes)
2. Loadable Families (for building components that have an associated file)
3. In-Place Families (for unique elements created just for the current project)

=#

abstract type RevitFamily <: Family end

struct RevitSystemFamily <: RevitFamily
    family_map::Dict{String, Function}
    instance_map::Dict{String, Function}
    instance_ref::Parameter{RVTId}
end

revit_system_family(family_map=(), instance_map=()) =
    RevitSystemFamily(
        Dict(family_map...),
        Dict(instance_map...),
        Parameter(0)) # instead of RVTVoidId.  We need to think this carefully.

backend_get_family_ref(b::RVT, f::Family, rvtf::RevitSystemFamily) =
  let c = connection(b)
    if rvtf.instance_ref()===RVTVoidId
      let param_map = rvtf.family_map,
          params = keys(param_map)
        rvtf.instance_ref(
            RVTFamilyElement(
                c,
                0,
                collect(keys),
                [param_map[param](f) for param in params]))
      end
    end
    rvtf.instance_ref()
  end

struct RevitFileFamily <: RevitFamily
    path::String
    family_map::Dict{String, Function}
    instance_map::Dict{String, Function}
    family_ref::Parameter{RVTId}
    instance_ref::Parameter{RVTId}
end

revit_file_family(path, family_map=(), instance_map=()) =
    RevitFileFamily(
        path,
        Dict(family_map...),
        Dict(instance_map...),
        Parameter(RVTVoidId),
        Parameter(RVTVoidId))

backend_get_family_ref(b::RVT, f::Family, rvtf::RevitFileFamily) =
  let c = connection(b)
    if true #rvtf.family_ref()===RVTVoidId
      rvtf.family_ref(RVTLoadFamily(c, rvtf.path))
    end
    if true #rvtf.instance_ref()===RVTVoidId
      let param_map = rvtf.family_map,
          params = keys(param_map)
        rvtf.instance_ref(
            RVTFamilyElement(
                c,
                rvtf.family_ref(),
                collect(params),
                [param_map[param](f) for param in params]))
      end
    end
    rvtf.instance_ref()
  end
#

# This is for future use
struct RevitInPlaceFamily <: RevitFamily
    parameter_map::Dict{Symbol,String}
    ref::Parameter{Int}
end

rvt"public ElementId LoadFamily(string fileName)"
rvt"public ElementId FamilyElement(ElementId familyId, string[] names, Length[] values)"

#AML This must be defined in the backend
rvt"public String InstalledLibraryPath(String name)"
# C:\\ProgramData\\Autodesk\\RVT 2017\\Libraries\\US Metric\\

set_backend_family(default_wall_family(), revit, revit_system_family())
set_backend_family(default_window_family(), revit, revit_system_family())
#=
set_backend_family(default_slab_family(), revit, revit_system_family())
set_backend_family(default_beam_family(), revit, revit_file_family(
      RVTInstalledLibraryPath(connection(revit)), "Structural Framing\\Wood\\M_Timber.rfa"),
      :width=>"b", :height=>"d"))
#set_backend_family(default_column_family(), unity, unity_material_family("Materials/Concrete/Concrete2"))
#set_backend_family(default_door_family(), unity, unity_material_family("Materials/Wood/InteriorWood2"))
#set_backend_family(default_panel_family(), unity, unity_material_family("Materials/Glass"))

=#

switch_to_backend(from::Backend, to::RVT) =
    let height = level_height(default_level())
        current_backend(to)
        default_level(level(height))
    end

#=
backend_get_family(b::RVT, f::TableFamily) =
    RVTCreateRectangularTableFamily(connection(b), f.length, f.width, f.height, f.top_thickness, f.leg_thickness)
backend_get_family(b::RVT, f::ChairFamily) =
    RVTCreateChairFamily(connection(b), f.length, f.width, f.height, f.seat_height, f.thickness)
backend_get_family(b::RVT, f::TableChairFamily) =
    RVTCreateRectangularTableAndChairsFamily(connection(b),
        ref(f.table_family), ref(f.chair_family),
        f.table_family.length, f.table_family.width,
        f.chairs_top, f.chairs_bottom, f.chairs_right, f.chairs_left,
        f.spacing)

backend_rectangular_table(b::RVT, c, angle, family) =
    RVTTable(connection(b), c, angle, ref(family))

backend_chair(b::RVT, c, angle, family) =
    RVTChair(connection(b), c, angle, ref(family))

backend_rectangular_table_and_chairs(b::RVT, c, angle, family) =
    RVTTableAndChairs(connection(b), c, angle, ref(family))
=#

rvt"public ElementId CreatePolygonalFloor(XYZ[] pts, ElementId levelId)"
rvt"public ElementId CreatePolygonalRoof(XYZ[] pts, ElementId levelId, ElementId famId)"
rvt"public ElementId CreatePathFloor(XYZ[] pts, double[] angles, ElementId levelId)"
rvt"public ElementId CreatePathRoof(XYZ[] pts, double[] angles, ElementId levelId, ElementId famId)"

locs_and_arcs(arc::ArcPath) =
    ([arc.center + vpol(arc.radius, arc.start_angle)],
     [arc.amplitude])

locs_and_arcs(circle::CircularPath) =
    let (locs1, arcs1) = locs_and_arcs(arc_path(circle.center, circle.radius, 0, pi))
        (locs2, arcs2) = locs_and_arcs(arc_path(circle.center, circle.radius, pi, pi))
        ([locs1..., locs2...], [arcs1..., arcs2...])
    end

realize_slab(b::RVT, contour::ClosedPath, holes::Vector{<:ClosedPath}, level::Level, family::SlabFamily) =
    let (locs, arcs) = locs_and_arcs(contour)
        @assert length(holes) == 0
        RVTCreatePathFloor(connection(b), locs, arcs, ref(level).value)
        # we are not using the family yet
        # ref(s.family))
    end

realize_slab(b::RVT, contour::ClosedPolygonalPath, holes::Vector{<:ClosedPath}, level::Level, family::SlabFamily) =
  begin
      @assert length(holes) == 0
    RVTCreatePolygonalFloor(
        connection(b),
        convert(ClosedPolygonalPath, contour).vertices,
        ref(level).value)
        # we are not using the family yet
        # ref(s.family))
    end

realize_slab(b::RVT, contour::RectangularPath, holes::Vector{<:ClosedPath}, level::Level, family::SlabFamily) =
    realize_slab(b, convert(ClosedPolygonalPath, contour), holes, level, family)

rvt"public void CreatePolygonalOpening(XYZ[] pts, Element host)"
rvt"public void CreatePathOpening(XYZ[] pts, double[] angles, Element host)"

realize_slab_openings(b::RVT, s::Slab, s_ref, openings) =
    let s_base_height = s.level.height
        for opening in openings
            realize_slab_opening(b, s, opening)
        end
        s_ref
    end

realize_slab_opening(b::RVT, s::Slab, contour::ClosedPath) =
    let (locs, arcs) = locs_and_arcs(contour)
        RVTCreatePathOpening(connection(b), locs, arcs, ref(s).value)
    end
realize_slab_opening(b::RVT, s::Slab, contour::ClosedPolygonalPath) =
        RVTCreatePolygonalOpening(
            connection(b),
            convert(ClosedPolygonalPath, contour).vertices,
            ref(s).value)

rvt"public ElementId CreateBeam(XYZ p0, XYZ p1, double rotationAngle, ElementId famId)"

#Beams are aligned along the top axis.
realize(b::RVT, s::Beam) =
    let o = loc_from_o_phi(s.cb, s.angle)
        RVTCreateBeam(connection(b), o, add_z(o, s.h), s.angle, ref(s.family))
    end

rvt"public Element CreateColumn(XYZ location, ElementId baseLevelId, ElementId topLevelId, ElementId famId)"
rvt"public Element CreateColumnPoints(XYZ p0, XYZ p1, Level level0, Level level1, ElementId famId)"

#Columns are aligned along the center axis.

realize(b::RVT, s::Column) =
    let b = loc_from_o_phi(s.cb, s.angle)
        t = add_z(o, s.h)
        RVTCreateColumnPoints(connection(b), b, t,
            RVTFindOrCreateLevelAtElevation(connection(b), loc_in_world(b).z),
            RVTFindOrCreateLevelAtElevation(connection(b), loc_in_world(t).z),
            ref(s.family))
    end

#
rvt"public ElementId[] CreateLineWall(XYZ[] pts, ElementId baseLevelId, ElementId topLevelId, ElementId famId)"
rvt"public ElementId[] CreateUnconnectedLineWall(XYZ[] pts, ElementId baseLevelId, double height, ElementId famId)"
rvt"public ElementId CreateSplineWall(XYZ[] pts, ElementId baseLevelId, ElementId topLevelId, ElementId famId, bool closed)"
rvt"public Element CreateLineRailing(XYZ[] pts, ElementId baseLevelId, ElementId familyId)"
rvt"public Element CreatePolygonRailing(XYZ[] pts, ElementId baseLevelId, ElementId familyId)"

realize_wall_no_openings(b::RVT, s::Wall) =
    if is_unconnected_level(s.top_level)
        RVTCreateUnconnectedLineWall(
            connection(b),
            convert(OpenPolygonalPath, s.path).vertices,
            ref(s.bottom_level).value,
            s.top_level.height - s.bottom_level.height,
            realize(b, s.family))
    else
        RVTCreateLineWall(
            connection(b),
            convert(OpenPolygonalPath, s.path).vertices,
            ref(s.bottom_level).value,
            ref(s.top_level).value,
            realize(b, s.family))
    end

realize_wall_openings(b::RVT, w::Wall, w_ref, openings) =
  begin
      for opening in openings
          realize(b, opening)
      end
      w_ref
  end

realize(b::RVT, s::Window) =
  let rvtf = backend_family(b, s.family),
      param_map = rvtf.instance_map,
      params = keys(param_map)
    RVTInsertWindow(
        connection(b),
        s.loc.x,
        s.loc.y,
        ref(s.wall).value,
        backend_get_family_ref(b, s.family, rvtf),
        collect(params),
        [param_map[param](s.family) for param in params])
  end

backend_add_door(b::RVT, w::Wall, loc::Loc, family::DoorFamily) = finish_this()
backend_add_window(b::RVT, w::Wall, loc::Loc, family::WindowFamily) =
    let d = window(w, loc, family=family)
        push!(w.windows, d)
        if realized(w) && ! realized(d)
            realize(b, d)
        end
        w
    end

############################################

backend_bounding_box(b::RVT, shapes::Shapes) =
  RVTBoundingBox(connection(b), collect_ref(shapes))

backend_name(b::RVT) = "Revit"

set_view(camera::Loc, target::Loc, lens::Real, b::RVT) =
  RVTSetView(connection(b), camera, target, lens)

get_view(b::RVT) =
  let c = connection(b)
    RVTViewCamera(c), RVTViewTarget(c), RVTViewLens(c)
  end

zoom_extents(b::RVT) = RVTZoomExtents(connection(b))

view_top(b::RVT) =
    RVTViewTop(connection(b))

delete_all_shapes(b::RVT) = RVTDeleteAllElements(connection(b))

prompt_position(prompt::String, b::RVT) =
  let ans = RVTGetPoint(connection(b), prompt)
    length(ans) > 0 && ans[1]
  end

shape_from_ref(r, b::RVT) =
    let c = connection(b)
        code = RVTShapeCode(c, r)
        if code == 1
            point(RVTPointPosition(c, r),
                  backend=b, ref=LazyRef(b, RVTNativeRef(r)))
        elseif code == 2
            circle(maybe_loc_from_o_vz(RVTCircleCenter(c, r), RVTCircleNormal(c, r)),
                   RVTCircleRadius(c, r),
                   backend=b, ref=LazyRef(b, RVTNativeRef(r)))
        elseif 3 <= code <= 6
            line(RVTLineVertices(c, r),
                 backend=b, ref=LazyRef(b, RVTNativeRef(r)))
        elseif code == 7
            spline([xy(0,0)], false, false, #HACK obtain interpolation points
                   backend=b, ref=LazyRef(b, RVTNativeRef(r)))
        elseif code == 9
            let start_angle = mod(RVTArcStartAngle(c, r), 2pi)
                end_angle = mod(RVTArcEndAngle(c, r), 2pi)
                if end_angle > start_angle
                    arc(maybe_loc_from_o_vz(RVTArcCenter(c, r), RVTArcNormal(c, r)),
                        RVTArcRadius(c, r), start_angle, end_angle - start_angle,
                        backend=b, ref=LazyRef(b, RVTNativeRef(r)))
                else
                    arc(maybe_loc_from_o_vz(RVTArcCenter(c, r), RVTArcNormal(c, r)),
                        RVTArcRadius(c, r), end_angle, start_angle - end_angle,
                        backend=b, ref=LazyRef(b, RVTNativeRef(r)))
                end
            end
        elseif code == 10
            let str = RVTTextString(c, r)
                height = RVTTextHeight(c, r)
                loc = RVTTextPosition(c, r)
                text(str, loc, height, backend=b, ref=LazyRef(b, RVTNativeRef(r)))
            end
        elseif code == 11
            let str = RVTMTextString(c, r)
                height = RVTMTextHeight(c, r)
                loc = RVTMTextPosition(c, r)
                text(str, loc, height, backend=b, ref=LazyRef(b, RVTNativeRef(r)))
            end
        elseif code == 50
            block_instance(block("To be finished!"))
        elseif code == 70
            block_instance(block("A viewport to be finished!"))
        elseif 103 <= code <= 106
            polygon(RVTLineVertices(c, r),
                    backend=b, ref=LazyRef(b, RVTNativeRef(r)))
        else
            block_instance(block("Unknown shape. To be finished!"))
            #error("Unknown shape with code $(code)")
        end
    end

all_shapes(b::RVT) =
  [shape_from_ref(r, b) for r in RVTGetAllShapes(connection(b))]

all_shapes_in_layer(layer, b::RVT) =
  [shape_from_ref(r) for r in RVTGetAllShapesInLayer(connection(b), layer)]

disable_update(b::RVT) =
    RVTDisableUpdate(connection(b))

enable_update(b::RVT) =
    RVTEnableUpdate(connection(b))

rvt"public Level[] DocLevels()"
rvt"public Element[] DocElements()"
rvt"public Element[] DocFamilies()"
rvt"public Element[] DocFloors()"
rvt"public Element[] DocCeilings()"
rvt"public Element[] DocWalls()"
rvt"public Element[] DocWallsAtLevel(Level level)"
rvt"public XYZ[] LineWallVertices(Element element)"
rvt"public ElementId ElementLevel(Element element)"
rvt"public ElementId WallTopLevel(Element element)"
rvt"public double WallHeight(Element element)"

all_levels(b::RVT) =
    [level_from_ref(r, b) for r in RVTDocLevels(connection(b))]

level_from_ref(r, b::RVT) =
    let c = connection(b)
        level(r == -1 ?
                error("Level for unconnected height") :
                RVTGetLevelElevation(c, r),
              backend=b, ref=LazyRef(b, RVTNativeRef(r)))
    end

unconnected_level(h::Real, b::RVT) =
    level(h, backend=b, ref=LazyRef(b, RVTNativeRef(-1)))

all_Elements(b::RVT) =
    [element_from_ref(r, b) for r in RVTDocElements(connection(b))]

element_from_ref(r, b::RVT) =
    let c = connection(b)
        Foo(Bar(c, r), backend=b, ref=LazyRef(b, RVTNativeRef(r)))
    end

all_floors(b::RVT) =
    [floor_from_ref(r, b) for r in RVTFloorElements(connection(b))]

floor_from_ref(r, b::RVT) =
    let c = connection(b)
        Foo(Bar(c, r), backend=b, ref=LazyRef(b, RVTNativeRef(r)))
    end

all_walls(b::RVT) =
    [wall_from_ref(r, b) for r in RVTDocWalls(connection(b))]
all_walls_at_level(level::Level, b::RVT) =
    [wall_from_ref(r, b) for r in RVTDocWallsAtLevel(connection(b), ref(level).value)]

wall_from_ref(r, b::RVT) =
    let c = connection(b)
        path = convert(Path, RVTLineWallVertices(c, r))
        bottom_level_id = RVTElementLevel(c, r)
        top_level_id = RVTWallTopLevel(c, r)
        bottom_level = level_from_ref(bottom_level_id, b)
        top_level = top_level_id == -1 ?
                        unconnected_level(bottom_level.height + RVTWallHeight(c, r), b) :
                        level_from_ref(top_level_id, b)
        wall(path,
             bottom_level=bottom_level,
             top_level=top_level,
             backend=b,
             ref=LazyRef(b, RVTNativeRef(r)))
    end

#=

struct revit_family
    path::String
    map::Dict
end

struct archicad_family
    name::String
    map::Dict
end

# for a non-BIM backend
bars_family = beam_family(width=10,height=20,based_on=Dict(
    revit => revit_family(
        "C:\\ProgramData\\Autodesk\\RVT 2017\\Libraries\\US Metric\\Structural Framing\\Steel\\M_HSS-Hollow Structural Section.rfa",
        Dict(:width=>"b", :height=>"d", :angle=>"Cross-Section Rotation"))
#    archicad => archicad_family("SpecialBeam", Dict(:width=>"width", :height=>"height"))
))

=#

=#


text:
module PLaplacianTests
using SparseMatricesCSR
using Gridap
using Gridap.Algebra
using GridapDistributed
using PartitionedArrays
using Test
using SparseArrays

function main(parts)
  main(parts,FullyAssembledRows(),SparseMatrixCSR{0,Float64,Int})
  main(parts,SubAssembledRows(),SparseMatrixCSC{Float64,Int})
end

function main(parts,strategy,local_matrix_type)

  output = mkpath(joinpath(@__DIR__,"output"))

  domain = (0,4,0,4)
  cells = (4,4)
  model = CartesianDiscreteModel(parts,domain,cells)

  k = 1
  u((x,y)) = (x+y)^k
  σ(∇u) =(1.0+∇u⋅∇u)*∇u
  dσ(∇du,∇u) = 2*∇u⋅∇du + (1.0+∇u⋅∇u)*∇du
  f(x) = -divergence(y->σ(∇(u,y)),x)

  Ω = Triangulation(strategy,model)
  dΩ = Measure(Ω,2*k)
  r(u,v) = ∫( ∇(v)⋅(σ∘∇(u)) - v*f )dΩ
  j(u,du,v) = ∫( ∇(v)⋅(dσ∘(∇(du),∇(u))) )dΩ

  reffe = ReferenceFE(lagrangian,Float64,k)
  V = TestFESpace(model,reffe,dirichlet_tags="boundary")
  U = TrialFESpace(u,V)

  assem=SparseMatrixAssembler(local_matrix_type,Vector{Float64},U,V,strategy)
  op = FEOperator(r,j,U,V,assem)

  uh = zero(U)
  b,A = residual_and_jacobian(op,uh)
  _A = copy(A)
  _b = copy(b)
  residual_and_jacobian!(_b,_A,op,uh)
  @test (norm(_b-b)+1) ≈ 1
  x = similar(b,Float64,axes(A,2))
  fill!(x,1)
  @test (norm(A*x-_A*x)+1) ≈ 1

  # This leads to a dead lock since the printing of the trace seems to lead to collective operations
  # show_trace = i_am_main(parts)
  show_trace = true # The output in MPI will be ugly, but fixing this would require to edit NLSolvers package.
  nls = NLSolver(show_trace=show_trace, method=:newton)
  solver = FESolver(nls)
  uh = solve(solver,op)

  Ωo = Triangulation(model)
  dΩo = Measure(Ωo,2*k)
  eh = u - uh
  @test sqrt(sum(∫( abs2(eh) )dΩo)) < 1.0e-9

end

end # module


text:
# stolen from https://github.com/EnzymeAD/Enzyme.jl/blob/1b187cc16953727cab26b64bc6a6dcf106c29a57/src/compiler/optimize.jl#L213

function optimize!(mod::LLVM.Module, tm)
    # everying except unroll, slpvec, loop-vec
    # then finish Julia GC
    ModulePassManager() do pm
        add_library_info!(pm, triple(mod))
        add_transform_info!(pm, tm)

        propagate_julia_addrsp!(pm)
        scoped_no_alias_aa!(pm)
        type_based_alias_analysis!(pm)
        basic_alias_analysis!(pm)
        cfgsimplification!(pm)
        dce!(pm)
@static if isdefined(GPUCompiler, :cpu_features!)
        GPUCompiler.cpu_features!(pm)
end
        scalar_repl_aggregates_ssa!(pm) # SSA variant?
        mem_cpy_opt!(pm)
        always_inliner!(pm)
        alloc_opt!(pm)
        instruction_combining!(pm)
        cfgsimplification!(pm)
        scalar_repl_aggregates_ssa!(pm) # SSA variant?
        instruction_combining!(pm)
        jump_threading!(pm)
        correlated_value_propagation!(pm)
        instruction_combining!(pm)
        reassociate!(pm)
        early_cse!(pm)
        alloc_opt!(pm)
        loop_idiom!(pm)
        loop_rotate!(pm)
        lower_simdloop!(pm)
        licm!(pm)
        loop_unswitch!(pm)
        instruction_combining!(pm)
        ind_var_simplify!(pm)
        loop_deletion!(pm)
        loop_unroll!(pm)
        alloc_opt!(pm)
        scalar_repl_aggregates_ssa!(pm) # SSA variant?
        gvn!(pm)
        # This InstCombine needs to be after GVN
        # Otherwise it will generate load chains in GPU code...
        instruction_combining!(pm)
        mem_cpy_opt!(pm)
        sccp!(pm)
        instruction_combining!(pm)
        jump_threading!(pm)
        dead_store_elimination!(pm)
        alloc_opt!(pm)
        cfgsimplification!(pm)
        loop_idiom!(pm)
        loop_deletion!(pm)
        jump_threading!(pm)
        correlated_value_propagation!(pm)
        # SLP_Vectorizer -- not for Enzyme
        aggressive_dce!(pm)
        instruction_combining!(pm)
        # Loop Vectorize -- not for Enzyme
        # InstCombine

        # GC passes
        barrier_noop!(pm)
        gc_invariant_verifier!(pm, false)

        # FIXME: Currently crashes printing
        cfgsimplification!(pm)
        instruction_combining!(pm) # Extra for Enzyme
        #API.EnzymeAddAttributorLegacyPass(pm)
        run!(pm, mod)
    end
    # @show "omod", mod
    # flush(stdout)
    # flush(stderr)
end

# https://github.com/JuliaLang/julia/blob/2eb5da0e25756c33d1845348836a0a92984861ac/src/aotcompile.cpp#L603
function addTargetPasses!(pm, tm)
    add_library_info!(pm, LLVM.triple(tm))
    add_transform_info!(pm, tm)
end

# https://github.com/JuliaLang/julia/blob/2eb5da0e25756c33d1845348836a0a92984861ac/src/aotcompile.cpp#L620
function addOptimizationPasses!(pm)
    constant_merge!(pm)

    propagate_julia_addrsp!(pm)
    scoped_no_alias_aa!(pm)
    type_based_alias_analysis!(pm)
    basic_alias_analysis!(pm)
    cfgsimplification!(pm)
    dce!(pm)
    scalar_repl_aggregates!(pm)

    # mem_cpy_opt!(pm)

    always_inliner!(pm) # Respect always_inline

    # Running `memcpyopt` between this and `sroa` seems to give `sroa` a hard time
    # merging the `alloca` for the unboxed data and the `alloca` created by the `alloc_opt`
    # pass.

    alloc_opt!(pm)
    # consider AggressiveInstCombinePass at optlevel > 2

    instruction_combining!(pm)
    cfgsimplification!(pm)
    scalar_repl_aggregates!(pm)
    instruction_combining!(pm) # TODO: createInstSimplifyLegacy
    jump_threading!(pm)
    correlated_value_propagation!(pm)

    reassociate!(pm)

    early_cse!(pm)

    # Load forwarding above can expose allocations that aren't actually used
    # remove those before optimizing loops.
    alloc_opt!(pm)
    loop_rotate!(pm)
    # moving IndVarSimplify here prevented removing the loop in perf_sumcartesian(10:-1:1)
    loop_idiom!(pm)

    # LoopRotate strips metadata from terminator, so run LowerSIMD afterwards
    lower_simdloop!(pm) # Annotate loop marked with "loopinfo" as LLVM parallel loop
    licm!(pm)
    julia_licm!(pm)
    # Subsequent passes not stripping metadata from terminator
    instruction_combining!(pm) # TODO: createInstSimplifyLegacy
    ind_var_simplify!(pm)
    loop_deletion!(pm)
    loop_unroll!(pm) # TODO: in Julia createSimpleLoopUnroll

    # Run our own SROA on heap objects before LLVM's
    alloc_opt!(pm)
    # Re-run SROA after loop-unrolling (useful for small loops that operate,
    # over the structure of an aggregate)
    scalar_repl_aggregates!(pm)
    instruction_combining!(pm) # TODO: createInstSimplifyLegacy

    gvn!(pm)
    mem_cpy_opt!(pm)
    sccp!(pm)

    # Run instcombine after redundancy elimination to exploit opportunities
    # opened up by them.
    # This needs to be InstCombine instead of InstSimplify to allow
    # loops over Union-typed arrays to vectorize.
    instruction_combining!(pm)
    jump_threading!(pm)
    dead_store_elimination!(pm)

    # More dead allocation (store) deletion before loop optimization
    # consider removing this:
    alloc_opt!(pm)

    # see if all of the constant folding has exposed more loops
    # to simplification and deletion
    # this helps significantly with cleaning up iteration
    cfgsimplification!(pm)
    loop_deletion!(pm)
    instruction_combining!(pm)
    loop_vectorize!(pm)
    # TODO: createLoopLoadEliminationPass
    cfgsimplification!(pm)
    slpvectorize!(pm)
    # might need this after LLVM 11:
    # TODO: createVectorCombinePass()

    aggressive_dce!(pm)
end

function addMachinePasses!(pm)
    combine_mul_add!(pm)
    # TODO: createDivRemPairs[]

    demote_float16!(pm)
    gvn!(pm)
end

function addJuliaLegalizationPasses!(pm, lower_intrinsics=true)
    if lower_intrinsics
        # LowerPTLS removes an indirect call. As a result, it is likely to trigger
        # LLVM's devirtualization heuristics, which would result in the entire
        # pass pipeline being re-exectuted. Prevent this by inserting a barrier.
        barrier_noop!(pm)
        lower_exc_handlers!(pm)
        gc_invariant_verifier!(pm, false)

        # Needed **before** LateLowerGCFrame on LLVM < 12
        # due to bug in `CreateAlignmentAssumption`.
        remove_ni!(pm)
        late_lower_gc_frame!(pm)
        final_lower_gc!(pm)
        # We need these two passes and the instcombine below
        # after GC lowering to let LLVM do some constant propagation on the tags.
        # and remove some unnecessary write barrier checks.
        gvn!(pm)
        sccp!(pm)
        # Remove dead use of ptls
        dce!(pm)
        lower_ptls!(pm, #=dump_native=# false)
        instruction_combining!(pm)
        # Clean up write barrier and ptls lowering
        cfgsimplification!(pm)
    else
        barrier_noop!(pm)
        remove_ni!(pm)
    end
end

function post_optimize!(mod, tm)
    # @show "pre_post", mod
    # flush(stdout)
    # flush(stderr)
    LLVM.ModulePassManager() do pm
        addTargetPasses!(pm, tm)
        addOptimizationPasses!(pm)
        run!(pm, mod)
    end
    LLVM.ModulePassManager() do pm
        addJuliaLegalizationPasses!(pm, true)
        addMachinePasses!(pm)
        run!(pm, mod)
    end
    # @show "post_mod", mod
    # flush(stdout)
    # flush(stderr)
end

const inactivefns = Set{String}((
    "jl_gc_queue_root", "gpu_report_exception", "gpu_signal_exception",
    "julia.ptls_states", "julia.write_barrier", "julia.typeof", "jl_box_int64", "jl_box_int32",
    "jl_subtype", "julia.get_pgcstack", "jl_in_threaded_region", "jl_object_id_", "jl_object_id",
    "jl_breakpoint",
    "llvm.julia.gc_preserve_begin","llvm.julia.gc_preserve_end", "jl_get_ptls_states",
    "jl_f_fieldtype",
    "jl_symbol_n",
    # BIG TODO
    "jl_gc_add_finalizer_th",
    # "jl_"
))

const activefns = Set{String}((
    "jl_",
))

function annotate!(mod)
    ctx = context(mod)
    inactive = LLVM.StringAttribute("enzyme_inactive", ""; ctx)
    active = LLVM.StringAttribute("enzyme_active", ""; ctx)
    fns = functions(mod)

    for inactivefn in inactivefns
        if haskey(fns, inactivefn)
            fn = fns[inactivefn]
            push!(function_attributes(fn), inactive)
        end
    end

    for activefn in activefns
        if haskey(fns, activefn)
            fn = fns[activefn]
            push!(function_attributes(fn), active)
        end
    end

    for fname in ("julia.typeof",)
        if haskey(fns, fname)
            fn = fns[fname]
            push!(function_attributes(fn), LLVM.EnumAttribute("readnone", 0; ctx))
            push!(function_attributes(fn), LLVM.StringAttribute("enzyme_shouldrecompute"; ctx))
        end
    end

    for fname in ("julia.get_pgcstack", "julia.ptls_states", "jl_get_ptls_states")
        if haskey(fns, fname)
            fn = fns[fname]
            # TODO per discussion w keno perhaps this should change to readonly / inaccessiblememonly
            push!(function_attributes(fn), LLVM.EnumAttribute("readnone", 0; ctx))
        end
    end

    for fname in ("julia.pointer_from_objref",)
        if haskey(fns, fname)
            fn = fns[fname]
            push!(function_attributes(fn), LLVM.EnumAttribute("readnone", 0; ctx))
        end
    end

    for boxfn in ("jl_box_float32", "jl_box_float64", "jl_box_int32", "jl_box_int64", "julia.gc_alloc_obj", "jl_alloc_array_1d", "jl_alloc_array_2d", "jl_alloc_array_3d")
        if haskey(fns, boxfn)
            fn = fns[boxfn]
            push!(return_attributes(fn), LLVM.EnumAttribute("noalias", 0; ctx))
            push!(function_attributes(fn), LLVM.EnumAttribute("inaccessiblememonly", 0; ctx))
        end
    end

    for gc in ("llvm.julia.gc_preserve_begin", "llvm.julia.gc_preserve_end")
        if haskey(fns, gc)
            fn = fns[gc]
            push!(function_attributes(fn), LLVM.EnumAttribute("inaccessiblememonly", 0; ctx))
        end
    end

    for rfn in ("jl_object_id_", "jl_object_id")
        if haskey(fns, rfn)
            fn = fns[rfn]
            push!(function_attributes(fn), LLVM.EnumAttribute("readonly", 0; ctx))
        end
    end

    for rfn in ("jl_in_threaded_region_", "jl_in_threaded_region")
        if haskey(fns, rfn)
            fn = fns[rfn]
            push!(function_attributes(fn), LLVM.EnumAttribute("readonly", 0; ctx))
            push!(function_attributes(fn), LLVM.EnumAttribute("inaccessiblememonly", 0; ctx))
        end
    end
end


text:
include("algorithm.jl");

numberOfParticle = 10;
numberOfOperands = 6;
minRang = -1;
maxRang = 1;
targetValue = 0;
maxIteration = 2000;
maxVelocity = 1;

swarm = generateSwarm(numberOfParticle,numberOfOperands,minRang,maxRang);
PsoAlgorithm(swarm,targetValue,maxIteration);

max_stars_repo_name: pikacxe/Primenjeni-Algoritmi

max_issues_repo_name: pikacxe/Primenjeni-Algoritmi

max_forks_repo_name: pikacxe/Primenjeni-Algoritmi


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

struct DiskAccessesApi <: SwaggerApi
    client::Swagger.Client
end

"""

Creates or updates a disk access resource
Param: subscriptionId::String (required)
Param: resourceGroupName::String (required)
Param: diskAccessName::String (required)
Param: api_version::String (required)
Param: diskAccess::DiskAccess (required)
Return: DiskAccess
"""
function _swaggerinternal_diskAccessesCreateOrUpdate(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String, diskAccess; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PUT", DiskAccess, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", ["azure_auth"], diskAccess)
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "diskAccessName", diskAccessName)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function diskAccessesCreateOrUpdate(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String, diskAccess; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesCreateOrUpdate(_api, subscriptionId, resourceGroupName, diskAccessName, api_version, diskAccess; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function diskAccessesCreateOrUpdate(_api::DiskAccessesApi, response_stream::Channel, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String, diskAccess; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesCreateOrUpdate(_api, subscriptionId, resourceGroupName, diskAccessName, api_version, diskAccess; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Deletes a disk access resource.
Param: subscriptionId::String (required)
Param: resourceGroupName::String (required)
Param: diskAccessName::String (required)
Param: api_version::String (required)
Return: Nothing
"""
function _swaggerinternal_diskAccessesDelete(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "DELETE", Nothing, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "diskAccessName", diskAccessName)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function diskAccessesDelete(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesDelete(_api, subscriptionId, resourceGroupName, diskAccessName, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function diskAccessesDelete(_api::DiskAccessesApi, response_stream::Channel, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesDelete(_api, subscriptionId, resourceGroupName, diskAccessName, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets information about a disk access resource.
Param: subscriptionId::String (required)
Param: resourceGroupName::String (required)
Param: diskAccessName::String (required)
Param: api_version::String (required)
Return: DiskAccess
"""
function _swaggerinternal_diskAccessesGet(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", DiskAccess, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", ["azure_auth"])
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "diskAccessName", diskAccessName)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function diskAccessesGet(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesGet(_api, subscriptionId, resourceGroupName, diskAccessName, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function diskAccessesGet(_api::DiskAccessesApi, response_stream::Channel, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesGet(_api, subscriptionId, resourceGroupName, diskAccessName, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Gets the private link resources possible under disk access resource
Param: subscriptionId::String (required)
Param: resourceGroupName::String (required)
Param: diskAccessName::String (required)
Param: api_version::String (required)
Return: PrivateLinkResourceListResult
"""
function _swaggerinternal_diskAccessesGetPrivateLinkResources(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", PrivateLinkResourceListResult, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources", ["azure_auth"])
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "diskAccessName", diskAccessName)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function diskAccessesGetPrivateLinkResources(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesGetPrivateLinkResources(_api, subscriptionId, resourceGroupName, diskAccessName, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function diskAccessesGetPrivateLinkResources(_api::DiskAccessesApi, response_stream::Channel, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesGetPrivateLinkResources(_api, subscriptionId, resourceGroupName, diskAccessName, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Lists all the disk access resources under a subscription.
Param: subscriptionId::String (required)
Param: api_version::String (required)
Return: DiskAccessList
"""
function _swaggerinternal_diskAccessesList(_api::DiskAccessesApi, subscriptionId::String, api_version::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", DiskAccessList, "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses", ["azure_auth"])
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function diskAccessesList(_api::DiskAccessesApi, subscriptionId::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesList(_api, subscriptionId, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function diskAccessesList(_api::DiskAccessesApi, response_stream::Channel, subscriptionId::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesList(_api, subscriptionId, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Lists all the disk access resources under a resource group.
Param: subscriptionId::String (required)
Param: resourceGroupName::String (required)
Param: api_version::String (required)
Return: DiskAccessList
"""
function _swaggerinternal_diskAccessesListByResourceGroup(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, api_version::String; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "GET", DiskAccessList, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses", ["azure_auth"])
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function diskAccessesListByResourceGroup(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesListByResourceGroup(_api, subscriptionId, resourceGroupName, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function diskAccessesListByResourceGroup(_api::DiskAccessesApi, response_stream::Channel, subscriptionId::String, resourceGroupName::String, api_version::String; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesListByResourceGroup(_api, subscriptionId, resourceGroupName, api_version; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

"""

Updates (patches) a disk access resource.
Param: subscriptionId::String (required)
Param: resourceGroupName::String (required)
Param: diskAccessName::String (required)
Param: api_version::String (required)
Param: diskAccess::DiskAccessUpdate (required)
Return: DiskAccess
"""
function _swaggerinternal_diskAccessesUpdate(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String, diskAccess; _mediaType=nothing)
    _ctx = Swagger.Ctx(_api.client, "PATCH", DiskAccess, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}", ["azure_auth"], diskAccess)
    Swagger.set_param(_ctx.path, "subscriptionId", subscriptionId)  # type String
    Swagger.set_param(_ctx.path, "resourceGroupName", resourceGroupName)  # type String
    Swagger.set_param(_ctx.path, "diskAccessName", diskAccessName)  # type String
    Swagger.set_param(_ctx.query, "api-version", api_version)  # type String
    Swagger.set_header_accept(_ctx, ["application/json"])
    Swagger.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json"] : [_mediaType])
    return _ctx
end

function diskAccessesUpdate(_api::DiskAccessesApi, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String, diskAccess; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesUpdate(_api, subscriptionId, resourceGroupName, diskAccessName, api_version, diskAccess; _mediaType=_mediaType)
    Swagger.exec(_ctx)
end

function diskAccessesUpdate(_api::DiskAccessesApi, response_stream::Channel, subscriptionId::String, resourceGroupName::String, diskAccessName::String, api_version::String, diskAccess; _mediaType=nothing)
    _ctx = _swaggerinternal_diskAccessesUpdate(_api, subscriptionId, resourceGroupName, diskAccessName, api_version, diskAccess; _mediaType=_mediaType)
    Swagger.exec(_ctx, response_stream)
end

export diskAccessesCreateOrUpdate, diskAccessesDelete, diskAccessesGet, diskAccessesGetPrivateLinkResources, diskAccessesList, diskAccessesListByResourceGroup, diskAccessesUpdate


text:
using JuMP
using Ipopt
using CSV, DataFrames, DataStructures, MathOptFormat
using Statistics,Distributions, StatsFuns, StatsBase
using PyPlot

function LRO_opt(df,gamma_step,moment_info, x_bounds=nothing, recover_SAA=nothing)
    # calculate optimal stocking quantity x_var using LRO framework (convexification of problem (14) in the paper)
    # df - dataframe, historical observed demand data
    #gamma_step - int, amount to vary gamma by (for experments)
    #moment_info - boolean, true if using moment information, false else
    #x_bounds - int or nothing, value to fix x to (for experiments), free otherwise

    b = 1 #underage cost
    h = 1 #overage cost

    N_i = get_occurences(df)  #construct N_i observation data
    N = sum(N_i[:,"Occurence"])

    gamma_temp = get_gamma_val(N_i, N)  #get gamma value

    gamma = gamma_temp += gamma_step

    model = Model(with_optimizer(Ipopt.Optimizer,print_level=0))

    @variable(model, lambda_var >=0)

    @variable(model, y_vars[1:length(N_i[:,"Occurence"])] >=0)

    if isnothing(x_bounds)
        @variable(model, x_var)
    else
        @variable(model, x_bounds <= x_var <= x_bounds)
    end

    if moment_info
        @variable(model, mu_vars[1:3])

    else
        @variable(model, mu_var)
    end

    z = sum(N_i[:,"Occurence"] .* log.(N_i[:,"Occurence"])) #to store log likelihood

    var_len = length(N_i[:,"Occurence"])

    if !isnothing(recover_SAA) #only if testing if we can recover SAA for sanity
        data_size = length(df[:,"Column1"])

        @variable(model, z_vars[1:data_size]) #define variable to linearize max behavior of objective function

        @constraint(model,con3[i = 1:data_size], z_vars[i] >= x_var - df[:,"Column1"][i])
        @constraint(model, con4[i = 1:data_size], z_vars[i] >= df[:,"Column1"][i] - x_var )

        @constraint(model, lambda_var == 1/N *(sum(z_vars[i]  for i in 1:var_len) - mu_var)) # analytically solve for lambda according to Proposition 1, and p_i is empirical distribution
    end

    if moment_info
        mu_hat = mean(df[:,"Column1"])
        sigma_sq_hat = var(df[:,"Column1"])
        b_vec = [1, mu_hat, mu_hat^2 + sigma_sq_hat]

        @constraint(model,con1[i = 1:var_len], b * (N_i[:,"Demand"][i] - x_var) + y_vars[i] <= mu_vars[1]
        + mu_vars[2] * N_i[:,"Demand"][i] + mu_vars[3] * N_i[:,"Demand"][i]^2)

        @constraint(model, con2[i = 1:var_len], h * (x_var - N_i[:,"Demand"][i]) + y_vars[i] <= mu_vars[1]
        + mu_vars[2] * N_i[:,"Demand"][i] + mu_vars[3] * N_i[:,"Demand"][i]^2)
    else
        @constraint(model,con1[i = 1:var_len], b * (N_i[:,"Demand"][i] - x_var) + y_vars[i] <= mu_var)
        @constraint(model, con2[i = 1:var_len], h * (x_var - N_i[:,"Demand"][i]) + y_vars[i] <= mu_var)
    end

    if moment_info
        @NLobjective(model, Min, sum(b_vec[i] * mu_vars[i] for i in 1:3) + lambda_var * (z - N - gamma) + N * lambda_var * log(lambda_var)
         - lambda_var * sum(N_i[:,"Occurence"][j] * log(y_vars[j]) for j in 1:var_len))
    else
        @NLobjective(model, Min, mu_var + lambda_var * (z - N - gamma) + N * lambda_var * log(lambda_var)
         - lambda_var * sum(N_i[:,"Occurence"][j] * log(y_vars[j]) for j in 1:var_len))
    end

    write_LP(model,"model")

    optimize!(model)

    if isnothing(x_bounds)
        return value(x_var) # return x* (optimal stocking quantity) for experiments
    else
        return objective_value(model) # return objective value for experiments
    end
end


text:
__precompile__()

module DiffRules

include("api.jl")
include("rules.jl")

end # module


text:
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/BoundingSphere.jl/blob/master/LICENSE

using BoundingSphere
const MB = BoundingSphere
using BenchmarkTools
using StaticArrays

for (dim, npoints) in [
                        (2, 100),
                        (3,1000)
                      ]
    seed!(42)
    pts = [@SVector(randn(3)) for _ in 1:npoints]
    for A in subtypes(MB.BoundingSphereAlg)
        alg = A()
        println("Running $alg on $npoints points of dimension $dim")
        trial = @benchmark boundingsphere($pts, $alg)
        show(stdout, MIME"text/plain"(), trial)
        println()
    end
end


text:
using Gadfly, Compat

plot((x,y) -> x*exp(-(x-(@compat round(Int, x)))^2-y^2), -8., 8, -2., 2)


text:
include("Object.jl")
include("Passive.jl")
include("Contacts.jl")
include("Semiconductor.jl")
include("VirtualVolumes.jl")
include("SolidStateDetector.jl")

function sample(det::SolidStateDetector{T}, ::Type{Cartesian}, sampling...)::Vector{CartesianPoint{T}} where {T <: SSDFloat}
    imp::Vector{CartesianPoint{T}} = vcat(
        CartesianPoint.(sample(det.semiconductor.geometry, sampling...)),
        [CartesianPoint.(sample(g.geometry, sampling...)) for object in skipmissing((det.contacts, det.passives)) for g in object]...)
    unique!(imp)
end

function sample(det::SolidStateDetector{T}, ::Type{Cylindrical}, sampling...)::Vector{CylindricalPoint{T}} where {T <: SSDFloat}
    imp::Vector{CylindricalPoint{T}} = vcat(
    CylindricalPoint.(sample(det.semiconductor.geometry, sampling...)),
    [CylindricalPoint.(sample(g.geometry, sampling...)) for object in skipmissing((det.contacts, det.passives)) for g in object]...)
    unique!(imp)
end

# go_to_nearest_gridpoint
function searchsortednearest(grid::CylindricalGrid{T}, pt::CylindricalPoint{T})::CylindricalPoint{T} where {T <: SSDFloat}
    idx1::Int = searchsortednearest(grid.axes[1].ticks, pt.r)
    idx2::Int = searchsortednearest(grid.axes[2].ticks, pt.φ)
    idx3::Int = searchsortednearest(grid.axes[3].ticks, pt.z)
    CylindricalPoint{T}(grid.axes[1].ticks[idx1], grid.axes[2].ticks[idx2], grid.axes[3].ticks[idx3])
end
function searchsortednearest(grid::CartesianGrid3D{T}, pt::CartesianPoint{T})::CartesianPoint{T} where {T <: SSDFloat}
    idx1::Int = searchsortednearest(grid.axes[1].ticks, pt.x)
    idx2::Int = searchsortednearest(grid.axes[2].ticks, pt.y)
    idx3::Int = searchsortednearest(grid.axes[3].ticks, pt.z)
    CartesianPoint{T}(grid.axes[1].ticks[idx1], grid.axes[2].ticks[idx2], grid.axes[3].ticks[idx3])
end

get_charge_density(sc::Semiconductor{T}, pt::AbstractCoordinatePoint{T}) where {T <: SSDFloat} =
    get_impurity_density(sc.impurity_density_model, pt) * elementary_charge

get_charge_density(p::Passive{T}, pt::AbstractCoordinatePoint{T}) where {T <: SSDFloat} =
    get_charge_density(p.charge_density_model, pt)

@inline function get_ρimp_ϵ_ρfix(pt::AbstractCoordinatePoint{T}, obj::Semiconductor)::Tuple{T, T, T} where {T <: SSDFloat}
    return get_charge_density(obj, pt), obj.material.ϵ_r, zero(T)
end
@inline function get_ρimp_ϵ_ρfix(pt::AbstractCoordinatePoint{T}, obj::Passive)::Tuple{T, T, T} where {T <: SSDFloat}
    return zero(T), obj.material.ϵ_r, get_charge_density(obj, pt)
end


text:
using COSMOAccelerators

@testset "EmptyAccelerator" begin
    ea = EmptyAccelerator()
    @test typeof(ea) == EmptyAccelerator
    iter = 1
    @test update!(ea, zeros(2), zeros(2),iter) == nothing
    @test accelerate!(zeros(2), zeros(2), ea, iter) == false

    @test was_successful(ea) == false
    @test restart!(ea) == nothing

end

max_issues_repo_name: oxfordcontrol/COSMOAccelerators

max_forks_repo_name: oxfordcontrol/COSMOAccelerators


text:
function fibsq48()
#
#  test polynomial suggested by Goedecker
#  square of Fibocacci polynomial
#
    n = 48;
    p = fib(n)
    p = conv(p,p)
    z = [-.9775253106342052;
         -.9693128478789493-.1267362311985826*im;
         -.9693128478789493+.1267362311985826*im;
         -.9448102919885515-.2513655659338360*im;
         -.9448102919885515+.2513655659338360*im;
         -.9044199317254038-.3718154066011398*im;
         -.9044199317254038+.3718154066011398*im;
         -.8488049242636358-.4860811780173362*im;
         -.8488049242636358+.4860811780173362*im;
         -.7788784384948876-.5922589089475263*im;
         -.7788784384948876+.5922589089475263*im;
         -.6957887129626554-.6885761217415814*im;
         -.6957887129626554+.6885761217415814*im;
         -.6009002821775153-.7734205049875106*im;
         -.6009002821775153+.7734205049875106*im;
         -.4957716929578976-.8453658760449938*im;
         -.4957716929578976+.8453658760449938*im;
         -.3821300978164688-.9031949785779086*im;
         -.3821300978164688+.9031949785779086*im;
         -.2618431760355581-.9459187037026260*im;
         -.2618431760355581+.9459187037026260*im;
         -.1368888970077769-.9727913710515751*im;
         -.1368888970077769+.9727913710515751*im;
         -.9323708922186879e-2-.9833217572983870*im;
         -.9323708922186879e-2+.9833217572983870*im;
         .1187501830426266-.9772796154416013*im;
         .1187501830426266+.9772796154416013*im;
         .2452176769219828-.9546974936920340*im;
         .2452176769219828+.9546974936920340*im;
         .3679828414167529-.9158677545985760*im;
         .3679828414167529+.9158677545985760*im;
         .4849990112751703-.8613348568446792*im;
         .4849990112751703+.8613348568446792*im;
         .5942953455083113-.7918833021200295*im;
         .5942953455083113+.7918833021200295*im;
         .6939977395882224-.7085224187149837*im;
         .6939977395882224+.7085224187149837*im;
         .7823414572835585-.6124708814099550*im;
         .7823414572835585+.6124708814099550*im;
         .8576732672059729-.5051474483453174*im;
         .8576732672059729+.5051474483453174*im;
         .9184452635324498-.3881803987843682*im;
         .9184452635324498+.3881803987843682*im;
         .9632174723875938-.2634528222232032*im;
         .9632174723875938+.2634528222232032*im;
         .9907153993859500-.1331861055266858*im;
         .9907153993859500+.1331861055266858*im;
         1.999999999999996];
    z = [z 2*ones(n)]
    p, PolyZeros(z)
end


text:
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder

name = "SQLite"
version = v"3.28.0"

# Collection of sources required to build SQLite
sources = [
    "https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz" =>
    "d61b5286f062adfce5125eaf544d495300656908e61fca143517afcc0a89b7c3",
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir
cd sqlite-autoconf-3280000/
./configure --prefix=$prefix --host=$target && make && make install
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = BinaryBuilder.supported_platforms()

# The products that we will ensure are always built
products(prefix) = [
    LibraryProduct(prefix, "libsqlite3", :libsqlite)
]

# Dependencies that must be installed before this package can be built
dependencies = []

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies)


text:
function [Grid] = InputGrid(filename,OrientFace)
Grid.nBar=[ 0  1   0    1
           -1  0  -1    0];
Grid.Dim=3;
Grid.Type='Quad';
fileID=fopen(filename);
tline=fgetl(fileID);
tline=fgetl(fileID);
NumNodes=str2num(tline);
Grid.NumNodes=NumNodes;
Nodes(1:NumNodes)=Node([0 0 0],0);
for i=1:NumNodes
  tline = fgetl(fileID);
  tt=str2num(tline);
  NodeNumber=tt(1);
  x=tt(2);
  y=tt(3);
  Nodes(NodeNumber)=Node([x;y;0],NodeNumber);
end
Grid.Nodes=Nodes;
tline=fgetl(fileID);
tline=fgetl(fileID);
NumEdges=str2num(tline);
Grid.NumEdges=NumEdges;
Edges(1:NumEdges)=Edge([1 2],Grid,0,0);
EdgeNumberB=1;
EdgeNumberI=1;
EdgeType=zeros(NumEdges,1);
for i=1:NumEdges
  tline=fgetl(fileID);
  tt=str2num(tline);
  EdgeNumber=tt(1);
  N1=tt(2);
  N2=tt(3);
  EdgeType(i)=tt(4);
  if EdgeType(i)==1
    Edges(EdgeNumber)=Edge([N1 N2],Grid,EdgeNumber,EdgeNumberB);
    EdgeNumberB=EdgeNumberB+1;
  else
    Edges(EdgeNumber)=Edge([N1 N2],Grid,EdgeNumber,EdgeNumberI);
    EdgeNumberI=EdgeNumberI+1;
  end
end
for i=1:NumEdges
  if EdgeType(i)==1
    Edges(i).EI=Edges(i).EI+EdgeNumberI-1;
  end
end
Grid.Edges=Edges;
Grid.NumEdgesI=EdgeNumberI-1;
Grid.NumEdgesB=EdgeNumberB-1;
tline=fgetl(fileID);
tline=fgetl(fileID);
NumFaces=str2num(tline);
Grid.NumFaces=NumFaces;
Faces(1:NumFaces)=Face([0 0 0 0],Grid,0,'x');
Type='o';
c=zeros(NumFaces,1);
for i=1:NumFaces
  c(i)=i;
  tline=fgetl(fileID);
  tt=str2num(tline);
  FaceNumber=tt(1);
  [Faces(FaceNumber),Grid]=Face(tt(2:end),Grid,FaceNumber,Type,OrientFace);
end
Grid.Faces=Faces;
%PlotFaceGrid(c,Grid,1)
fclose(fileID);
Grid=Orientation(Grid);
Grid=Renumbering(Grid);
end


text:
using Test
using FlatGeobuf
using FlatBuffers
using Tables
using TypedTables
using Downloads

@testset "FlatGeobuf" begin
    fna = "countries.fgb"
    fnb = "UScounties.fgb"
    isfile(fna) || Downloads.download("https://github.com/bjornharrtell/flatgeobuf/blob/master/test/data/countries.fgb?raw=true", fna)
    isfile(fnb) || Downloads.download("https://github.com/bjornharrtell/flatgeobuf/blob/master/test/data/UScounties.fgb?raw=true", fnb)

    @testset "Construction" begin
        crs = FlatGeobuf.Crs("epsg", 28992, "RD New", "Dutch grid", "proj+=asdas", "codestring")
        h = FlatGeobuf.Header(name="test", crs=crs)
        g = FlatGeobuf.Geometry()
    end

    @testset "Serializing and parsing" begin
        crs = FlatGeobuf.Crs("epsg", 28992, "RD New", "Dutch grid", "proj+=asdas", "codestring")
        h = FlatGeobuf.Header(name="test", crs=crs)

        # Write header
        open("example.bin", "w") do f FlatBuffers.serialize(f, h) end
        # Read header again
        nh = open("example.bin", "r") do f
            FlatBuffers.deserialize(f, FlatGeobuf.Header)
        end

        # Assert it's similar
        @test h.crs.wkt == nh.crs.wkt
    end

    @testset "Using testfiles" begin
        fgb = FlatGeobuf.read_file(fnb)
        features = collect(fgb)
        @test length(features) == 3221

        filter!(fgb, [-92.73405699999999, 32.580974999999995, -92.73405699999999, 32.580974999999995])
        features = collect(fgb)
        @test length(features) == 2

        fgb = FlatGeobuf.read_file(joinpath(@__DIR__, "null.fgb"))
        t = Table(fgb)
        @test ismissing(t.date[2])
        @test ismissing(t.name[2])
        @test ismissing(t.number[2])
    end
end